Skip to content

Use feature switches to make System.Linq.Expressions use optional? #794

@jonpryor

Description

@jonpryor

Context: https://github.com/dotnet/designs/blob/main/accepted/2020/linking-libraries.md#Feature-Switches
Context: https://docs.microsoft.com/en-us/dotnet/api/system.appcontext.trygetswitch?view=net-5.0#System_AppContext_TryGetSwitch_System_String_System_Boolean__
Context: dotnet/runtime@a547d41

In the .NET 6 timeframe, the linker will be able to "know" about "feature switches", and remove code accordingly.

Additionally, an XML file can be used to "tell" the linker which methods to remove based on the feature:

https://github.com/dotnet/runtime/blob/f3b433039b23b57fea17de117485f2b071030f69/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml

Should we consider adding a "feature switch" around anything using System.Linq.Expressions, so that if the feature isn't used, it can be linked away?

Metadata

Metadata

Assignees

Labels

java-interopRuntime bridge between .NET and Java

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions