Skip to content

Commit ba53749

Browse files
committed
Address feedback from peer review
1 parent 3c020e2 commit ba53749

File tree

42 files changed

+1005
-968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1005
-968
lines changed

src/Http/Http.Extensions/gen/RequestDelegateGenerator.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,21 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
6060
{
6161
using var stringWriter = new StringWriter(CultureInfo.InvariantCulture);
6262
using var codeWriter = new CodeWriter(stringWriter, baseIndent: 2);
63-
codeWriter.WriteLine($$"""[global::System.Runtime.CompilerServices.InterceptsLocation(@"{{endpoint!.Location.File}}", {{endpoint.Location.LineNumber}}, {{endpoint.Location.CharaceterNumber + 1}})]""");
64-
codeWriter.WriteLine($"internal static global::Microsoft.AspNetCore.Builder.RouteHandlerBuilder {endpoint!.HttpMethod}_{endpoint.Location.LineNumber}(");
63+
codeWriter.WriteLine($$"""[InterceptsLocation(@"{{endpoint.Location.File}}", {{endpoint.Location.LineNumber}}, {{endpoint.Location.CharacterNumber + 1}})]""");
64+
codeWriter.WriteLine($"internal static RouteHandlerBuilder {endpoint.HttpMethod}_{endpoint.Location.LineNumber}(");
6565
codeWriter.Indent++;
66-
codeWriter.WriteLine("this global::Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints,");
66+
codeWriter.WriteLine("this IEndpointRouteBuilder endpoints,");
6767
// MapFallback overloads that only take a delegate do not need a pattern argument
6868
if (endpoint.HttpMethod != "MapFallback" || endpoint.Operation.Arguments.Length != 2)
6969
{
70-
codeWriter.WriteLine(@"[global::System.Diagnostics.CodeAnalysis.StringSyntax(""Route"")] string pattern,");
70+
codeWriter.WriteLine(@"[StringSyntax(""Route"")] string pattern,");
7171
}
7272
// MapMethods overloads define an additional `httpMethods` parameter
7373
if (endpoint.HttpMethod == "MapMethods")
7474
{
75-
codeWriter.WriteLine("global::System.Collections.Generic.IEnumerable<string> httpMethods,");
75+
codeWriter.WriteLine("IEnumerable<string> httpMethods,");
7676
}
77-
codeWriter.WriteLine($"global::System.Delegate handler)");
77+
codeWriter.WriteLine("Delegate handler)");
7878
codeWriter.Indent--;
7979
codeWriter.StartBlock();
8080
codeWriter.WriteLine("MetadataPopulator populateMetadata = (methodInfo, options) =>");
@@ -135,7 +135,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
135135
codeWriter.WriteLine("return new RequestDelegateResult(targetDelegate, metadata);");
136136
codeWriter.EndBlockWithSemicolon();
137137

138-
codeWriter.WriteLine("return global::Microsoft.AspNetCore.Http.Generated.GeneratedRouteBuilderExtensionsCore.MapCore(");
138+
codeWriter.WriteLine("return GeneratedRouteBuilderExtensionsCore.MapCore(");
139139
codeWriter.Indent++;
140140
codeWriter.WriteLine("endpoints,");
141141
// For `MapFallback` overloads that only take a delegate, provide the assumed default
@@ -149,7 +149,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
149149
codeWriter.WriteLine($"{SymbolDisplay.FormatLiteral("{*path:nonfile}", true)},");
150150
}
151151
codeWriter.WriteLine("handler,");
152-
codeWriter.WriteLine($"{endpoint!.EmitVerb()},");
152+
codeWriter.WriteLine($"{endpoint.EmitVerb()},");
153153
codeWriter.WriteLine("populateMetadata,");
154154
codeWriter.WriteLine($"createRequestDelegate);");
155155
codeWriter.Indent--;

src/Http/Http.Extensions/gen/RequestDelegateGeneratorSources.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ namespace Microsoft.AspNetCore.Http.Generated
542542
using System.Globalization;
543543
using System.Linq;
544544
using System.Reflection;
545+
using System.Runtime.CompilerServices;
545546
using System.Text.Json;
546547
using System.Text.Json.Serialization.Metadata;
547548
using System.Threading.Tasks;
@@ -564,11 +565,11 @@ namespace Microsoft.AspNetCore.Http.Generated
564565
{{GeneratedCodeAttribute}}
565566
file static class GeneratedRouteBuilderExtensionsCore
566567
{
567-
private static readonly string[] GetVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Get };
568-
private static readonly string[] PostVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Post };
569-
private static readonly string[] PutVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Put };
570-
private static readonly string[] DeleteVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Delete };
571-
private static readonly string[] PatchVerb = new[] { global::Microsoft.AspNetCore.Http.HttpMethods.Patch };
568+
private static readonly string[] GetVerb = new[] { Microsoft.AspNetCore.Http.HttpMethods.Get };
569+
private static readonly string[] PostVerb = new[] { Microsoft.AspNetCore.Http.HttpMethods.Post };
570+
private static readonly string[] PutVerb = new[] { Microsoft.AspNetCore.Http.HttpMethods.Put };
571+
private static readonly string[] DeleteVerb = new[] { Microsoft.AspNetCore.Http.HttpMethods.Delete };
572+
private static readonly string[] PatchVerb = new[] { Microsoft.AspNetCore.Http.HttpMethods.Patch };
572573
573574
{{endpoints}}
574575

src/Http/Http.Extensions/gen/StaticRouteHandler/Emitters/EmitterConstants.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace Microsoft.AspNetCore.Http.RequestDelegateGenerator.StaticRouteHandler.
77
internal static class EmitterConstants
88
{
99
public static SymbolDisplayFormat DisplayFormat => new SymbolDisplayFormat(
10-
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Included,
10+
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted,
1111
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
1212
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
1313
miscellaneousOptions: SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier);
1414

1515
public static SymbolDisplayFormat DisplayFormatWithoutNullability => new SymbolDisplayFormat(
16-
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Included,
16+
globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted,
1717
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
1818
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces);
1919
}

src/Http/Http.Extensions/gen/StaticRouteHandler/Model/Endpoint.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,12 @@ public Endpoint(IInvocationOperation operation, WellKnownTypes wellKnownTypes, S
9090
public string HttpMethod { get; }
9191
public bool IsAwaitable { get; set; }
9292
public bool NeedsParameterArray { get; }
93-
public string? RoutePattern { get; }
9493
public EmitterContext EmitterContext { get; }
9594
public EndpointResponse? Response { get; }
9695
public EndpointParameter[] Parameters { get; } = Array.Empty<EndpointParameter>();
9796
public List<Diagnostic> Diagnostics { get; } = new List<Diagnostic>();
9897

99-
public (string File, int LineNumber, int CharaceterNumber) Location { get; }
98+
public (string File, int LineNumber, int CharacterNumber) Location { get; }
10099
public IInvocationOperation Operation { get; }
101100

102101
public override bool Equals(object o) =>

0 commit comments

Comments
 (0)