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
The default "nullable context" for newly-generated C# projects targeting .NET 6 is now set to "enable" at the project level; this means all code generated by the dotnet-dbus codegen command will receive the context that is set for the entire project unless it is overwritten at the source file level.
This means that every time the generated code tries to assign null to a reference type, we get a compiler warning. When following along with the example included in the README.md file, for example, I observed the same warning 81 times:
warning CS8625: Cannot convert null literal to non-nullable reference type.
Given that the codegen command has no knowledge of the C# project it will be generating code for, I propose we fix this issue with one of the following solutions:
Disable the nullable context for all codegen-generated source files by prepending "#nullable disable" to the top of each file
Add a --nullable option for the codegen command that optimizes the generated code to take advantage of new nullable context features. (This obviously requires more work)
The default "nullable context" for newly-generated C# projects targeting .NET 6 is now set to "enable" at the project level; this means all code generated by the
dotnet-dbus codegen
command will receive the context that is set for the entire project unless it is overwritten at the source file level.This means that every time the generated code tries to assign
null
to a reference type, we get a compiler warning. When following along with the example included in the README.md file, for example, I observed the same warning 81 times:For reference, I have included the following to provide more information on this issue:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types#setting-the-nullable-context
The text was updated successfully, but these errors were encountered: