Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static void DisallowNonParsableComplexTypesOnParameters(
continue;
}

var parameterTypeSymbol = ResovleParameterTypeSymbol(handlerDelegateParameter);
var parameterTypeSymbol = ResolveParameterTypeSymbol(handlerDelegateParameter);

// If this is null it means we aren't working with a named type symbol.
if (parameterTypeSymbol == null)
Expand Down Expand Up @@ -113,7 +113,7 @@ static bool ReportFromAttributeDiagnostic(OperationAnalysisContext context, Well
return false;
}

static INamedTypeSymbol? ResovleParameterTypeSymbol(IParameterSymbol parameterSymbol)
static INamedTypeSymbol? ResolveParameterTypeSymbol(IParameterSymbol parameterSymbol)
{
INamedTypeSymbol? parameterTypeSymbol = null;

Expand All @@ -127,8 +127,10 @@ static bool ReportFromAttributeDiagnostic(OperationAnalysisContext context, Well
parameterTypeSymbol = namedTypeSymbol;
}

// If it is nullable, unwrap it.
if (parameterTypeSymbol!.ConstructedFrom.SpecialType == SpecialType.System_Nullable_T)
// If it is nullable and we have type arguments, unwrap it.
// The length check aims to alleviate AD0001 warnings when referencing methods in external class libraries that contain parameters
if (parameterTypeSymbol!.ConstructedFrom.SpecialType == SpecialType.System_Nullable_T &&
parameterTypeSymbol.TypeArguments.Length > 0)
{
parameterTypeSymbol = parameterTypeSymbol.TypeArguments[0] as INamedTypeSymbol;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Security.Policy;
using Microsoft.CodeAnalysis.Testing;
using VerifyCS = Microsoft.AspNetCore.Analyzers.Verifiers.CSharpAnalyzerVerifier<Microsoft.AspNetCore.Analyzers.RouteHandlers.RouteHandlerAnalyzer>;

Expand Down
Loading