File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Core/Microsoft.NetCore.Analyzers/Runtime
UnitTests/Microsoft.NetCore.Analyzers/Runtime Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,8 @@ aooreThrowIfGreaterThan is not null || aooreThrowIfGreaterThanOrEqual is not nul
180180 if ( SymbolEqualityComparer . Default . Equals ( objectCreationOperation . Type , ane ) )
181181 {
182182 if ( aneThrowIfNull is not null &&
183- IsParameterNullCheck ( condition . Condition , out IParameterReferenceOperation ? nullCheckParameter ) )
183+ IsParameterNullCheck ( condition . Condition , out IParameterReferenceOperation ? nullCheckParameter ) &&
184+ nullCheckParameter . Type . TypeKind == TypeKind . Class )
184185 {
185186 context . ReportDiagnostic ( condition . CreateDiagnostic (
186187 UseArgumentNullExceptionThrowIfNullRule ,
Original file line number Diff line number Diff line change @@ -177,6 +177,24 @@ string this[string name]
177177 return name;
178178 }
179179 }
180+
181+ void NullableArg(int? arg)
182+ {
183+ if (arg is null) throw new ArgumentNullException(nameof(arg));
184+ }
185+
186+ void GenericMethod<T>(T arg)
187+ {
188+ if (arg is null) throw new ArgumentNullException(nameof(arg));
189+ }
190+ }
191+
192+ class GenericType<T>
193+ {
194+ void M(T arg)
195+ {
196+ if (arg is null) throw new ArgumentNullException(nameof(arg));
197+ }
180198}
181199" ,
182200 FixedCode =
@@ -260,6 +278,24 @@ string this[string name]
260278 return name;
261279 }
262280 }
281+
282+ void NullableArg(int? arg)
283+ {
284+ if (arg is null) throw new ArgumentNullException(nameof(arg));
285+ }
286+
287+ void GenericMethod<T>(T arg)
288+ {
289+ if (arg is null) throw new ArgumentNullException(nameof(arg));
290+ }
291+ }
292+
293+ class GenericType<T>
294+ {
295+ void M(T arg)
296+ {
297+ if (arg is null) throw new ArgumentNullException(nameof(arg));
298+ }
263299}
264300"
265301 } . RunAsync ( ) ;
You can’t perform that action at this time.
0 commit comments