You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running the SonarScanner on an .NET Core project that passes null to the ArgumentNullException constructor results in a NullReferenceException being logged by CSC.
Repro steps
From a *nix environment:
Run mkdir sonar-csharp-AD0001
Run cd sonar-csharp-AD0001
Run dotnet new console
Edit the generated .csproj file and specify a ProjectGuid
Edit the generated Program.cs and add throw new ArgumentNullException(null, String.Empty);
Run dotnet <path-to-scanner> begin [args]
Run dotnet build
Run dotnet <path-to-scanner> end [args]
Expected behavior
No warnings logged by CSC.
Actual behavior
The following warning is found in the logs:
CSC : warning AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.CheckArgumentException' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'. [/Users/jdoe/src/tmp/sonar-csharp-AD0001/sonar-csharp-AD0001.csproj]
Known workarounds
Don't pass null to ArgumentNullException, but this should probably be a rule not a difficult to track down NullReferenceException.
Related information
SonarC# Version: 7.5 (build 6605)
SonarScanner Version: 4.3.1
SonarQube Version: 6.7.1 (build 35068)
.NET Core SDK Version: 2.1.402
MSBuild Version: 15.4.0.0
The text was updated successfully, but these errors were encountered:
Thanks for raising this issue!
It will be fixed on the next release.
Cheers,
Amaury
Evangelink
changed the title
AD0001 warning for NullReferenceException issued scanning "bad" ArgumentNullException code
Fix S3928: Rule should not throw NullReferenceException for ArgumentNullException with null parameter name
Sep 24, 2018
Description
Running the SonarScanner on an .NET Core project that passes
null
to theArgumentNullException
constructor results in aNullReferenceException
being logged by CSC.Repro steps
From a *nix environment:
mkdir sonar-csharp-AD0001
cd sonar-csharp-AD0001
dotnet new console
.csproj
file and specify aProjectGuid
Program.cs
and addthrow new ArgumentNullException(null, String.Empty);
dotnet <path-to-scanner> begin [args]
dotnet build
dotnet <path-to-scanner> end [args]
Expected behavior
No warnings logged by CSC.
Actual behavior
The following warning is found in the logs:
Known workarounds
Don't pass
null
toArgumentNullException
, but this should probably be a rule not a difficult to track downNullReferenceException
.Related information
7.5 (build 6605)
4.3.1
6.7.1 (build 35068)
2.1.402
15.4.0.0
The text was updated successfully, but these errors were encountered: