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

Null Reference Types cause CS8669 #1195

Closed
AceHack opened this issue Jun 13, 2020 · 2 comments · Fixed by #1201
Closed

Null Reference Types cause CS8669 #1195

AceHack opened this issue Jun 13, 2020 · 2 comments · Fixed by #1201

Comments

@AceHack
Copy link

AceHack commented Jun 13, 2020

warning CS8669: The annotation for nullable reference types
    should only be used in code within a '#nullable' annotations context. Auto-generated code
    requires an explicit '#nullable' directive in source.

Please add explicit #nullable when null reference types are used. This happens even with Nullable is turned on at the project level.

@RicoSuter
Copy link
Owner

This happens even with Nullable is turned on at the project level.

My idea was that you’d turn this on in the csproj - but this doesnt work because its autogenerated?

jeremyVignelles pushed a commit to jeremyVignelles/NJsonSchema that referenced this issue Jun 18, 2020
Added a `#nullable enable` directive in generated C# source only if
`GenerateNullableReferenceTypes` is set to `true`.

Fixes RicoSuter#1195
@jeremyVignelles
Copy link
Contributor

@AceHack : FYI, I opened #1201 to fix your issue. I've also added =default!; to all properties if no default value is provided and GenerateNRT is enabled. Would you like to try the branch and see if it works for you ?

RicoSuter pushed a commit that referenced this issue Jun 24, 2020
* Added a `#nullable enable` directive

Added a `#nullable enable` directive in generated C# source only if
`GenerateNullableReferenceTypes` is set to `true`.

Fixes #1195

* Fixed typo in Property name

* Added default values for generated properties in NRT context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants