You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this generates without issues and is actually usable, but the following compiler warning is listed for the generated file. One warning per line that uses ? on a reference type.
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.
I'm not sure how to check whether one can/should enable the nullable context in the generated source for all users of this awesome generator, but to resolve it all we need is to add #nullable enable somewhere at the top of the file!
The text was updated successfully, but these errors were encountered:
Hmm. Interesting that they know which files are generated. O.o
Also, good to know that the NRT propagates even though it's expected to support C#7.3 at most.
As per the issue at hand: well, I think the actual support will come only when my upstream (CodeGeneration.Roslyn) will be able to pass the generator a variable saying whether the Nullable feature is on or off in the project.
Maybe it can be done upstream in full, so that the directive, if you have it in your source file, is preserved. That way you can "workaround" by duplicating the project setting in source files as well.
Thanks for the quick reply, and the detailed information!
Interesting that they know which files are generated.
I believe Roslyn nowadays checks for GeneratedCodeAttribute, maybe even the <auto-generated> comment tag.
Also, good to know that the NRT propagates even though it's expected to support C#7.3 at most.
For sure! To me, this means this issue is thankfully not a blocker: I just disabled the warning in our project and it's working fine. Thankfully the compiler team added this warning as a specific one, i.e. disabling it won't toggle off anything else as far as I can see.
Looks like the dotnet team decided auto-generated code needs to explicitly opt-in into nullable reference types:
In a project with
this generates without issues and is actually usable, but the following compiler warning is listed for the generated file. One warning per line that uses
?
on a reference type.I'm not sure how to check whether one can/should enable the nullable context in the generated source for all users of this awesome generator, but to resolve it all we need is to add
#nullable enable
somewhere at the top of the file!The text was updated successfully, but these errors were encountered: