BuilderGenerator icon indicating copy to clipboard operation
BuilderGenerator copied to clipboard

CS8669 warning for types with nullable properties

Open j-mok opened this issue 1 year ago • 0 comments

I've got a .NET 8/C# 12 project with nullable references enabled and when I use BuilderGenerator on a class that has properties with nullable reference types, the generated builder becomes a source of compiler warnings:

FooDtoBuilder.g.cs(102,77): 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.

This seems to be a consequence of a combination of #nullable disable in the generated code and the keeping the ? suffix on data fields:

public System.Lazy<string?> BazProperty = new System.Lazy<string?>(() => default(string?));

Can this be fixed somehow?

j-mok avatar Jul 11 '24 09:07 j-mok