Improvements to the `[DataContract]` and `[DataContractIgnore]` attributes
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Is your feature request related to a problem? Please describe.
Currently, using other classes in a script is really annoying due to a few reason:
- Non-engine classes (like from external libraries) in lists aren't serialized and instead of being ignored, they throw errors due to the missing
[DataContractIgnore]attribute. - When adding the attributes, intelisense might suggest using the
System.Runtime.Serializationones that have the exact same names, but don't work.
Describe the solution you'd like
- Lists containing class and struct instances without a
[DataContract]attribute should just be ignored by default. This is how many other engines behave such as Unity. - The asset compiler should detect the usage of these attributes and log a warning that the wrong attribute is being used. I'm not sure if there should also be a way of disabling that warning for a class in case some external library uses it.
Describe alternatives you've considered
This behavior could be documented better, but I don't think there is a way of doing this that will stop users from being confused. Besides, removing the problem is a much better solution.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the asset compiler and the serialization handling for [DataContract] and [DataContractIgnore]. Check how unmarked classes and structs in lists are currently processed, and how similarly named System.Runtime.Serialization attributes are resolved. Done means unmarked list elements are ignored by default and incorrect attribute usage produces a suitable warning, with any external-library exception clarified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- game-dev, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100