JetBrains InspectCode caching causes it to ignore files with #nullable annotations changed

We have a build server which takes advantage of InspectCode caching to speed up run time. However it seems to miss issues when the sole change to a file is the removal of a "#nullable" annotation. InspectCode does not behave correctly and I think it does not flag these files as being changed. Here an example:

Program.cs

#nullable enable
using System;

namespace InspectCodeBugTest
{
static class Program
{
static void Main()
{
var result = TestTriggerInspectCode(new TestClass("a"));
Console.WriteLine(result);
}

static int TestTriggerInspectCode(TestClass a)
{
return a.MyTestString?.Length ?? 0;
}
}
}

TestClass.cs

#nullable enable
#nullable disable // Comment this line to cause TestTriggerInspectCode to have a style issue

namespace InspectCodeBugTest
{
class TestClass
{
public TestClass(string myTestString)
{
MyTestString = myTestString;
}

public readonly string MyTestString;
}
}

Bash script to reproduce:

# Run #1 - don't change anything
jb inspectcode InspectCodeBugTest.csproj -o=JetbrainsInspectCodeOutput.xml --caches-home=InspectCodeCache --verbosity=FATAL --build
# Debug output: JetBrains Inspect Code 2021.2 Running on AMD 64 in 64-bit mode, .NET runtime 5.0.8 under Unix 5.8.0.44
cat JetbrainsInspectCodeOutput.xml # No issues as expected

# Run #2 - introduce the issue but InspectCode still passes
vim TestClass.cs # Comment the #nullable disable which should cause an issue
jb inspectcode InspectCodeBugTest.csproj -o=JetbrainsInspectCodeOutput.xml --caches-home=InspectCodeCache --verbosity=FATAL --build
cat JetbrainsInspectCodeOutput.xml # No issues even with the #nullable disable removed

# Run #3 - delete the cache and now InspectCode will fail because it is building from scratch
rm InspectCodeCache -r # Remove the cache
jb inspectcode InspectCodeBugTest.csproj -o=JetbrainsInspectCodeOutput.xml --caches-home=InspectCodeCache --verbosity=FATAL --build
cat JetbrainsInspectCodeOutput.xml # The issue appears because the cache was removed
1 comment
Comment actions Permalink

Hello Jadentom

We're aware of the issue: 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\v212\SolutionCaches or the entire SolutionCaches directory.

0

Please sign in to leave a comment.