Skip to content
Closed
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 @@ -131,7 +131,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)

// Don't offer route parameter names when the parameter type can't be bound to route parameters.
// e.g. special types like HttpContext, non-primitive types that don't have a static TryParse method.
if (!IsCurrentParameterBindable(token, semanticModel, wellKnownTypes, context.CancellationToken))
if (!IsCurrentParameterBindable(token, semanticModel, context.CancellationToken))
{
return;
}
Expand Down Expand Up @@ -383,7 +383,7 @@ private static bool HasNonRouteAttribute(SyntaxToken token, SemanticModel semant
return false;
}

private static bool IsCurrentParameterBindable(SyntaxToken token, SemanticModel semanticModel, WellKnownTypes wellKnownTypes, CancellationToken cancellationToken)
private static bool IsCurrentParameterBindable(SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken)
{
if (token.Parent.IsKind(SyntaxKind.PredefinedType))
{
Expand All @@ -393,7 +393,7 @@ private static bool IsCurrentParameterBindable(SyntaxToken token, SemanticModel
var parameterTypeSymbol = semanticModel.GetSymbolInfo(token.Parent!, cancellationToken).GetAnySymbol();
if (parameterTypeSymbol is INamedTypeSymbol typeSymbol)
{
return ParsabilityHelper.GetParsability(typeSymbol, wellKnownTypes) == Parsability.Parsable;
return ParsabilityHelper.GetParsability(typeSymbol) == Parsability.Parsable;

}
else if (parameterTypeSymbol is IMethodSymbol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static void DisallowNonParsableComplexTypesOnParameters(

if (IsRouteParameter(routeUsage, handlerDelegateParameter))
{
var parsability = ParsabilityHelper.GetParsability(parameterTypeSymbol, wellKnownTypes);
var parsability = ParsabilityHelper.GetParsability(parameterTypeSymbol);

if (parsability != Parsability.Parsable)
{
Expand Down Expand Up @@ -97,7 +97,7 @@ static bool IsRouteParameter(RouteUsageModel routeUsage, IParameterSymbol handle
static bool ReportFromAttributeDiagnostic(OperationAnalysisContext context, WellKnownType fromMetadataInterfaceType, WellKnownTypes wellKnownTypes, IParameterSymbol parameter, INamedTypeSymbol parameterTypeSymbol, Location location)
{
var fromMetadataInterfaceTypeSymbol = wellKnownTypes.Get(fromMetadataInterfaceType);
var parsability = ParsabilityHelper.GetParsability(parameterTypeSymbol, wellKnownTypes);
var parsability = ParsabilityHelper.GetParsability(parameterTypeSymbol);
if (parameter.HasAttributeImplementingInterface(fromMetadataInterfaceTypeSymbol) && parsability != Parsability.Parsable)
{
context.ReportDiagnostic(Diagnostic.Create(
Expand Down
8 changes: 2 additions & 6 deletions src/Http/Http.Extensions/gen/RequestDelegateGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.AspNetCore.Analyzers.Infrastructure;
using Microsoft.AspNetCore.App.Analyzers.Infrastructure;
using Microsoft.AspNetCore.Http.RequestDelegateGenerator.StaticRouteHandlerModel;
using Microsoft.AspNetCore.Http.RequestDelegateGenerator.StaticRouteHandlerModel.Emitters;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Operations;

namespace Microsoft.AspNetCore.Http.RequestDelegateGenerator;

Expand All @@ -26,10 +23,9 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
transform: static (context, token) =>
{
var operation = context.SemanticModel.GetOperation(context.Node, token);
var wellKnownTypes = WellKnownTypes.GetOrCreate(context.SemanticModel.Compilation);
if (operation.IsValidOperation(wellKnownTypes, out var invocationOperation))
if (operation.IsValidOperation(out var invocationOperation))
{
return new Endpoint(invocationOperation, wellKnownTypes, context.SemanticModel);
return new Endpoint(invocationOperation, context.SemanticModel);
}
return null;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ public override void ReportSuppressions(SuppressionAnalysisContext context)

var semanticModel = context.GetSemanticModel(sourceTree);
var operation = semanticModel.GetOperation(node, context.CancellationToken);
var wellKnownTypes = WellKnownTypes.GetOrCreate(semanticModel.Compilation);
if (operation.IsValidOperation(wellKnownTypes, out var invocationOperation))
if (operation.IsValidOperation(out var invocationOperation))
{
var endpoint = new Endpoint(invocationOperation, wellKnownTypes, semanticModel);
var endpoint = new Endpoint(invocationOperation, semanticModel);
if (endpoint.Diagnostics.Count == 0)
{
var targetSuppression = diagnostic.Id == SuppressRUCDiagnostic.SuppressedDiagnosticId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Http.RequestDelegateGenerator.StaticRouteHandlerM

internal class Endpoint
{
public Endpoint(IInvocationOperation operation, WellKnownTypes wellKnownTypes, SemanticModel semanticModel)
public Endpoint(IInvocationOperation operation, SemanticModel semanticModel)
{
Operation = operation;
Location = GetLocation(operation);
Expand All @@ -28,7 +28,7 @@ public Endpoint(IInvocationOperation operation, WellKnownTypes wellKnownTypes, S
return;
}

Response = new EndpointResponse(method, wellKnownTypes);
Response = new EndpointResponse(method);
Response.EmitRequiredDiagnostics(Diagnostics, Operation.Syntax.GetLocation());
IsAwaitable = Response?.IsAwaitable == true;

Expand Down Expand Up @@ -56,7 +56,7 @@ public Endpoint(IInvocationOperation operation, WellKnownTypes wellKnownTypes, S
{
continue;
}
var parameter = new EndpointParameter(this, parameterSymbol, wellKnownTypes);
var parameter = new EndpointParameter(this, parameterSymbol);

switch (parameter.Source)
{
Expand Down
Loading