-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Description
When using the OpenFeature CLI code generator for C# in projects that have "warnings as errors" enabled, the generated code produces a compilation error.
Error
1>OpenFeature.g.cs(535,84): Error CS8669 :The annotation for Nullable reference types must only be used in code within a '#nullable' annotations context. Automatically generated code requires an explicit '#nullable' directive in the source.
Steps to Reproduce
- Create a C# project with
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>in the.csprojfile - Generate C# code using the OpenFeature CLI code generator
- Attempt to build the project
- Observe the CS8669 compilation error in the generated
OpenFeature.g.csfile
Repro : https://github.com/tomflenner/openfeature-cli-sharp-repro
Expected Behavior
The generated code should compile without errors, even in projects with warnings as errors enabled.
Proposed Solution
Add #nullable enable directive at the top of the generated C# file (OpenFeature.g.cs). This will provide the explicit nullable context required by the compiler.
Workaround
Used this rules in my .editorconfig :
[**/*.g.cs]
generated_code = true
# Disable nullable reference type warnings in generated code
dotnet_diagnostic.CS8669.severity = none
Metadata
Metadata
Assignees
Labels
No labels