Not recognising <Nullable>enable</Nullable>
Prior to upgrading to Reshaper 2020.1.3, I had enabled Nullable types by putting
<Nullable>enable</Nullable>
in the project file. Since updating to version 2020.1.3, Resharper appears to be ignoring this and insisting that every file that uses Nullable types has to have
#nullable enable
at the top of each file.
Please sign in to leave a comment.
Confirming this behavior in ReSharper commandline tool version 2020.2.4.
I have a .Net Core 3.1 .sln solution file, which points to multiple .csproj C# project files. The C# projects are configured with `<Nullable>enable</Nullable>`.
If I run `jb inspectcode SubProject/SubProject.csproj -o=inspectcode.xml` on the .csproj, it detects and respects the Nullable property correctly.
If I run `jb inspectcode TopLevel.sln -o=inspectcode.xml` on the .sln, it does not respect the property, and complains about every use of `?` in the C# project with:
> The annotation for nullable reference types should only be used in code within a '#nullable' annotations context
Bram John
This is a known issue in Command-Line Tools: https://youtrack.jetbrains.com/issue/RSRP-485906 Please feel free to comment and vote or just subscribe to the issue.
As a workaround, please try to clear the InspectCode caches for this solution by removing the corresponding sub-folder at
%LocalAppData%\JetBrains\Transient\InspectCode\v213\SolutionCaches
or the entire SolutionCaches directory.That doesn't sound like a Resharper issue. Note that using <Nullable>enable</Nullable> only works for new-style .csproj files - the old style ones ignore that setting. Could that be the issue?
Hello,
Sorry for the delay in responding.
Could you please provide some sample solution demonstrating the specified behavior? You can do it private via "Submit a request" form at the top of the page.
Thank you.
David A Riggs I wasn't able to reproduce the behavior on my side. Could you provide a sample solution which triggers this? You can do it privately via "Submit a request" form at the top of the page.
I see the same behaviour as David - running on subprojects and running via Rider works, but running the CLI tools shows a lot of compiler warnings ala
However these compiler warnings don't show up anywhere when i run `dotnet build`
Hello Gustavwengel
Could you please try deleting the following folder %LocalAppData%\JetBrains\Transient folder and check if it helps.
Thank you.
Is there any update on this issue?
We've run into the same issue in our project. Resharper works just fine in our local development environment(rider). However our build agent, which uses the following command:
jb inspectcode $(solution.file) --no-build --disable-settings-layers:SolutionPersonal --output=inspection_results.txt --format=text --severity=WARNING --verbosity=WARN --dotnetcoresdk=$(build.sdk)
if [[ `wc -l < inspection_results.txt` -gt 1 ]]; then
cat inspection_results.txt
exit 1
fi
fails with the notification: "The annotation for nullable reference types should only be used in code within a '#nullable' annotations context " on every file which uses nullability.
I'm seeing this in 2021.3.1 as well with .NET 6.0, with <Nullable>enable</Nullable> and <LangVersion>10.0</LangVersion>. It only incorrectly reports these issues on some machines, however.
C:\AzureDevOps\elitedev-1\_work\_tool\dotnet\dotnet.exe jb inspectcode --output=C:\AzureDevOps\elitedev-1\_work\27\a\issues.xml --no-build --severity=WARNING Elite.Data.sln