Serialised fields require correct type #1720
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements the rules of the Unity serialiser, so that only fields with a correct type will be recognised as serialised fields.
If the field does not have the proper type, it is not recognised as a serialised field, is not marked as implicitly used, does not get a gutter icon/code vision marker, and is not highlighted as an implicitly used identifier.
The rules are taken from the Unity docs, with the addition that Unity 2020.1 allows serialising fields with generic type. This isn't documented, but is mentioned in this blog post. There is also special treatment for
System.Version
, which appears to be have specific handling in Unity - Mono marks it as serialisable, but netstandard doesn't - Unity treats it as non-serialisable, and so does Rider.This PR also moves a couple of files around, and updates the tests to support Unity 2019.3, 2019.4 and 2020.1, which means lots of file changes… There are also fixes to the attributed method signature test analyser, which the updated tests highlighted.