Skip to content

Conversation

@eerhardt
Copy link
Member

@eerhardt eerhardt commented Jul 6, 2020

Adds 3 runtimeconfig.json options introduced in .NET 5 that allow for code to be trimmed out of an application.

  • EventSource.IsSupported
  • UseSystemResourceKeys
  • EnableUnsafeUTF7Encoding

Also fixing InvariantGlobalization so it is passed to the linker correctly.

Contributes to #12217

Adds 3 runtimeconfig.json options introduced in .NET 5 that allow for code to be trimmed out of an application.

* EventSource.IsSupported
* UseSystemResourceKeys
* EnableUnsafeUTF7Encoding

Also fixing InvariantGlobalization so it is passed to the linker correctly.

Contributes to dotnet#12217
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<TieredCompilationQuickJitForLoops>true</TieredCompilationQuickJitForLoops>
<EventSourceSupport>false</EventSourceSupport>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
Copy link
Member

Choose a reason for hiding this comment

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

Some minor comment not directly from your PR is do we want to add some common prefix/sufix to these properties so that it is a bit obvious they are related and about the linker?

Copy link
Member Author

Choose a reason for hiding this comment

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

so that it is a bit obvious they are related and about the linker?

These options are not just about the linker - just like the $(InvariantGlobalization) property. These properties control runtime behavior. Setting these properties in any .NET 5 application will change its behavior as specified, since we set the value in the runtimeconfig.json. You don't need to run the linker in order to get the behavior. Yes, the linker recognizes and reacts to these properties, but to a user that is less important than the runtime behavior change.

Copy link
Member

Choose a reason for hiding this comment

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

makes sense.

Copy link
Member

@sbomer sbomer Jul 6, 2020

Choose a reason for hiding this comment

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

One of the design goals of the feature switches is to define a general-purpose pattern we use for features - the linker's ability to drop code for disabled features is just one use case (you could in theory disable a feature without linking for example) - so I think we don't need a prefix. edit: as usual @eerhardt beat me to it :)

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of mine too 😄

<RuntimeHostConfigurationOption Include="System.Text.Encoding.EnableUnsafeUTF7Encoding"
Condition="'$(EnableUnsafeUTF7Encoding)' != ''"
Value="$(EnableUnsafeUTF7Encoding)"
Trim="true" />
Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm, "trim=true" means "this setting participates in the trimming process," not "enable trimming only if the value is set to true," correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. This value gets passed into the linker when Trim=true is set on it. See

<_TrimmerFeatureSettings Include="@(RuntimeHostConfigurationOption)" Condition="'%(RuntimeHostConfigurationOption.Trim)' == 'true'" />

@eerhardt eerhardt merged commit 408fe82 into dotnet:master Jul 7, 2020
@eerhardt eerhardt deleted the AddRuntimeFeatureSwitches branch July 7, 2020 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants