What is standard practice with new <Nullable>enable</Nullable>
setting for classes with properties that are bound at runtime that you know the value will not be null? Examples:
Strongly typed appsettings.json classes
public class CustomSettings
{
public CustomObject CustomObject { get; set; }
}
public class CustomObject
{
public string NonNullProperty { get; set; }
}
With json of:
{
"CustomSettings": {
"CustomObject": {
"NonNullProperty": "Some Value Here"
}
}
}
Custom MSBuild Task Properties
public class DependencyCopy : Task
{
[Required]
public string StartFolder { get; set; } = default!;
[Required]
public string ProjectName { get; set; } = default!;
[Required]
public string Configuration { get; set; } = default!;
[Required]
public string OutputFolder { get; set; }
}
With *.csproj settings of:
<DependencyCopy StartFolder="$(MSBuildProjectDirectory)" ProjectName="$(ProjectName)" Configuration="$(Configuration)" OutputFolder="$(OutputPath)" />
Should I be using #nullable disable
and #nullable restore
? Settings properties to = default!
?