Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,21 @@ Copyright (c) .NET Foundation. All rights reserved.
</AssemblyAttribute>
</ItemGroup>

<!-- We disable startup hooks for trimmed apps here so that the feature
switch can flow to the runtimeconfig.json. Startup hooks are disabled
by default since they may require assemblies, types or members that
could be removed by the linker, causing a trimmed app to crash. -->
<PropertyGroup Condition="'$(StartupHookSupport)' == '' And
'$(PublishTrimmed)' == 'true' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0'))">
<StartupHookSupport>false</StartupHookSupport>
</PropertyGroup>

<!-- We disable custom resource types for trimmed apps here so that the feature
switch can flow to the runtimeconfig.json. Custom resource types are disabled
by default since they may require assemblies, types or members that
could be removed by the linker, causing a trimmed app to crash. -->
<PropertyGroup Condition="'$(CustomResourceTypesSupport)' == '' And
'$(PublishTrimmed)' == 'true' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0'))">
<CustomResourceTypesSupport>false</CustomResourceTypesSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization)' == '' And
'$(PublishTrimmed)' == 'true' And
<!-- We disable features for trimmed apps here so that the feature
switches can flow to the runtimeconfig.json. Features are disabled
by default since they may require assemblies, types or members that
could be removed by the linker, causing a trimmed app to crash. -->
<PropertyGroup Condition="'$(PublishTrimmed)' == 'true' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0'))">
<EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>false</EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>
<StartupHookSupport Condition="'$(StartupHookSupport)' == ''">false</StartupHookSupport>
<CustomResourceTypesSupport Condition="'$(CustomResourceTypesSupport)' == ''">false</CustomResourceTypesSupport>
<EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization Condition="'$(EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization)' == ''">false</EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>
<BuiltInComInteropSupport Condition="'$(BuiltInComInteropSupport)' == ''">false</BuiltInComInteropSupport>
<EnableCppCLIHostActivation Condition="'$(EnableCppCLIHostActivation)' == ''">false</EnableCppCLIHostActivation>
<_EnableConsumingManagedCodeFromNativeHosting Condition="'$(_EnableConsumingManagedCodeFromNativeHosting)' == ''">false</_EnableConsumingManagedCodeFromNativeHosting>
</PropertyGroup>

<!-- We disable in-built COM support for trimmed apps here so that the feature
switch can flow to the runtimeconfig.json. Built-in COM support is disabled
by default since they may require assemblies, types or members that
could be removed by the linker, causing a trimmed app to crash. -->
<PropertyGroup Condition="'$(BuiltInComSupport)' == '' And
'$(PublishTrimmed)' == 'true' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0'))">
<BuiltInComSupport>false</BuiltInComSupport>
</PropertyGroup>

<PropertyGroup Condition="'$(SuppressTrimAnalysisWarnings)' == '' And ('$(EnableTrimAnalyzer)' == 'true' Or '$(PublishTrimmed)' == 'true')">
<!-- Trim analysis warnings are suppressed for .NET < 6. -->
<SuppressTrimAnalysisWarnings Condition="$([MSBuild]::VersionLessThan('$(TargetFrameworkVersion)', '6.0'))">true</SuppressTrimAnalysisWarnings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,6 @@ Copyright (c) .NET Foundation. All rights reserved.
-->

<ItemGroup>
<RuntimeHostConfigurationOption Include=" System.Runtime.InteropServices.Marshal.IsBuiltInComSupported"
Condition="'$(BuiltInComSupport)' != ''"
Value="$(BuiltInComSupport)"
Trim="true" />

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

<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.BuiltInComInterop.IsSupported"
Condition="'$(BuiltInComInteropSupport)' != ''"
Value="$(BuiltInComInteropSupport)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting"
Condition="'$(_EnableConsumingManagedCodeFromNativeHosting)' != ''"
Value="$(_EnableConsumingManagedCodeFromNativeHosting)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Runtime.InteropServices.EnableCppCLIHostActivation"
Condition="'$(EnableCppCLIHostActivation)' != ''"
Value="$(EnableCppCLIHostActivation)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization"
Condition="'$(EnableUnsafeBinaryFormatterSerialization)' != ''"
Value="$(EnableUnsafeBinaryFormatterSerialization)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,24 +682,32 @@ public void TrimmingOptions_are_defaulted_correctly_on_trimmed_apps(string targe
{
JObject runtimeConfig = JObject.Parse(runtimeConfigContents);
runtimeConfig["runtimeOptions"]["configProperties"]
["System.Runtime.InteropServices.Marshal.IsBuiltInComSupported"].Value<bool>()
["System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.StartupHookProvider.IsSupported"].Value<bool>()
["System.Resources.ResourceManager.AllowCustomResourceTypes"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.Resources.ResourceManager.AllowCustomResourceTypes"].Value<bool>()
["System.Runtime.InteropServices.BuiltInComInterop.IsSupported"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"].Value<bool>()
["System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.Runtime.InteropServices.EnableCppCLIHostActivation"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.StartupHookProvider.IsSupported"].Value<bool>()
.Should().BeFalse();
}
else
{
runtimeConfigContents.Should().NotContain("System.Runtime.InteropServices.Marshal.IsBuiltInComSupported");
runtimeConfigContents.Should().NotContain("System.StartupHookProvider.IsSupported");
runtimeConfigContents.Should().NotContain("System.Resources.ResourceManager.AllowCustomResourceTypes");
runtimeConfigContents.Should().NotContain("System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization");
runtimeConfigContents.Should().NotContain("System.Resources.ResourceManager.AllowCustomResourceTypes");
runtimeConfigContents.Should().NotContain("System.Runtime.InteropServices.BuiltInComInterop.IsSupported");
runtimeConfigContents.Should().NotContain("System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting");
runtimeConfigContents.Should().NotContain("System.Runtime.InteropServices.EnableCppCLIHostActivation");
runtimeConfigContents.Should().NotContain("System.StartupHookProvider.IsSupported");
}
}

Expand Down