Skip to content

Commit b4b43e3

Browse files
authored
Add gRPC JSON transcoding (#40242)
1 parent 8b742dc commit b4b43e3

File tree

184 files changed

+13831
-78
lines changed

Some content is hidden

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

184 files changed

+13831
-78
lines changed

AspNetCore.sln

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

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
<Import Project="artifacts\bin\GenerateFiles\Directory.Build.props" Condition=" '$(MSBuildProjectName)' != 'GenerateFiles' " />
240240
<Import Project="eng\Dependencies.props" />
241241
<Import Project="eng\ProjectReferences.props" />
242+
<Import Project="eng\RequiresDelayedBuildProjects.props" />
242243
<Import Project="eng\SharedFramework.Local.props" />
243244
<Import Project="eng\SharedFramework.External.props" />
244245
<Import Project="eng\targets\Cpp.Common.props" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'" />

eng/Build.props

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
<Project>
22
<Import Project="Common.props" />
33

4+
<!--
5+
@(RequiresDelayedBuild) projects can be extended many ways but this isn't fully automated because the new
6+
projects likely aren't referenced initially. To add new projects, edit RequiresDelayedBuildProjects.props
7+
manually, update the $(BuildMainlyReferenceProviders)' == 'true' item group near the bottom of this file,
8+
or edit BuildAfterTargetingPack.csproj. Then run GenerateProjectList.ps1 (even for the first option to ensure
9+
the format is correct) and undo any temporary changes. When complete, only BuildAfterTargetingPack.csproj and
10+
other @(RequiresDelayedBuild) projects should mention projects listed in RequiresDelayedBuildProjects.props.
11+
-->
12+
<Import Project="RequiresDelayedBuildProjects.props" />
13+
414
<!-- These projects are always excluded, even when -projects is specified on command line. -->
515
<ItemGroup>
616
<!-- Explicitly excluded projects -->
@@ -16,8 +26,11 @@
1626
<!-- Exclude the websockets samples for now because they use classic .csproj, which is not yet supported in our build. -->
1727
<ProjectToExclude Include="$(RepoRoot)src\Middleware\WebSockets\samples\**\*.csproj" />
1828

19-
<!-- These projects are meant to be referenced only by tests. -->
20-
<ProjectToExclude Include="$(RepoRoot)src\**\testassets\**\*.*proj"
29+
<!-- These projects are meant to be referenced only by tests or via BuildAfterTargetingPack.csproj. -->
30+
<ProjectToExclude
31+
Include="$(RepoRoot)src\**\testassets\**\*.*proj;
32+
@(RequiresDelayedBuild);
33+
"
2134
Exclude="$(RepoRoot)src\Components\WebAssembly\testassets\WasmLinkerTest\*.*proj;
2235
$(RepoRoot)src\Components\WebView\Samples\PhotinoPlatform\testassets\PhotinoTestApp\*.*proj;
2336
$(RepoRoot)src\Http\Routing\test\testassets\RoutingSandbox\*.*proj;
@@ -190,6 +203,7 @@
190203
$(RepoRoot)src\ProjectTemplates\*\*.csproj;
191204
$(RepoRoot)src\submodules\spa-templates\src\*.csproj;
192205
$(RepoRoot)src\Extensions\**\*.csproj;
206+
$(RepoRoot)src\BuildAfterTargetingPack\*.csproj;
193207
"
194208
Exclude="
195209
@(ProjectToBuild);
@@ -229,6 +243,7 @@
229243
$(RepoRoot)src\HealthChecks\**\src\*.csproj;
230244
$(RepoRoot)src\Testing\**\src\*.csproj;
231245
$(RepoRoot)src\Extensions\**\src\*.csproj;
246+
$(RepoRoot)src\BuildAfterTargetingPack\*.csproj;
232247
"
233248
Exclude="
234249
@(ProjectToBuild);

eng/CodeGen.proj

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<Project>
2-
32
<PropertyGroup>
43
<BuildManaged>true</BuildManaged>
54
<RepoRoot
@@ -17,13 +16,15 @@
1716
BuildInParallel="true"
1817
SkipNonexistentTargets="true"
1918
SkipNonexistentProjects="true">
20-
<Output TaskParameter="TargetOutputs" ItemName="_ProjectReferenceProvider" />
19+
<Output TaskParameter="TargetOutputs" ItemName="_ProvidesReferenceOrRequiresDelay" />
2120
</MSBuild>
2221

2322
<ItemGroup>
24-
<_SharedFrameworkAndPackageRef Include="@(_ProjectReferenceProvider->WithMetadataValue('IsAspNetCoreApp','true')->WithMetadataValue('IsPackable', 'true')->Distinct())" />
25-
<_SharedFrameworkRef Include="@(_ProjectReferenceProvider->WithMetadataValue('IsAspNetCoreApp','true')->WithMetadataValue('IsPackable', 'false')->Distinct())" />
26-
<_TrimmableProject Include="@(_ProjectReferenceProvider->WithMetadataValue('Trimmable', 'true')->Distinct())" />
23+
<_ProjectReferenceProvider Include="@(_ProvidesReferenceOrRequiresDelay->WithMetadataValue('IsProjectReferenceProvider','true')->Distinct())" />
24+
<_RequiresDelayedBuild Include="@(_ProvidesReferenceOrRequiresDelay->WithMetadataValue('RequiresDelayedBuild','true')->Distinct())" />
25+
<_SharedFrameworkAndPackageRef Include="@(_ProjectReferenceProvider->WithMetadataValue('IsAspNetCoreApp','true')->WithMetadataValue('IsPackable', 'true'))" />
26+
<_SharedFrameworkRef Include="@(_ProjectReferenceProvider->WithMetadataValue('IsAspNetCoreApp','true')->WithMetadataValue('IsPackable', 'false'))" />
27+
<_TrimmableProject Include="@(_ProjectReferenceProvider->WithMetadataValue('Trimmable', 'true'))" />
2728
</ItemGroup>
2829

2930
<PropertyGroup>
@@ -57,7 +58,7 @@
5758
5859
This file contains a complete list of the assemblies which are part of the shared framework.
5960
60-
This project is generated using the <IsAspNetCoreApp> and <IsPackable> properties from each .csproj in this repository.
61+
This file is generated using the <IsAspNetCoreApp/> and <IsPackable/> properties from each .csproj in this repository.
6162
-->
6263
<Project>
6364
<ItemGroup>
@@ -97,6 +98,30 @@
9798

9899
<WriteLinesToFile File="$(TrimmableProjectsList)" Lines="$(TrimmableProjectsListContent)" Overwrite="true" />
99100
<Message Importance="High" Text="Generated $(TrimmableProjectsList)" />
100-
</Target>
101101

102+
<PropertyGroup>
103+
<DelayedBuildFile>$(MSBuildThisFileDirectory)RequiresDelayedBuildProjects.props</DelayedBuildFile>
104+
<DelayedBuildContent><![CDATA[<!--
105+
This file is automatically generated. Run `./eng/scripts/GenerateProjectList.ps1` to update.
106+
107+
This file contains a list of projects that must be restored etc. after App.Ref and App.Runtime are fully built.
108+
109+
This file is generated using <RequiresDelayedBuild/> properties. Content may overlap ProjectReferences.csproj
110+
but that is not required (projects that are not project reference providers are also supported).
111+
-->
112+
<Project>
113+
<ItemGroup>
114+
@(_RequiresDelayedBuild->'<RequiresDelayedBuild Include="%24(RepoRoot)%(ProjectFileRelativePath)" />', '%0A ')
115+
</ItemGroup>
116+
</Project>
117+
]]></DelayedBuildContent>
118+
</PropertyGroup>
119+
120+
<!-- Workaround https://github.com/Microsoft/msbuild/issues/1024 -->
121+
<WriteLinesToFile Condition="'$(OS)' == 'Windows_NT'"
122+
File="$(DelayedBuildFile)" Lines="$([MSBuild]::Escape($(DelayedBuildContent)))" Overwrite="true" />
123+
<Exec Condition="'$(OS)' != 'Windows_NT'"
124+
Command="echo '$(DelayedBuildContent.Replace('\t','\\t'))' > $(DelayedBuildFile)" />
125+
<Message Importance="High" Text="Generated $(DelayedBuildFile)" />
126+
</Target>
102127
</Project>

eng/Dependencies.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ and are generated based on the last package release.
178178
<LatestPackageReference Include="Duende.IdentityServer.EntityFramework.Storage" />
179179
<LatestPackageReference Include="Duende.IdentityServer.Storage" />
180180
<LatestPackageReference Include="FSharp.Core" />
181+
<LatestPackageReference Include="Google.Api.CommonProtos" />
181182
<LatestPackageReference Include="Google.Protobuf" />
182183
<LatestPackageReference Include="Grpc.AspNetCore" />
184+
<LatestPackageReference Include="Grpc.AspNetCore.Server" />
183185
<LatestPackageReference Include="Grpc.Auth" />
184186
<LatestPackageReference Include="Grpc.Net.Client" />
185187
<LatestPackageReference Include="Grpc.Tools" />
@@ -202,6 +204,7 @@ and are generated based on the last package release.
202204
<LatestPackageReference Include="Serilog.Extensions.Logging" />
203205
<LatestPackageReference Include="Serilog.Sinks.File" />
204206
<LatestPackageReference Include="StackExchange.Redis" />
207+
<LatestPackageReference Include="Swashbuckle.AspNetCore" />
205208
<LatestPackageReference Include="System.Reactive.Linq" />
206209
<LatestPackageReference Include="xunit.abstractions" />
207210
<LatestPackageReference Include="xunit.analyzers" />

eng/ProjectReferences.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,7 @@
157157
<ProjectReferenceProvider Include="Microsoft.Extensions.Diagnostics.HealthChecks" ProjectPath="$(RepoRoot)src\HealthChecks\HealthChecks\src\Microsoft.Extensions.Diagnostics.HealthChecks.csproj" />
158158
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Testing" ProjectPath="$(RepoRoot)src\Testing\src\Microsoft.AspNetCore.Testing.csproj" />
159159
<ProjectReferenceProvider Include="Microsoft.Extensions.Features" ProjectPath="$(RepoRoot)src\Extensions\Features\src\Microsoft.Extensions.Features.csproj" />
160+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Grpc.JsonTranscoding" ProjectPath="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.JsonTranscoding\Microsoft.AspNetCore.Grpc.JsonTranscoding.csproj" />
161+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Grpc.Swagger" ProjectPath="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.Swagger\Microsoft.AspNetCore.Grpc.Swagger.csproj" />
160162
</ItemGroup>
161163
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
This file is automatically generated. Run `./eng/scripts/GenerateProjectList.ps1` to update.
3+
4+
This file contains a list of projects that must be restored etc. after App.Ref and App.Runtime are fully built.
5+
6+
This file is generated using <RequiresDelayedBuild/> properties. Content may overlap ProjectReferences.csproj
7+
but that is not required (projects that are not project reference providers are also supported).
8+
-->
9+
<Project>
10+
<ItemGroup>
11+
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\perf\Microsoft.AspNetCore.Grpc.Microbenchmarks\Microsoft.AspNetCore.Grpc.Microbenchmarks.csproj" />
12+
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.JsonTranscoding\Microsoft.AspNetCore.Grpc.JsonTranscoding.csproj" />
13+
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.Swagger\Microsoft.AspNetCore.Grpc.Swagger.csproj" />
14+
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\Microsoft.AspNetCore.Grpc.JsonTranscoding.IntegrationTests\Microsoft.AspNetCore.Grpc.JsonTranscoding.IntegrationTests.csproj" />
15+
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests\Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests.csproj" />
16+
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\Microsoft.AspNetCore.Grpc.Swagger.Tests\Microsoft.AspNetCore.Grpc.Swagger.Tests.csproj" />
17+
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\testassets\IntegrationTestsWebsite\IntegrationTestsWebsite.csproj" />
18+
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\testassets\Sandbox\Sandbox.csproj" />
19+
</ItemGroup>
20+
</Project>

eng/SharedFramework.Local.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
This file contains a complete list of the assemblies which are part of the shared framework.
55
6-
This project is generated using the <IsAspNetCoreApp> and <IsPackable> properties from each .csproj in this repository.
6+
This file is generated using the <IsAspNetCoreApp/> and <IsPackable/> properties from each .csproj in this repository.
77
-->
88
<Project>
99
<ItemGroup>

eng/Versions.props

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,13 @@
238238
<CastleCoreVersion>4.2.1</CastleCoreVersion>
239239
<CommandLineParserVersion>2.3.0</CommandLineParserVersion>
240240
<FSharpCoreVersion>6.0.0</FSharpCoreVersion>
241-
<GoogleProtobufVersion>3.18.0</GoogleProtobufVersion>
242-
<GrpcAspNetCoreVersion>2.40.0</GrpcAspNetCoreVersion>
243-
<GrpcAuthVersion>2.40.0</GrpcAuthVersion>
244-
<GrpcNetClientVersion>2.40.0</GrpcNetClientVersion>
245-
<GrpcToolsVersion>2.40.0</GrpcToolsVersion>
241+
<GoogleApiCommonProtosVersion>2.5.0</GoogleApiCommonProtosVersion>
242+
<GoogleProtobufVersion>3.18.1</GoogleProtobufVersion>
243+
<GrpcAspNetCoreVersion>2.43.0</GrpcAspNetCoreVersion>
244+
<GrpcAspNetCoreServerVersion>2.43.0</GrpcAspNetCoreServerVersion>
245+
<GrpcAuthVersion>2.43.0</GrpcAuthVersion>
246+
<GrpcNetClientVersion>2.43.0</GrpcNetClientVersion>
247+
<GrpcToolsVersion>2.43.0</GrpcToolsVersion>
246248
<DuendeIdentityServerAspNetIdentityVersion>5.2.0</DuendeIdentityServerAspNetIdentityVersion>
247249
<DuendeIdentityServerEntityFrameworkVersion>5.2.0</DuendeIdentityServerEntityFrameworkVersion>
248250
<DuendeIdentityServerVersion>5.2.0</DuendeIdentityServerVersion>

eng/targets/ResolveReferences.targets

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,18 @@
311311
<Warning Condition=" '$(IsProjectReferenceProvider)' == 'true' AND '$(AssemblyName)' != '$(MSBuildProjectName)' "
312312
Text="Project name &quot;$(MSBuildProjectName)&quot; is confusing; assembly is named &quot;$(AssemblyName)&quot;." />
313313

314-
<ItemGroup Condition=" '$(IsProjectReferenceProvider)' == 'true' ">
314+
<ItemGroup Condition=" '$(IsProjectReferenceProvider)' == 'true' OR '$(RequiresDelayedBuild)' == 'true' ">
315315
<ProvidesReference Include="$(AssemblyName)">
316316
<IsAspNetCoreApp>$([MSBuild]::ValueOrDefault($(IsAspNetCoreApp),'false'))</IsAspNetCoreApp>
317317
<IsPackable>$([MSBuild]::ValueOrDefault($(IsPackable),'false'))</IsPackable>
318318
<ProjectFileRelativePath>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectFullPath)))</ProjectFileRelativePath>
319319
<Trimmable>$([MSBuild]::ValueOrDefault($(Trimmable),'false'))</Trimmable>
320+
321+
<!-- True if the project may be referenced using a @(Reference) item. -->
322+
<IsProjectReferenceProvider>$([MSBuild]::ValueOrDefault($(IsProjectReferenceProvider),'false'))</IsProjectReferenceProvider>
323+
324+
<!-- True if project must be restored etc. after App.Ref and App.Runtime are fully built. -->
325+
<RequiresDelayedBuild>$([MSBuild]::ValueOrDefault($(RequiresDelayedBuild),'false'))</RequiresDelayedBuild>
320326
</ProvidesReference>
321327
</ItemGroup>
322328
</Target>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<Project>
2+
<!-- Fake a unit test project unless that would prevent building this project. -->
3+
<PropertyGroup>
4+
<IsUnitTestProject Condition=" '$(SkipTestBuild)' != 'true' ">true</IsUnitTestProject>
5+
</PropertyGroup>
6+
7+
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
8+
9+
<!--
10+
Forward targets to @(RequiresDelayedBuild) projects after App.Ref has built. Intended for projects that
11+
cannot restore without our App.Ref layout and aren't referenced elsewhere in the repo. For projects
12+
referenced elsewhere, use something else e.g. @(TestAssetProjectReference) items and
13+
FunctionalTestWithAssets.targets for test asset projects that need special handling.
14+
-->
15+
<PropertyGroup>
16+
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
17+
18+
<!-- Nothing from this project ships whether we're faking a unit test project or not. -->
19+
<IsShipping>false</IsShipping>
20+
21+
<!-- Build.props is main thing that references this project. -->
22+
<IsProjectReferenceProvider>false</IsProjectReferenceProvider>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<!--
27+
When adding new projects to @(RequiresDelayedBuild), temporarily reference the projects here, run
28+
GenerateProjectList.ps1, then undo changes in this file. See comments in Build.props for other options.
29+
-->
30+
<!-- RequiresDelayedBuild Include="..." / -->
31+
32+
<!-- Enforce build order. Need shared Fx before building the important projects. -->
33+
<ProjectReference Include="$(RepoRoot)\src\Framework\App.Ref\src\Microsoft.AspNetCore.App.Ref.csproj"
34+
Private="false"
35+
ReferenceOutputAssembly="false"
36+
SkipGetTargetFrameworkProperties="true" />
37+
</ItemGroup>
38+
39+
<!-- Cannot build in source-build because that does not create an App.Ref layout. -->
40+
<Target Name="BuildDelayedProjects"
41+
BeforeTargets="Build"
42+
Condition=" '$(DotNetBuildFromSource)' != 'true' "
43+
Returns="@(TargetPathWithTargetPlatformMoniker)">
44+
<MSBuild Projects="@(RequiresDelayedBuild)"
45+
BuildInParallel="$(BuildInParallel)"
46+
Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
47+
Targets="Restore" />
48+
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Build">
49+
<Output TaskParameter="TargetOutputs" ItemName="TargetPathWithTargetPlatformMoniker" />
50+
</MSBuild>
51+
</Target>
52+
53+
<Target Name="CleanDelayedProjects" BeforeTargets="Clean" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
54+
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Clean" />
55+
</Target>
56+
57+
<Target Name="CreateHelixPayloadDelayedProjects"
58+
BeforeTargets="CreateHelixPayload"
59+
Condition=" '$(DotNetBuildFromSource)' != 'true' "
60+
Returns="@(HelixWorkItem)">
61+
<MSBuild Projects="@(RequiresDelayedBuild)"
62+
BuildInParallel="$(BuildInParallel)"
63+
SkipNonexistentTargets="true"
64+
Targets="CreateHelixPayload">
65+
<Output TaskParameter="TargetOutputs" ItemName="HelixWorkItem" />
66+
</MSBuild>
67+
</Target>
68+
69+
<Target Name="GetReferencesProvidedDelayedProjects"
70+
BeforeTargets="GetReferencesProvided"
71+
Returns="@(ProvidesReference)">
72+
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="GetReferencesProvided">
73+
<Output TaskParameter="TargetOutputs" ItemName="ProvidesReference" />
74+
</MSBuild>
75+
</Target>
76+
77+
<Target Name="PackDelayedProjects" BeforeTargets="Pack" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
78+
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Pack" />
79+
</Target>
80+
81+
<Target Name="PublishDelayedProjects" BeforeTargets="Publish" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
82+
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Publish" />
83+
</Target>
84+
85+
<Target Name="TestDelayedProjects" BeforeTargets="Test" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
86+
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Test" />
87+
</Target>
88+
89+
<Target Name="VSTestDelayedProjects" BeforeTargets="VSTest" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
90+
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="VSTest" />
91+
</Target>
92+
93+
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
94+
</Project>

0 commit comments

Comments
 (0)