Skip to content

Commit 5270dd8

Browse files
committed
Merge remote-tracking branch 'origin/main' into oroztocil/js-interop-extension2
2 parents 45260dd + 25a9b32 commit 5270dd8

17 files changed

+493
-114
lines changed

.azure/pipelines/jobs/default-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ jobs:
109109
vmImage: macOS-13
110110
${{ if eq(parameters.agentOs, 'Linux') }}:
111111
${{ if eq(parameters.useHostedUbuntu, true) }}:
112-
vmImage: ubuntu-20.04
112+
vmImage: ubuntu-22.04
113113
${{ else }}:
114114
name: $(DncEngPublicBuildPool)
115-
demands: ImageOverride -equals Build.Ubuntu.2004.Amd64.Open
115+
demands: ImageOverride -equals Build.Ubuntu.2204.Amd64.Open
116116
${{ if eq(parameters.agentOs, 'Windows') }}:
117117
name: $(DncEngPublicBuildPool)
118118
demands: ImageOverride -equals windows.vs2022preview.amd64.open
@@ -325,7 +325,7 @@ jobs:
325325
os: macOS
326326
${{ if eq(parameters.agentOs, 'Linux') }}:
327327
name: $(DncEngInternalBuildPool)
328-
image: 1es-ubuntu-2004
328+
image: 1es-ubuntu-2204
329329
os: linux
330330
${{ if eq(parameters.agentOs, 'Windows') }}:
331331
name: $(DncEngInternalBuildPool)

.azure/pipelines/richnav.yml

Lines changed: 0 additions & 84 deletions
This file was deleted.

NuGet.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
<add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
1212
<add key="dotnet8-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json" />
1313
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
14-
<!-- Used for the Rich Navigation indexing task -->
15-
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
1614
</packageSources>
1715
<disabledPackageSources>
1816
<clear />

eng/Signing.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@
9696
</_InstallersToPublish>
9797

9898
<Artifact Include="@(_InstallersToPublish)" Kind="Blob">
99-
<!-- Working around msbuild not being able to negate the result of Contains() outside of targets -->
100-
<IsShipping Condition="$([System.String]::Copy('%(Filename)').ToLowerInvariant().Contains('internal')) == 'True'">false</IsShipping>
101-
<IsShipping Condition="$([System.String]::Copy('%(Filename)').ToLowerInvariant().Contains('internal')) != 'True'">true</IsShipping>
99+
<IsShipping>true</IsShipping>
100+
<IsShipping Condition="$([System.String]::Copy('%(RecursiveDir)').StartsWith('NonShipping'))">false</IsShipping>
101+
<IsShipping Condition="$([System.String]::Copy('%(Identity)').ToLowerInvariant().Contains('wixpack.zip'))">false</IsShipping>
102102
</Artifact>
103103
</ItemGroup>
104104

eng/scripts/install-nginx-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ scriptroot="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
66
reporoot="$(dirname "$(dirname "$scriptroot")")"
77
nginxinstall="$reporoot/.tools/nginx"
88

9-
curl -sSL http://nginx.org/download/nginx-1.14.2.tar.gz --retry 5 | tar zxfv - -C /tmp && cd /tmp/nginx-1.14.2/
9+
curl -sSL http://nginx.org/download/nginx-1.26.3.tar.gz --retry 5 | tar zxfv - -C /tmp && cd /tmp/nginx-1.26.3/
1010
./configure --prefix=$nginxinstall --with-http_ssl_module --without-http_rewrite_module
1111
make
1212
make install

src/Http/Http.Extensions/gen/Microsoft.AspNetCore.Http.ValidationsGenerator/Parsers/ValidationsGenerator.AddValidation.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ internal bool FindAddValidation(SyntaxNode syntaxNode, CancellationToken cancell
2626
{
2727
var node = (InvocationExpressionSyntax)context.Node;
2828
var semanticModel = context.SemanticModel;
29+
var symbol = semanticModel.GetSymbolInfo(node, cancellationToken).Symbol;
30+
if (symbol is not IMethodSymbol methodSymbol
31+
|| methodSymbol.ContainingType.Name != "ValidationServiceCollectionExtensions"
32+
|| methodSymbol.ContainingAssembly.Name != "Microsoft.AspNetCore.Http.Abstractions")
33+
{
34+
return null;
35+
}
2936
return semanticModel.GetInterceptableLocation(node, cancellationToken);
3037
}
3138
}

src/Http/Http.Extensions/test/ValidationsGenerator/ValidationsGenerator.NoOp.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,70 @@ await VerifyEndpoint(compilation, "/complex-type", async (endpoint, serviceProvi
5151
});
5252
}
5353

54+
[Fact]
55+
public async Task DoesNotEmitIfNotCorrectAddValidationCallExists()
56+
{
57+
// Arrange
58+
var source = """
59+
using System;
60+
using System.ComponentModel.DataAnnotations;
61+
using System.Collections.Generic;
62+
using System.Threading.Tasks;
63+
using Microsoft.AspNetCore.Builder;
64+
using Microsoft.AspNetCore.Http;
65+
using Microsoft.AspNetCore.Http.Validation;
66+
using Microsoft.AspNetCore.Routing;
67+
using Microsoft.Extensions.DependencyInjection;
68+
69+
var builder = WebApplication.CreateBuilder();
70+
71+
builder.Services.AddValidation("example");
72+
SomeExtensions.AddValidation(builder.Services);
73+
74+
var app = builder.Build();
75+
76+
app.MapPost("/complex-type", (ComplexType complexType) => Results.Ok("Passed"));
77+
78+
app.Run();
79+
80+
public class ComplexType
81+
{
82+
[Range(10, 100)]
83+
public int IntegerWithRange { get; set; } = 10;
84+
}
85+
86+
public static class SomeExtensions
87+
{
88+
public static IServiceCollection AddValidation(this IServiceCollection services, string someString)
89+
{
90+
// This is not the correct AddValidation method
91+
return services;
92+
}
93+
94+
public static IServiceCollection AddValidation(this IServiceCollection services, Action<ValidationOptions>? configureOptions = null)
95+
{
96+
// This is not the correct AddValidation method
97+
return services;
98+
}
99+
}
100+
""";
101+
await Verify(source, out var compilation);
102+
// Verify that we don't validate types if no AddValidation call exists
103+
await VerifyEndpoint(compilation, "/complex-type", async (endpoint, serviceProvider) =>
104+
{
105+
var payload = """
106+
{
107+
"IntegerWithRange": 5
108+
}
109+
""";
110+
var context = CreateHttpContextWithPayload(payload, serviceProvider);
111+
112+
await endpoint.RequestDelegate(context);
113+
114+
Assert.Equal(StatusCodes.Status200OK, context.Response.StatusCode);
115+
});
116+
}
117+
54118
[Fact]
55119
public async Task DoesNotEmitForExemptTypes()
56120
{

src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<ItemGroup>
1414
<Reference Include="Microsoft.AspNetCore.TestHost" />
1515
<Reference Include="Microsoft.AspNetCore.Mvc.Core" />
16+
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
1617
<Reference Include="Microsoft.Extensions.DependencyModel" />
1718
<Reference Include="Microsoft.Extensions.Hosting" />
1819
<Reference Include="Microsoft.Extensions.HostFactoryResolver.Sources" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
#nullable enable
2+
Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TEntryPoint>.StartServer() -> void
3+
Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TEntryPoint>.UseKestrel() -> void
4+
Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TEntryPoint>.UseKestrel(int port) -> void
5+
Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TEntryPoint>.UseKestrel(System.Action<Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions!>! configureKestrelOptions) -> void

src/Mvc/Mvc.Testing/src/Resources.resx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -126,4 +126,13 @@
126126
<data name="MissingDepsFile" xml:space="preserve">
127127
<value>Can't find '{0}'. This file is required for functional tests to run properly. There should be a copy of the file on your source project bin folder. If that is not the case, make sure that the property PreserveCompilationContext is set to true on your project file. E.g '&lt;PreserveCompilationContext&gt;true&lt;/PreserveCompilationContext&gt;'. For functional tests to work they need to either run from the build output folder or the {1} file from your application's output directory must be copied to the folder where the tests are running on. A common cause for this error is having shadow copying enabled when the tests run.</value>
128128
</data>
129+
<data name="ServerNotInitialized" xml:space="preserve">
130+
<value>Server hasn't been initialized yet. Please initialize the server first before trying to create a client.</value>
131+
</data>
132+
<data name="TestServerNotSupportedWhenUsingKestrel" xml:space="preserve">
133+
<value>Accessing the `Server` property isn't supported when using Kestrel server.</value>
134+
</data>
135+
<data name="UseKestrelCanBeCalledBeforeInitialization" xml:space="preserve">
136+
<value>UseKestrel should be called before server initialization. Calling UseKestrel after the server was initialized will have no effect.</value>
137+
</data>
129138
</root>

0 commit comments

Comments
 (0)