Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -52,15 +52,37 @@ Copyright (c) .NET Foundation. All rights reserved.
<EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>false</EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>
</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
<!-- We disable in-built COM Interop support for trimmed apps here so that the feature
switch can flow to the runtimeconfig.json. Built-in COM Interop 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
<PropertyGroup Condition="'$(BuiltInComInteropSupport)' == '' And
'$(PublishTrimmed)' == 'true' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0'))">
<BuiltInComSupport>false</BuiltInComSupport>
</PropertyGroup>
<BuiltInComInteropSupport>false</BuiltInComInteropSupport>
</PropertyGroup>

<!-- We disable Native Host entry point support for IJW (C++/CLI Assemblies) for trimmed
apps here so that the feature switch can flow to the runtimeconfig.json.
Native Host entry point 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="'$(EnableCPlusPlusCLIHostActivation)' == '' And
'$(PublishTrimmed)' == 'true' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0'))">
<EnableCPlusPlusCLIHostActivation>false</EnableCPlusPlusCLIHostActivation>
</PropertyGroup>

<!-- We disable Native Host entry point support for loading managed components for trimmed
apps here so that the feature switch can flow to the runtimeconfig.json.
Native Host entry point 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="'$(_EnableCallingManagedFunctionFromNativeHosting)' == '' And
'$(PublishTrimmed)' == 'true' And
$([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '6.0'))">
<_EnableCallingManagedFunctionFromNativeHosting>false</_EnableCallingManagedFunctionFromNativeHosting>
</PropertyGroup>

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

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

<RuntimeHostConfigurationOption Include="Internal.Runtime.InteropServices.InMemoryAssemblyLoader.IsSupported"
Condition="'$(EnableCPlusPlusCLIHostActivation)' != ''"
Value="$(EnableCPlusPlusCLIHostActivation)"
Trim="true" />

<RuntimeHostConfigurationOption Include="System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"
Expand Down Expand Up @@ -416,6 +421,11 @@ 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.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>()
["Internal.Runtime.InteropServices.ComponentActivator.IsSupported"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.StartupHookProvider.IsSupported"].Value<bool>()
["Internal.Runtime.InteropServices.InMemoryAssemblyLoader.IsSupported"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.Resources.ResourceManager.AllowCustomResourceTypes"].Value<bool>()
.Should().BeFalse();
runtimeConfig["runtimeOptions"]["configProperties"]
["System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"].Value<bool>()
["System.Runtime.InteropServices.BuiltInComInterop.IsSupported"].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("Internal.Runtime.InteropServices.ComponentActivator.IsSupported");
runtimeConfigContents.Should().NotContain("Internal.Runtime.InteropServices.InMemoryAssemblyLoader.IsSupported");
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.StartupHookProvider.IsSupported");
}
}

Expand Down