Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a property has a default value, emit System.ComponentModel.DefaultValueAttribute #58

Closed
ghost opened this issue Dec 26, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 26, 2018

Do this automatically, without requiring an AttributeHint​​​​​​​ in CodeGenHints.json.

@ghost ghost closed this as completed in 7358e25 Dec 28, 2018
@ghost ghost self-assigned this Dec 28, 2018
@ghost ghost added the resolved-fixed label Dec 28, 2018
michaelcfanning added a commit that referenced this issue Dec 29, 2018
* Remove dependency on RuleMessageId (shortly to be deprecated) (#24)

* Release 0.57.0

* Todotnet package (#30)

* Add utilities to validation and todotnet packages

* Update nuget.exe. Add success message for nuspec-driven package creation.

* Update signing scripts

* Release 0.58.0 (#32)

* Address PR feedback from 0.58.0 release (#33)

Also:
* Build the `develop` branch in AppVeyor.

* Add dotnet publish step to build. (#34)

Also:
- Use `.CommandLine`, not `.Cli` in the command line tool namespaces.

* Disable appveyor email notifications (#36)

* Update to latest SARIF SDK + JSON.NET downgrade (#38)

* Fix ToDotNet.Cli project file so resources can be found. (#40)

When you run the ToDotNet command line app, it fails because it can't find the resource stream. Somehow the `.resx` and the `.Resources.designer` files got separated in the project file. Fix the project file to connect the resources back up.

* Rewrite top-level README in preparation for documenting each component. (#47)

An almost complete rewrite.

* Fix #41: Document Json.Pointer (#48)

* embed resx resources (#53)

* Add unit test to demonstrate interaction of ClassNameHint with other hints (#54)

* Start codegen README (#59)

* Fix #57, fix #58: Emit initializers and attributes for default values (#60)

#57: When a schema property declares a default value, assign that value to the property in the default constructor. This ensures that the property has the correct default even if you construct the object by hand rather than by deserializing it from JSON.

#58: When a schema property declares a default value, decorate the property with a `System.ComponentModel.DefaultValue` attribute. This avoids your having to specify those attributes in the CodeGenHints.json file, which is error-prone.

Also:
- Fix a bug where the generated doc comments for properties had an extra space: `cref="P: propName`" → `cref="P:propName`".
- Address some hygiene-related IDE messages by marking some properties `readonly`, and by inlining the declarations of some `out` parameters.

* Fix #61: Generate JsonProperty attribute for properties with defaults (#62)

* Add final release note in advance of shipping 0.59.0
michaelcfanning added a commit that referenced this issue Dec 30, 2018
* Remove dependency on RuleMessageId (shortly to be deprecated) (#24)

* Release 0.57.0

* Todotnet package (#30)

* Add utilities to validation and todotnet packages

* Update nuget.exe. Add success message for nuspec-driven package creation.

* Update signing scripts

* Release 0.58.0 (#32)

* Address PR feedback from 0.58.0 release (#33)

Also:
* Build the `develop` branch in AppVeyor.

* Add dotnet publish step to build. (#34)

Also:
- Use `.CommandLine`, not `.Cli` in the command line tool namespaces.

* Disable appveyor email notifications (#36)

* Update to latest SARIF SDK + JSON.NET downgrade (#38)

* Fix ToDotNet.Cli project file so resources can be found. (#40)

When you run the ToDotNet command line app, it fails because it can't find the resource stream. Somehow the `.resx` and the `.Resources.designer` files got separated in the project file. Fix the project file to connect the resources back up.

* Rewrite top-level README in preparation for documenting each component. (#47)

An almost complete rewrite.

* Fix #41: Document Json.Pointer (#48)

* embed resx resources (#53)

* Add unit test to demonstrate interaction of ClassNameHint with other hints (#54)

* Start codegen README (#59)

* Fix #57, fix #58: Emit initializers and attributes for default values (#60)

#57: When a schema property declares a default value, assign that value to the property in the default constructor. This ensures that the property has the correct default even if you construct the object by hand rather than by deserializing it from JSON.

#58: When a schema property declares a default value, decorate the property with a `System.ComponentModel.DefaultValue` attribute. This avoids your having to specify those attributes in the CodeGenHints.json file, which is error-prone.

Also:
- Fix a bug where the generated doc comments for properties had an extra space: `cref="P: propName`" → `cref="P:propName`".
- Address some hygiene-related IDE messages by marking some properties `readonly`, and by inlining the declarations of some `out` parameters.

* Fix #61: Generate JsonProperty attribute for properties with defaults (#62)

* Add final release note in advance of shipping 0.59.0

* Update licensing reference to satisfy NuGet improvements in this area. (#65)
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants