NCCS raises nullable context error even when Nullable enabled in csproj file
In C# proj file:
<PropertyGroup>
<NeoContractName>SafePurchase</NeoContractName>
<NeoExpressBatchFile>..\express.batch</NeoExpressBatchFile>
<Nullable>enable</Nullable>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
Command line:
> dotnet nccs --debug --no-optimize "C:\Users\harry\Source\neo\seattle\samples\safe-purchase\contract\safe-purchase.csproj" --contract-name SafePurchase
Determining projects to restore...
All projects are up-to-date for restore.
C:\Users\harry\Source\neo\seattle\samples\safe-purchase\contract\SafePurchaseContract.cs(73,122): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
C:\Users\harry\Source\neo\seattle\samples\safe-purchase\contract\SafePurchaseContract.cs(68,27): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
Created C:\Users\harry\Source\neo\seattle\samples\safe-purchase\contract\bin\sc\SafePurchase.nef
Created C:\Users\harry\Source\neo\seattle\samples\safe-purchase\contract\bin\sc\SafePurchase.manifest.json
Created C:\Users\harry\Source\neo\seattle\samples\safe-purchase\contract\bin\sc\SafePurchase.nefdbgnfo
Compilation completed successfully.
The warning CS8632 lines should not be appearing
@devhawk Please check #687
@devhawk Please check #687
You've changed from defaulting Nullable options to Disabled to hardcoding Nullable options to Annotations. So if a project doesn't specify Nullable in their project file (which is the default as of .NET 5) then they will get a bunch of nullability warnings from NCCS than they likely won't understand and won't match the output of C# compiler.
According to the docs in https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references
annotations: The compiler doesn't perform null analysis or emits warnings when code might dereference null.
It won't emit warnings. And the result of my test is the same.
It won't emit warnings. And the result of my test is the same.
Now it won't ever emit warnings, even if the user has explicitly opted-in to getting the warnings.
Further thoughts over on the PR : https://github.com/neo-project/neo-devpack-dotnet/pull/687#discussion_r740518411
Now it won't ever emit warnings, even if the user has explicitly opted-in to getting the warnings.
The users will get the warnings in IDE.