Skip to content

Commit 207cb9e

Browse files
authored
Merge branch 'main' into darc-main-e4893e14-f6c2-4dae-a11b-2ff4d00b15c9
2 parents c900271 + 46312f3 commit 207cb9e

File tree

31 files changed

+1110
-268
lines changed

31 files changed

+1110
-268
lines changed

.azure/pipelines/localization.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,42 @@ parameters:
2525
variables:
2626
- name: _TeamName
2727
value: AspNetCore
28-
- template: /eng/common/templates/variables/pool-providers.yml
29-
30-
jobs:
31-
- ${{ if and(ne(variables['System.TeamProject'], 'public'), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'Manual'))) }}:
32-
- template: /eng/common/templates/job/onelocbuild.yml
33-
parameters:
34-
CreatePr: ${{ or(ne(variables['Build.Reason'], 'Manual'), eq(parameters.createPr, 'true')) }}
35-
LclPackageId: 'LCL-JUNO-PROD-ASPNETCORE'
36-
LclSource: lclFilesFromPackage
37-
MirrorRepo: aspnetcore
28+
- template: /eng/common/templates-official/variables/pool-providers.yml@self
29+
30+
31+
resources:
32+
repositories:
33+
# Repo: 1ESPipelineTemplates/1ESPipelineTemplates
34+
- repository: 1esPipelines
35+
type: git
36+
name: 1ESPipelineTemplates/1ESPipelineTemplates
37+
ref: refs/tags/release
38+
39+
extends:
40+
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
41+
parameters:
42+
sdl:
43+
sourceAnalysisPool:
44+
name: $(DncEngInternalBuildPool)
45+
image: 1es-windows-2022
46+
os: windows
47+
codeql:
48+
compiled:
49+
enabled: false
50+
justificationForDisabling: "This pipeline doesn't build any code. The product code is already scanned in the main pipeline (aspnetcore-ci)"
51+
pool:
52+
name: $(DncEngInternalBuildPool)
53+
image: 1es-windows-2022
54+
os: windows
55+
56+
stages:
57+
- stage: build
58+
displayName: Build
59+
jobs:
60+
- ${{ if and(ne(variables['System.TeamProject'], 'public'), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(variables['Build.Reason'], 'Manual'))) }}:
61+
- template: /eng/common/templates-official/job/onelocbuild.yml@self
62+
parameters:
63+
CreatePr: ${{ or(ne(variables['Build.Reason'], 'Manual'), eq(parameters.createPr, 'true')) }}
64+
LclPackageId: 'LCL-JUNO-PROD-ASPNETCORE'
65+
LclSource: lclFilesFromPackage
66+
MirrorRepo: aspnetcore

eng/Version.Details.xml

Lines changed: 146 additions & 146 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 75 additions & 75 deletions
Large diffs are not rendered by default.

src/Components/benchmarkapps/Wasm.Performance/dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN .dotnet/dotnet publish -c Release -r linux-x64 --sc true -o /app ./src/Compo
2929
RUN chmod +x /app/Wasm.Performance.Driver
3030

3131
WORKDIR /app
32-
FROM mcr.microsoft.com/playwright/dotnet:v1.49.0-jammy-amd64 AS final
32+
FROM mcr.microsoft.com/playwright/dotnet:v1.50.0-jammy-amd64 AS final
3333
COPY --from=build ./app ./
3434
COPY ./exec.sh ./
3535

src/Framework/AspNetCoreAnalyzers/src/SourceGenerators/PublicTopLevelProgramGenerator.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ public class PublicProgramSourceGenerator : IIncrementalGenerator
1212
{
1313
private const string PublicPartialProgramClassSource = """
1414
// <auto-generated />
15+
#pragma warning disable CS1591
1516
public partial class Program { }
17+
#pragma warning restore CS1591
1618
""";
1719

1820
public void Initialize(IncrementalGeneratorInitializationContext context)
@@ -21,17 +23,17 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
2123
// Get the entry point associated with the compilation, this maps to the Main method definition
2224
// Get the containing symbol of the entry point, this maps to the Program class
2325
compilation.GetEntryPoint(cancellationToken)?.ContainingSymbol is INamedTypeSymbol
24-
{
25-
// If the discovered `Program` type is not a class then its not
26-
// generated and has been defined in source, so we can skip it
27-
// If the program class is already public, we don't need to generate anything.
28-
DeclaredAccessibility: not Accessibility.Public,
29-
TypeKind: TypeKind.Class,
30-
// If there are multiple partial declarations, then do nothing since we don't want
31-
// to trample on visibility explicitly set by the user
32-
DeclaringSyntaxReferences: { Length: 1 } declaringSyntaxReferences
33-
} &&
34-
// If the `Program` class is already declared in user code, we don't need to generate anything.
26+
{
27+
// If the program class is already public, we don't need to generate anything
28+
DeclaredAccessibility: not Accessibility.Public,
29+
// If the discovered `Program` type is not a class then its not
30+
// generated and has been defined in source, so we can skip it
31+
TypeKind: TypeKind.Class,
32+
// If there are multiple partial declarations, then do nothing since we don't want
33+
// to trample on visibility explicitly set by the user
34+
DeclaringSyntaxReferences: { Length: 1 } declaringSyntaxReferences
35+
} &&
36+
// If the `Program` class is already declared in user code, we don't need to generate anything
3537
declaringSyntaxReferences.Single().GetSyntax(cancellationToken) is not ClassDeclarationSyntax
3638
);
3739

src/Framework/AspNetCoreAnalyzers/test/SourceGenerators/PublicTopLevelProgramGeneratorTests.cs

Lines changed: 109 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ namespace Microsoft.AspNetCore.SourceGenerators.Tests;
77

88
public class PublicTopLevelProgramGeneratorTests
99
{
10+
private const string ExpectedGeneratedSource = """
11+
// <auto-generated />
12+
#pragma warning disable CS1591
13+
public partial class Program { }
14+
#pragma warning restore CS1591
15+
""";
16+
1017
[Fact]
1118
public async Task GeneratesSource_ProgramWithTopLevelStatements()
1219
{
@@ -20,12 +27,33 @@ public async Task GeneratesSource_ProgramWithTopLevelStatements()
2027
app.Run();
2128
""";
2229

23-
var expected = """
24-
// <auto-generated />
25-
public partial class Program { }
30+
await VerifyCS.VerifyAsync(source, "PublicTopLevelProgram.Generated.g.cs", ExpectedGeneratedSource);
31+
}
32+
33+
// The compiler synthesizes a Program class in the global namespace due to top-level statements
34+
// The Foo.Program class is completely unrelated to the entry point and is just as any regular type
35+
// Hence, we will expect to see the source generated in these scenarios
36+
[Theory]
37+
[InlineData("public partial class Program { }")]
38+
[InlineData("internal partial class Program { }")]
39+
public async Task GeneratesSource_IfProgramDefinedInANamespace (string declaration)
40+
{
41+
var source = $$"""
42+
using Microsoft.AspNetCore.Builder;
43+
44+
var app = WebApplication.Create();
45+
46+
app.MapGet("/", () => "Hello, World!");
47+
48+
app.Run();
49+
50+
namespace Foo
51+
{
52+
{{declaration}}
53+
}
2654
""";
2755

28-
await VerifyCS.VerifyAsync(source, "PublicTopLevelProgram.Generated.g.cs", expected);
56+
await VerifyCS.VerifyAsync(source, "PublicTopLevelProgram.Generated.g.cs", ExpectedGeneratedSource);
2957
}
3058

3159
[Fact]
@@ -86,6 +114,31 @@ public static void Main()
86114
await VerifyCS.VerifyAsync(source);
87115
}
88116

117+
[Fact]
118+
public async Task DoesNotGeneratorSource_ExplicitPublicProgramClassInNamespace()
119+
{
120+
var source = """
121+
using Microsoft.AspNetCore.Builder;
122+
123+
namespace Foo
124+
{
125+
public class Program
126+
{
127+
public static void Main()
128+
{
129+
var app = WebApplication.Create();
130+
131+
app.MapGet("/", () => "Hello, World!");
132+
133+
app.Run();
134+
}
135+
}
136+
}
137+
""";
138+
139+
await VerifyCS.VerifyAsync(source);
140+
}
141+
89142
[Fact]
90143
public async Task DoesNotGeneratorSource_ExplicitInternalProgramClass()
91144
{
@@ -108,6 +161,31 @@ public static void Main()
108161
await VerifyCS.VerifyAsync(source);
109162
}
110163

164+
[Fact]
165+
public async Task DoesNotGeneratorSource_ExplicitInternalProgramClassInNamespace()
166+
{
167+
var source = """
168+
using Microsoft.AspNetCore.Builder;
169+
170+
namespace Foo
171+
{
172+
internal class Program
173+
{
174+
public static void Main()
175+
{
176+
var app = WebApplication.Create();
177+
178+
app.MapGet("/", () => "Hello, World!");
179+
180+
app.Run();
181+
}
182+
}
183+
}
184+
""";
185+
186+
await VerifyCS.VerifyAsync(source);
187+
}
188+
111189
[Theory]
112190
[InlineData("interface")]
113191
[InlineData("struct")]
@@ -127,6 +205,33 @@ public static void Main(string[] args)
127205
app.Run();
128206
}
129207
}
208+
""";
209+
210+
await VerifyCS.VerifyAsync(source);
211+
}
212+
213+
[Theory]
214+
[InlineData("interface")]
215+
[InlineData("struct")]
216+
public async Task DoesNotGeneratorSource_ExplicitInternalProgramTypeInNamespace(string type)
217+
{
218+
var source = $$"""
219+
using Microsoft.AspNetCore.Builder;
220+
221+
namespace Foo
222+
{
223+
internal {{type}} Program
224+
{
225+
public static void Main(string[] args)
226+
{
227+
var app = WebApplication.Create();
228+
229+
app.MapGet("/", () => "Hello, World!");
230+
231+
app.Run();
232+
}
233+
}
234+
}
130235
""";
131236

132237
await VerifyCS.VerifyAsync(source);

src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace Microsoft.AspNetCore.Hosting.Tests;
2222
public class HostingApplicationDiagnosticsTests : LoggedTest
2323
{
2424
[Fact]
25-
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/57259")]
2625
public async Task EventCountersAndMetricsValues()
2726
{
2827
// Arrange

src/Hosting/Hosting/test/Internal/HostingEventSourceTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ public void UnhandledException()
176176
}
177177

178178
[Fact]
179-
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/57259")]
180179
public async Task VerifyCountersFireWithCorrectValues()
181180
{
182181
// Arrange

src/Http/Http.Extensions/gen/Microsoft.AspNetCore.Http.RequestDelegateGenerator/StaticRouteHandlerModel/Emitters/EndpointParameterEmitter.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ internal static void EmitQueryOrHeaderParameterPreparation(this EndpointParamete
1818
{
1919
codeWriter.WriteLine(endpointParameter.EmitParameterDiagnosticComment());
2020

21-
var assigningCode = endpointParameter.Source is EndpointParameterSource.Header
22-
? $"httpContext.Request.Headers[\"{endpointParameter.LookupName}\"]"
23-
: $"httpContext.Request.Query[\"{endpointParameter.LookupName}\"]";
21+
var assigningCode = (endpointParameter.Source, endpointParameter.IsArray) switch
22+
{
23+
(EndpointParameterSource.Header, true) => $"httpContext.Request.Headers.GetCommaSeparatedValues(\"{endpointParameter.LookupName}\")",
24+
(EndpointParameterSource.Header, false) => $"httpContext.Request.Headers[\"{endpointParameter.LookupName}\"]",
25+
_ => $"httpContext.Request.Query[\"{endpointParameter.LookupName}\"]"
26+
};
2427
codeWriter.WriteLine($"var {endpointParameter.EmitAssigningCodeResult()} = {assigningCode};");
2528

2629
// If we are not optional, then at this point we can just assign the string value to the handler argument,

src/Http/Http.Extensions/src/RequestDelegateFactory.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public static partial class RequestDelegateFactory
5252
private static readonly MethodInfo ExecuteTaskResultOfTMethod = typeof(RequestDelegateFactory).GetMethod(nameof(ExecuteTaskResult), BindingFlags.NonPublic | BindingFlags.Static)!;
5353
private static readonly MethodInfo ExecuteValueResultTaskOfTMethod = typeof(RequestDelegateFactory).GetMethod(nameof(ExecuteValueTaskResult), BindingFlags.NonPublic | BindingFlags.Static)!;
5454
private static readonly MethodInfo ExecuteAwaitedReturnMethod = typeof(RequestDelegateFactory).GetMethod(nameof(ExecuteAwaitedReturn), BindingFlags.NonPublic | BindingFlags.Static)!;
55+
private static readonly MethodInfo GetHeaderSplitMethod = typeof(ParsingHelpers).GetMethod(nameof(ParsingHelpers.GetHeaderSplit), BindingFlags.Public | BindingFlags.Static, [typeof(IHeaderDictionary), typeof(string)])!;
5556
private static readonly MethodInfo GetRequiredServiceMethod = typeof(ServiceProviderServiceExtensions).GetMethod(nameof(ServiceProviderServiceExtensions.GetRequiredService), BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(IServiceProvider) })!;
5657
private static readonly MethodInfo GetServiceMethod = typeof(ServiceProviderServiceExtensions).GetMethod(nameof(ServiceProviderServiceExtensions.GetService), BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(IServiceProvider) })!;
5758
private static readonly MethodInfo GetRequiredKeyedServiceMethod = typeof(ServiceProviderKeyedServiceExtensions).GetMethod(nameof(ServiceProviderKeyedServiceExtensions.GetRequiredKeyedService), BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(IServiceProvider), typeof(object) })!;
@@ -1955,8 +1956,14 @@ private static Expression BindParameterFromExpression(
19551956
Expression.Convert(Expression.Constant(parameter.DefaultValue), parameter.ParameterType)));
19561957
}
19571958

1958-
private static Expression BindParameterFromProperty(ParameterInfo parameter, MemberExpression property, PropertyInfo itemProperty, string key, RequestDelegateFactoryContext factoryContext, string source) =>
1959-
BindParameterFromValue(parameter, GetValueFromProperty(property, itemProperty, key, GetExpressionType(parameter.ParameterType)), factoryContext, source);
1959+
private static Expression BindParameterFromProperty(ParameterInfo parameter, MemberExpression property, PropertyInfo itemProperty, string key, RequestDelegateFactoryContext factoryContext, string source)
1960+
{
1961+
var valueExpression = (source == "header" && parameter.ParameterType.IsArray)
1962+
? Expression.Call(GetHeaderSplitMethod, property, Expression.Constant(key))
1963+
: GetValueFromProperty(property, itemProperty, key, GetExpressionType(parameter.ParameterType));
1964+
1965+
return BindParameterFromValue(parameter, valueExpression, factoryContext, source);
1966+
}
19601967

19611968
private static Type? GetExpressionType(Type type) =>
19621969
type.IsArray ? typeof(string[]) :

0 commit comments

Comments
 (0)