Skip to content

Commit cf6b502

Browse files
authored
Improve generation and use of ref/ projects (#17311)
* Remove useless src/PackageArchive files - not used outside 2.x branches * Improve use of ref/ assemblies - compile against ref/ assemblies but do not change package metadata - update the metadata of implementation projects to include the ref/ assembly path - update `@(ReferenceAssembly)` metadata for Extensions packages, not `@(PackageReference)` - can be disabled using `$(CompileUsingReferenceAssemblies)` e.g. when generating ref/ projects - include ref/ projects in source build by default - remove `$(ExcludeFromSourceBuild)` overrides from ref/ project files - use latest package references and use project references even when _not_ building the targeting packs - restore previous `@(Reference)` -> `@(PackageReference)` logic - add build-only Microsoft.Internal.Extensions.Refs package reference in most cases - remove IndirectReferences.props and `@(_ExtensionInternalRefAssemblies)`; no longer needed * Improve ref/ project generation - use ../src/**/AssemblyInfo.cs files instead of including attributes in *.Manual.cs files - for same reason, copy `@(InternalsVisibleto)` items from src/ to ref/ projects - use eng/targets/CSharp.ReferenceAssembly.props instead of ref/Directory.Build.props files - use TFM-specific *.Manual.cs files in ref/ project files instead of ref/Directory.Build.props files optimizations and usability improvements: - add `$(BuildMainlyReferenceProviders)` property to focus on reference providers when generating ref/ projects - disable `$(UseReferenceAssemblyInImplementation)` to avoid using ref/ projects while generating them nits: - clean up whitespace and remove blank lines in ref/ project files * Perform smaller cleanup - remove `$(IsTargetingPackPatching)`; use only `$(IsTargetingPackBuilding)` - remove `$(DisableServicingFeatures)`; enable the servicing features we need - suppress baseline references even in servicing builds - restore `$(AdditionalGenApiCmdOptions)`; useful when updating *.Manual.cs files nits: - simplify conditions using `$(HasReferenceAssembly)` - correct spelling in comments - shorten long lines * Use a response file for GenAPI commands - work around dotnet/arcade#4021 and help with additional ref assemblies - mimic 111462e and integrate w/ other changes here * Undo some manual ref/ project changes - now done automatically or centrally - remove manual `[TypeForwardedTo]` and `[InternalsVisibleTo]` attributes - fully qualify a type now that `using` is gone - remove dupe `@(Compile)` items for *.Manual.cs files; included in the ref/ project files - remove redundant `$(AllowUnsafeBlocks)` and `$(NoWarn)` settings nits: - rename a *.Manual.cs file that's not TFM-specific - remove `private` members * Correct use of `@(ProjectReference)` items for reference providers - use `@(Reference)` instead * Remove recently-added `@(Compile)` and `@(Reference)` items - were added due to missing `[InternalsVisibleTo]` attributes in ref/ assemblies or as early workarounds - plus, now transitive references **Just Work:tm:** - expose `ClosedGenericMatcher` in the usual (*.Manual.cs) way - also undo Microsoft.Extensions.ApiDescription.Server workaround * Remove `private` members from ref/ *.Manual.cs files - not useful and bloat the ref/ assemblies * Cleanup warnings - avoid "CSC warning CS2008: No source files specified." building site extensions - correct warnings (as errors) about `RenderToStringResult` being obsolete - add Microsoft.AspNetCore.SpaServices.Tests to Middleware solution * Remove `@(RuntimeHostConfigurationOption)` workarounds - deps files are unaffected by new ref/ assembly handling and test projects aren't special-cased - also execute a test previously skipped due to deps file problems * Regenerate ref/ projects - pick up the latest generation changes (unclear why Mvc.RazorPages/ref/Microsoft.AspNetCore.Mvc.RazorPages.netcoreapp3.0.cs changed but works) * Fill in missing `internal` types 1 of n - rename Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs; need `RenderTreeFrame` type everywhere - add types needed in unit and perf tests to *.Manual.cs files * Clean up recent commits - remove recently-added `private` members - restore `_dummyPrimitive` fields in Microsoft.AspNetCore.Server.HttpSys.Manual.cs * Add *.Manual.cs files for more projects * !fixup! fields in *.Manual.cs `struct`s - GenAPI sometimes generates `_dummy` and `_dummyPrimitive` fields _instead of_ visible members - what GenAPI generates sometimes have the right length but actual fields don't hurt - that is, using the real fields corrects both the visible API and `struct`s' sizes nits: - consolidate `namespace`s in Microsoft.AspNetCore.Mvc.Core.Manual.cs * Remove special case for generating ref/ projects on non-Windows - referenced issue was closed with no action but workaround still not required - no tabs in generated content * Only create ref/ projects for assemblies in the shared framework - restrict when `$(HasReferenceAssembly)` is `true` by default - add warnings when `$(IsAspNetCoreApp)` or `$(HasReferenceAssembly)` have unexpected values * Remove "extra" ref/ projects - associated implementation projects no longer have `$(HasReferenceAssembly)` set to `true` * Add a few GenAPI exclusions - see dotnet/arcade#4488 - generation for these members leads to NREs * Add more `internal` types and members - Identity/Core - Identity/Extensions.Core - Mvc/Mvc.ViewFeatures * Add direct dependencies to work around CS1705 errors - add direct references to some test and sample projects to make intent clear i.e. address CS1705 root cause - these projects must use implementation assemblies for those direct references - requirement also applies to anything depending on them e.g. functional tests - for simplicity, use `$(CompileUsingReferenceAssemblies)` instead of targeted `@(Reference)` metadata - leads to ~40 projects that do not themselves add ref/ metadata - this is _not_ transitive i.e. it applies only to projects that override `$(CompileUsingReferenceAssemblies)` * nits: Remove a few more `private` members in *.Manual.cs files * !fixup! correct namespaces of a few types in *.Manual.cs files * Try another way to fix Microsoft.AspNetCore.Blazor.Build.Tests * Try another way to fix missing targets in Web.JS.npmproj
1 parent 9a4ab80 commit cf6b502

File tree

311 files changed

+9335
-18517
lines changed

Some content is hidden

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

311 files changed

+9335
-18517
lines changed

Directory.Build.props

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@
8484
<RuntimeInstallerBaseName>aspnetcore-runtime</RuntimeInstallerBaseName>
8585
<TargetingPackInstallerBaseName>aspnetcore-targeting-pack</TargetingPackInstallerBaseName>
8686

87-
<!-- 3.0.1 is a special servicing release since we're building the targeting pack. We need this condition in a few places. -->
88-
<IsTargetingPackPatching Condition="'$(VersionPrefix)' == '3.0.1'">true</IsTargetingPackPatching>
89-
90-
<!-- Used to only produce targeting pack installers/packages once per major.minor. -->
91-
<IsTargetingPackBuilding Condition="'$(AspNetCorePatchVersion)' != '0' OR '$(DotNetBuildFromSource)' == 'true'">false</IsTargetingPackBuilding>
92-
93-
<!-- We need to build the targeting pack in 3.0.1. We can remove this line from any branch other than release/3.0 -->
94-
<IsTargetingPackBuilding Condition="'$(IsTargetingPackPatching)' == 'true' AND '$(DotNetBuildFromSource)' != 'true'">true</IsTargetingPackBuilding>
87+
<!-- Produce targeting pack installers/packages once per major.minor except in extraordinary cases i.e. 3.0.1. -->
88+
<!-- We can remove the 3.0.1 line from any branch other than release/3.0 and from here after 3.0.1 is released. -->
89+
<IsTargetingPackBuilding Condition=" '$(DotNetBuildFromSource)' == 'true' ">false</IsTargetingPackBuilding>
90+
<IsTargetingPackBuilding
91+
Condition=" '$(IsTargetingPackBuilding)' == '' AND '$(VersionPrefix)' == '3.0.1' ">true</IsTargetingPackBuilding>
92+
<IsTargetingPackBuilding
93+
Condition=" '$(IsTargetingPackBuilding)' == '' AND '$(AspNetCorePatchVersion)' != '0' ">false</IsTargetingPackBuilding>
94+
<IsTargetingPackBuilding Condition=" '$(IsTargetingPackBuilding)' == '' ">true</IsTargetingPackBuilding>
9595

9696
<!--
9797
Archives and installers using this prefix are intended for internal-use only.

Directory.Build.targets

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
-->
1010
<IsPackable Condition="'$(IsAspNetCoreApp)' == 'true' AND '$(IsShippingPackage)' != 'true'">false</IsPackable>
1111

12-
<!-- Only build assemblies in Microsoft.AspNetCore.App in source build -->
12+
<!-- Only build Microsoft.AspNetCore.App and ref/ assemblies in source build. -->
1313
<!-- Analyzer package are needed in source build for WebSDK -->
14-
<ExcludeFromSourceBuild Condition="'$(ExcludeFromSourceBuild)' == '' and '$(DotNetBuildFromSource)' == 'true' and '$(IsAspNetCoreApp)' != 'true' and '$(IsAnalyzersProject)' != 'true'">true</ExcludeFromSourceBuild>
14+
<ExcludeFromSourceBuild
15+
Condition="'$(ExcludeFromSourceBuild)' == '' and '$(DotNetBuildFromSource)' == 'true' and '$(IsAspNetCoreApp)' != 'true' and '$(IsReferenceAssemblyProject)' != 'true' and '$(IsAnalyzersProject)' != 'true'">true</ExcludeFromSourceBuild>
1516
</PropertyGroup>
1617

1718
<PropertyGroup Label="Resx settings">
@@ -58,15 +59,11 @@
5859

5960
<Import Project="eng\Baseline.Designer.props" />
6061

61-
<PropertyGroup
62-
Condition=" '$(IsPackable)' != 'false' AND '$(AspNetCorePatchVersion)' != '0' AND '$(DisableServicingFeatures)' != 'true' ">
63-
<IsPackageInThisPatch Condition="'$(IsPackageInThisPatch)' == ''">true</IsPackageInThisPatch>
64-
</PropertyGroup>
65-
6662
<PropertyGroup Condition=" '$(IsPackable)' != 'false' AND '$(IsServicingBuild)' == 'true' ">
63+
<IsPackageInThisPatch Condition="'$(IsPackageInThisPatch)' == ''">true</IsPackageInThisPatch>
6764
<!-- Used to distinguish between packages building -->
6865
<IsPackableInNonServicingBuild>true</IsPackableInNonServicingBuild>
69-
<!-- Suppress creation of .nupkg for servicing builds. -->
66+
<!-- Suppress creation of .nupkg for servicing builds of non-shipping projects. -->
7067
<IsPackable Condition=" '$(IsPackageInThisPatch)' != 'true' ">false</IsPackable>
7168
</PropertyGroup>
7269

@@ -88,7 +85,7 @@
8885
<Version Condition="'$(NoBuild)' == 'true' AND '$(DesignTimeBuild)' == 'true'">$(BaselinePackageVersion)</Version>
8986
<PackageVersion Condition="'$(NoBuild)' == 'true' AND '$(DesignTimeBuild)' == 'true'">$(BaselinePackageVersion)</PackageVersion>
9087

91-
<!-- For servicing builds, we want to resolve basline versions of project packages that aren't building, always -->
88+
<!-- For servicing builds, we want to resolve baseline versions of project packages that aren't building, always -->
9289
<PackageVersionForPackageVersionInfo>$(BaselinePackageVersion)</PackageVersionForPackageVersionInfo>
9390
</PropertyGroup>
9491

@@ -99,7 +96,8 @@
9996
<!-- This determines whether a project is available as a <Reference> to other projects in this repo. -->
10097
<IsProjectReferenceProvider Condition=" '$(IsProjectReferenceProvider)' == '' AND '$(IsImplementationProject)' == 'true' AND '$(PackAsTool)' != 'true' ">true</IsProjectReferenceProvider>
10198

102-
<HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == '' AND '$(IsProjectReferenceProvider)' == 'true'">true</HasReferenceAssembly>
99+
<HasReferenceAssembly
100+
Condition=" '$(HasReferenceAssembly)' == '' AND '$(IsProjectReferenceProvider)' == 'true' AND '$(IsAspNetCoreApp)' == 'true' ">true</HasReferenceAssembly>
103101
<HasReferenceAssembly Condition="'$(HasReferenceAssembly)' == ''">false</HasReferenceAssembly>
104102

105103
<IsPackable Condition="'$(IsPackable)' == '' AND ('$(IsImplementationProject)' == 'true' OR '$(IsAnalyzersProject)' == 'true') ">true</IsPackable>
@@ -161,13 +159,12 @@
161159
</Target>
162160

163161
<Import Project="eng\Workarounds.targets" />
164-
<Import Project="eng\IndirectReferences.props" Condition="'$(IsTestProject)' == 'true' OR '$(IsTestAssetProject)' == 'true' OR '$(IsBenchmarkProject)' == 'true' OR '$(IsSampleProject)' == 'true'" />
165162
<Import Project="eng\targets\ResolveIisReferences.targets" Condition=" '$(MSBuildProjectExtension)' != '.vcxproj' " />
166163
<Import Project="eng\targets\Cpp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'" />
167164
<Import Project="eng\targets\CSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.csproj'" />
168165
<Import Project="eng\targets\FSharp.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.fsproj'" />
169166
<Import Project="eng\targets\Wix.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.wixproj'" />
170167
<Import Project="eng\targets\Npm.Common.targets" Condition="'$(MSBuildProjectExtension)' == '.npmproj'" />
171-
<Import Project="eng\targets\ReferenceAssembly.targets" Condition=" '$(HasReferenceAssembly)' == 'true' " />
168+
<Import Project="eng\targets\ReferenceAssembly.targets" Condition=" $(HasReferenceAssembly) " />
172169

173170
</Project>

eng/Build.props

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,35 @@
157157
@(ProjectToExclude);
158158
$(RepoRoot)**\node_modules\**\*;
159159
$(RepoRoot)**\bin\**\*;
160-
$(RepoRoot)**\obj\**\*;" />
160+
$(RepoRoot)**\obj\**\*;"
161+
Condition=" '$(BuildMainlyReferenceProviders)' != 'true' " />
162+
<DotNetProjects Include="
163+
$(RepoRoot)src\DefaultBuilder\**\src\*.csproj;
164+
$(RepoRoot)src\Features\JsonPatch\**\src\*.csproj;
165+
$(RepoRoot)src\DataProtection\**\src\*.csproj;
166+
$(RepoRoot)src\Antiforgery\**\src\*.csproj;
167+
$(RepoRoot)src\Hosting\**\src\*.csproj;
168+
$(RepoRoot)src\Http\**\src\*.csproj;
169+
$(RepoRoot)src\Html\**\src\*.csproj;
170+
$(RepoRoot)src\Identity\**\src\*.csproj;
171+
$(RepoRoot)src\Servers\**\src\*.csproj;
172+
$(RepoRoot)src\Security\**\src\*.csproj;
173+
$(RepoRoot)src\SiteExtensions\**\src\*.csproj;
174+
$(RepoRoot)src\Tools\**\src\*.csproj;
175+
$(RepoRoot)src\Middleware\**\src\*.csproj;
176+
$(RepoRoot)src\Razor\**\src\*.csproj;
177+
$(RepoRoot)src\Mvc\**\src\*.csproj;
178+
$(RepoRoot)src\Azure\**\src\*.csproj;
179+
$(RepoRoot)src\SignalR\**\src\*.csproj;
180+
$(RepoRoot)src\Components\**\src\*.csproj;
181+
"
182+
Exclude="
183+
@(ProjectToBuild);
184+
@(ProjectToExclude);
185+
$(RepoRoot)**\node_modules\**\*;
186+
$(RepoRoot)**\bin\**\*;
187+
$(RepoRoot)**\obj\**\*;"
188+
Condition=" '$(BuildMainlyReferenceProviders)' == 'true' " />
161189

162190
<ProjectToBuild Condition=" '$(BuildManaged)' == 'true'" Include="@(DotNetProjects)" Exclude="@(ProjectToExclude)" />
163191
<ProjectToExclude Condition=" '$(BuildManaged)' != 'true'" Include="@(DotNetProjects)" />

eng/CodeGen.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<BuildManaged>true</BuildManaged>
55
<RepoRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..'))</RepoRoot>
6+
<BuildMainlyReferenceProviders>true</BuildMainlyReferenceProviders>
67
</PropertyGroup>
78

89
<Import Project="Build.props" />
@@ -15,7 +16,6 @@
1516
BuildInParallel="true"
1617
SkipNonexistentTargets="true"
1718
SkipNonexistentProjects="true" >
18-
1919
<Output TaskParameter="TargetOutputs" ItemName="_ProjectReferenceProvider"/>
2020
</MSBuild>
2121

eng/GenAPI.exclusions.txt

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,48 @@ F:Microsoft.AspNetCore.Mvc.Razor.Infrastructure.TagHelperMemoryCacheProvider.{Ca
99
M:Microsoft.AspNetCore.Mvc.Razor.Infrastructure.TagHelperMemoryCacheProvider.#ctor
1010
P:Microsoft.AspNetCore.Mvc.Razor.Infrastructure.TagHelperMemoryCacheProvider.Cache
1111
M:Microsoft.AspNetCore.Mvc.Razor.Infrastructure.TagHelperMemoryCacheProvider.get_Cache
12-
M:Microsoft.AspNetCore.Mvc.Razor.Infrastructure.TagHelperMemoryCacheProvider.set_Cache(Microsoft.Extensions.Caching.Memory.IMemoryCache)
12+
M:Microsoft.AspNetCore.Mvc.Razor.Infrastructure.TagHelperMemoryCacheProvider.set_Cache(Microsoft.Extensions.Caching.Memory.IMemoryCache)
13+
# Manually implemented - Need to include internal setter
14+
P:Microsoft.AspNetCore.Routing.Matching.CandidateState.Values
15+
# Manually implemented - Need to include internal setter
16+
P:Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.KestrelServerOptions
17+
# Manually implemented - Need to include private fields in struct with sequential layout
18+
T:Microsoft.AspNetCore.Components.RenderHandle
19+
P:Microsoft.AspNetCore.Components.RenderHandle.Dispatcher
20+
P:Microsoft.AspNetCore.Components.RenderHandle.IsInitialized
21+
M:Microsoft.AspNetCore.Components.RenderHandle.get_Dispatcher
22+
M:Microsoft.AspNetCore.Components.RenderHandle.get_IsInitialized
23+
M:Microsoft.AspNetCore.Components.RenderHandle.Render(Microsoft.AspNetCore.Components.RenderFragment)
24+
T:Microsoft.AspNetCore.Components.ParameterView
25+
P:Microsoft.AspNetCore.Components.ParameterView.Empty
26+
M:Microsoft.AspNetCore.Components.ParameterView.FromDictionary(System.Collections.Generic.IDictionary{System.String,System.Object})
27+
M:Microsoft.AspNetCore.Components.ParameterView.GetEnumerator
28+
M:Microsoft.AspNetCore.Components.ParameterView.GetValueOrDefault``1(System.String)
29+
M:Microsoft.AspNetCore.Components.ParameterView.GetValueOrDefault``1(System.String,``0)
30+
M:Microsoft.AspNetCore.Components.ParameterView.get_Empty
31+
M:Microsoft.AspNetCore.Components.ParameterView.SetParameterProperties(System.Object)
32+
M:Microsoft.AspNetCore.Components.ParameterView.ToDictionary
33+
M:Microsoft.AspNetCore.Components.ParameterView.TryGetValue``1(System.String,``0@)
34+
T:Microsoft.AspNetCore.Components.ParameterView.Enumerator
35+
P:Microsoft.AspNetCore.Components.ParameterView.Enumerator.Current
36+
M:Microsoft.AspNetCore.Components.ParameterView.Enumerator.get_Current
37+
M:Microsoft.AspNetCore.Components.ParameterView.Enumerator.MoveNext
38+
T:Microsoft.AspNetCore.Components.EventCallback
39+
F:Microsoft.AspNetCore.Components.EventCallback.Empty
40+
F:Microsoft.AspNetCore.Components.EventCallback.Factory
41+
M:Microsoft.AspNetCore.Components.EventCallback.#ctor(Microsoft.AspNetCore.Components.IHandleEvent,System.MulticastDelegate)
42+
P:Microsoft.AspNetCore.Components.EventCallback.HasDelegate
43+
M:Microsoft.AspNetCore.Components.EventCallback.get_HasDelegate
44+
M:Microsoft.AspNetCore.Components.EventCallback.InvokeAsync(System.Object)
45+
T:Microsoft.AspNetCore.Components.EventCallback`1
46+
F:Microsoft.AspNetCore.Components.EventCallback`1.Empty
47+
M:Microsoft.AspNetCore.Components.EventCallback`1.#ctor(Microsoft.AspNetCore.Components.IHandleEvent,System.MulticastDelegate)
48+
P:Microsoft.AspNetCore.Components.EventCallback`1.HasDelegate
49+
M:Microsoft.AspNetCore.Components.EventCallback`1.get_HasDelegate
50+
M:Microsoft.AspNetCore.Components.EventCallback`1.InvokeAsync(`0)
51+
# Manually implemented - Need to include internal setter
52+
P:Microsoft.AspNetCore.Mvc.RazorPages.RazorPagesOptions.Conventions
53+
# Break GenAPI - https://github.com/dotnet/arcade/issues/4488
54+
T:Microsoft.AspNetCore.Mvc.ApplicationModels.ActionAttributeRouteModel.<GetAttributeRoutes>d__3
55+
T:Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.<CreateInitialRenderAsync>d__17
56+
T:Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.<RenderComponentAsync>d__8

0 commit comments

Comments
 (0)