stride3d / stride3d/stride

Improvements to the `[DataContract]` and `[DataContractIgnore]` attributes

Open
#3,145 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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:

  1. 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.
  2. When adding the attributes, intelisense might suggest using the System.Runtime.Serialization ones that have the exact same names, but don't work.

Describe the solution you'd like

  1. 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.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.