forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ILLink/ILCompiler support for feature checks (dotnet#99267)
This will substitute static boolean properties with `false` when decorated with `[FeatureGuard(typeof(SomeFeature))]`, where `SomeFeature` is known to be disabled. The "feature" of unreferenced code, represented by `RequiresUnreferencedCodeAttribute`, is always considered disabled. For ILC, `RequiresDynamicCodeAttribute` and `RequiresAssemblyFilesAttribute` are also disabled. ILLink also respects the feature switch for `IsDynamicCodeSupported` to disable the `RequiresDynamicCodeAttribute` feature. We don't want this kicking in when trimming in library mode, so this adds an ILLink option to disable the optimization. Additionally, a property is substituted if it has `[FeatureSwitchDefinition("SomeFeatureName")]` and `"SomeFeatureName"` is set in the command-line arguments. XML substitutions take precedence over this behavior. Includes a few tweaks and cleanup to the analyzer logic.
- Loading branch information
Showing
23 changed files
with
794 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/SubstitutionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace ILLink.RoslynAnalyzer.Tests | ||
{ | ||
public sealed partial class SubstitutionsTests : LinkerTestBase | ||
{ | ||
protected override string TestSuiteName => "Substitutions"; | ||
|
||
[Fact] | ||
public Task FeatureGuardSubstitutions () | ||
{ | ||
return RunTest (); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.