Skip to content

Commit 9ae3243

Browse files
authored
Add RuntimeHostConfigurationOption for COM descriptor support (#40106)
Adds SDK logic for the feature switch System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported. Tests that the switch is disabled by default in trimmed apps.
1 parent c65d21c commit 9ae3243

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

src/Assets/TestProjects/KitchenSink/TestApp/TestApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<VerifyDependencyInjectionOpenGenericServiceTrimmability>true</VerifyDependencyInjectionOpenGenericServiceTrimmability>
1313
<_AggressiveAttributeTrimming>true</_AggressiveAttributeTrimming>
1414
<EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>false</EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization>
15+
<_ComObjectDescriptorSupport>false</_ComObjectDescriptorSupport>
1516
<DebuggerSupport>true</DebuggerSupport>
1617
<EventSourceSupport>false</EventSourceSupport>
1718
<MetricsSupport>false</MetricsSupport>

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,11 @@ Copyright (c) .NET Foundation. All rights reserved.
499499
Value="$(EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization)"
500500
Trim="true" />
501501

502+
<RuntimeHostConfigurationOption Include="System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported"
503+
Condition="'$(_ComObjectDescriptorSupport)' != ''"
504+
Value="$(_ComObjectDescriptorSupport)"
505+
Trim="true" />
506+
502507
<RuntimeHostConfigurationOption Include="System.Diagnostics.Debugger.IsSupported"
503508
Condition="'$(DebuggerSupport)' != ''"
504509
Value="$(DebuggerSupport)"

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishAProjectWithAllFeatures.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void It_publishes_the_project_correctly(string targetFramework, string[]
5959
""Microsoft.Extensions.DependencyInjection.VerifyOpenGenericServiceTrimmability"": true,
6060
""System.AggressiveAttributeTrimming"": true,
6161
""System.ComponentModel.TypeConverter.EnableUnsafeBinaryFormatterInDesigntimeLicenseContextSerialization"": false,
62+
""System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported"": false,
6263
""System.Diagnostics.Debugger.IsSupported"": true,
6364
""System.Diagnostics.Metrics.Meter.IsSupported"": false,
6465
""System.Diagnostics.Tracing.EventSource.IsSupported"": false,

test/Microsoft.NET.Publish.Tests/GivenThatWeWantToRunILLink.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,12 @@ public void TrimmingOptions_are_defaulted_correctly_on_trimmed_apps(string targe
10441044
configProperties["System.Text.Json.JsonSerializer.IsReflectionEnabledByDefault"].Value<bool>()
10451045
.Should().BeFalse();
10461046
}
1047+
1048+
if (parsedVersion.Major >= 9)
1049+
{
1050+
configProperties["System.ComponentModel.TypeDescriptor.IsComObjectDescriptorSupported"].Value<bool>()
1051+
.Should().BeFalse();
1052+
}
10471053
}
10481054
else
10491055
{

0 commit comments

Comments
 (0)