Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SDK to support new DI and Attribute feature switches #19432

Merged
merged 1 commit into from
Jul 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Assets/TestProjects/KitchenSink/TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<!-- Host configuration properties
Keep this list in the same order as the configProperties in GivenThatWeWantToPublishAProjectWithAllFeatures. -->
<PropertyGroup>
<VerifyDependencyInjectionOpenGenericServiceTrimmability>true</VerifyDependencyInjectionOpenGenericServiceTrimmability>
<_AggressiveAttributeTrimming>true</_AggressiveAttributeTrimming>
<EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>false</EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>
<DebuggerSupport>true</DebuggerSupport>
<EventSourceSupport>false</EventSourceSupport>
Expand All @@ -20,6 +22,7 @@
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
<UseNativeHttpHandler>true</UseNativeHttpHandler>
<MetadataUpdaterSupport>false</MetadataUpdaterSupport>
<NullabilityInfoContextSupport>false</NullabilityInfoContextSupport>
<CustomResourceTypesSupport>false</CustomResourceTypesSupport>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<BuiltInComInteropSupport>false</BuiltInComInteropSupport>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<UseSystemResourceKeys Condition="'$(UseSystemResourceKeys)' == ''">true</UseSystemResourceKeys>
<EnableUnsafeUTF7Encoding Condition="'$(EnableUnsafeUTF7Encoding)' == ''">false</EnableUnsafeUTF7Encoding>
<HttpActivityPropagationSupport Condition="'$(HttpActivityPropagationSupport)' == ''">false</HttpActivityPropagationSupport>
<NullabilityInfoContextSupport Condition="'$(NullabilityInfoContextSupport)' == ''">false</NullabilityInfoContextSupport>
<_AggressiveAttributeTrimming Condition="'$(_AggressiveAttributeTrimming)' == ''">true</_AggressiveAttributeTrimming>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this "private" because we don't think it's ready for prime time?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. It is a bit dangerous removing all these attributes as some code could be reading them, and now behavior has changed. To mitigate this, we are making this setting "private" for Blazor WASM (and Maui if needed) to use to get as small as possible, but we don't expect other app models to use this.

With dotnet/runtime#56475, Blazor WASM devs who are broke by the attribute trimming can now turn it off to get unblocked, at the cost of a slightly larger app.

<DebuggerSupport Condition="'$(DebuggerSupport)' == '' and '$(Configuration)' != 'Debug'">false</DebuggerSupport>
<BlazorCacheBootResources Condition="'$(BlazorCacheBootResources)' == ''">true</BlazorCacheBootResources>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<AutoreleasePoolSupport Condition="'$(AutoreleasePoolSupport)' == ''">false</AutoreleasePoolSupport>
<EnableCppCLIHostActivation Condition="'$(EnableCppCLIHostActivation)' == ''">false</EnableCppCLIHostActivation>
<_EnableConsumingManagedCodeFromNativeHosting Condition="'$(_EnableConsumingManagedCodeFromNativeHosting)' == ''">false</_EnableConsumingManagedCodeFromNativeHosting>
<VerifyDependencyInjectionOpenGenericServiceTrimmability Condition="'$(VerifyDependencyInjectionOpenGenericServiceTrimmability)' == ''">true</VerifyDependencyInjectionOpenGenericServiceTrimmability>
</PropertyGroup>

<PropertyGroup Condition="'$(SuppressTrimAnalysisWarnings)' == '' And ('$(EnableTrimAnalyzer)' == 'true' Or '$(PublishTrimmed)' == 'true')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,16 @@ Copyright (c) .NET Foundation. All rights reserved.
-->

<ItemGroup>
<RuntimeHostConfigurationOption Include="Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability"
Condition="'$(VerifyDependencyInjectionOpenGenericServiceTrimmability)' != ''"
Value="$(VerifyDependencyInjectionOpenGenericServiceTrimmability)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.AggressiveAttributeTrimming"
Condition="'$(_AggressiveAttributeTrimming)' != ''"
Value="$(_AggressiveAttributeTrimming)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"
Condition="'$(EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization)' != ''"
Value="$(EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization)"
Expand Down Expand Up @@ -424,6 +434,11 @@ Copyright (c) .NET Foundation. All rights reserved.
Value="$(MetadataUpdaterSupport)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Reflection.NullabilityInfoContext.IsSupported"
Condition="'$(NullabilityInfoContextSupport)' != ''"
Value="$(NullabilityInfoContextSupport)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Resources.ResourceManager.AllowCustomResourceTypes"
Condition="'$(CustomResourceTypesSupport)' != ''"
Value="$(CustomResourceTypesSupport)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public void It_publishes_the_project_correctly(string targetFramework, string []
var baselineConfigJsonObject = JObject.Parse(@"{
""runtimeOptions"": {
""configProperties"": {
""Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability"": true,
""System.AggressiveAttributeTrimming"": true,
""System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"": false,
""System.Diagnostics.Debugger.IsSupported"": true,
""System.Diagnostics.Tracing.EventSource.IsSupported"": false,
Expand All @@ -78,6 +80,7 @@ public void It_publishes_the_project_correctly(string targetFramework, string []
""System.Net.Http.EnableActivityPropagation"": false,
""System.Net.Http.UseNativeHttpHandler"": true,
""System.Reflection.Metadata.MetadataUpdater.IsSupported"": false,
""System.Reflection.NullabilityInfoContext.IsSupported"": false,
""System.Resources.ResourceManager.AllowCustomResourceTypes"": false,
""System.Resources.UseSystemResourceKeys"": true,
""System.Runtime.InteropServices.BuiltInComInterop.IsSupported"": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ public void TrimmingOptions_are_defaulted_correctly_on_trimmed_apps(string targe
{
JObject runtimeConfig = JObject.Parse(runtimeConfigContents);
JToken configProperties = runtimeConfig["runtimeOptions"]["configProperties"];
configProperties["Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability"].Value<bool>()
.Should().BeTrue();
configProperties["System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"].Value<bool>()
.Should().BeFalse();
configProperties["System.Resources.ResourceManager.AllowCustomResourceTypes"].Value<bool>()
Expand All @@ -701,6 +703,7 @@ public void TrimmingOptions_are_defaulted_correctly_on_trimmed_apps(string targe
}
else
{
runtimeConfigContents.Should().NotContain("Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability");
runtimeConfigContents.Should().NotContain("System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization");
runtimeConfigContents.Should().NotContain("System.Resources.ResourceManager.AllowCustomResourceTypes");
runtimeConfigContents.Should().NotContain("System.Runtime.InteropServices.BuiltInComInterop.IsSupported");
Expand Down