From 78768ce44c00b352d1ca11124e0b362516fa0266 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 26 Mar 2020 10:30:23 +0100 Subject: Add sealer opt-in optimization (#1011) * Add sealer opt-in optimization * Review feedback * Add local cache for IsSubclassed check * Generate verifiable metadata * Move nested check before interface shortcut --- test/Mono.Linker.Tests/TestCases/TestDatabase.cs | 5 +++++ test/Mono.Linker.Tests/TestCases/TestSuites.cs | 6 ++++++ .../Mono.Linker.Tests/Tests/CodeOptimizationsSettingsTests.cs | 11 +++++++++++ 3 files changed, 22 insertions(+) (limited to 'test/Mono.Linker.Tests') diff --git a/test/Mono.Linker.Tests/TestCases/TestDatabase.cs b/test/Mono.Linker.Tests/TestCases/TestDatabase.cs index fe40ae4d5..5e603ba19 100644 --- a/test/Mono.Linker.Tests/TestCases/TestDatabase.cs +++ b/test/Mono.Linker.Tests/TestCases/TestDatabase.cs @@ -147,6 +147,11 @@ namespace Mono.Linker.Tests.TestCases return NUnitCasesBySuiteName ("UnreachableBlock"); } + public static IEnumerable SealerTests () + { + return NUnitCasesBySuiteName ("Sealer"); + } + public static IEnumerable SubstitutionsTests () { return NUnitCasesBySuiteName ("Substitutions"); diff --git a/test/Mono.Linker.Tests/TestCases/TestSuites.cs b/test/Mono.Linker.Tests/TestCases/TestSuites.cs index 2fda3c3e9..60f2ff9ed 100644 --- a/test/Mono.Linker.Tests/TestCases/TestSuites.cs +++ b/test/Mono.Linker.Tests/TestCases/TestSuites.cs @@ -187,6 +187,12 @@ namespace Mono.Linker.Tests.TestCases Run (testCase); } + [TestCaseSource (typeof (TestDatabase), nameof (TestDatabase.SealerTests))] + public void SealerTests (TestCase testCase) + { + Run (testCase); + } + protected virtual void Run (TestCase testCase) { var runner = new TestRunner (new ObjectFactory ()); diff --git a/test/Mono.Linker.Tests/Tests/CodeOptimizationsSettingsTests.cs b/test/Mono.Linker.Tests/Tests/CodeOptimizationsSettingsTests.cs index e7b8ff2f6..a05fb5393 100644 --- a/test/Mono.Linker.Tests/Tests/CodeOptimizationsSettingsTests.cs +++ b/test/Mono.Linker.Tests/Tests/CodeOptimizationsSettingsTests.cs @@ -40,5 +40,16 @@ namespace Mono.Linker.Tests Assert.False (cos.IsEnabled (CodeOptimizations.ClearInitLocals, "any")); Assert.That (cos.IsEnabled (CodeOptimizations.BeforeFieldInit, "testasm.dll")); } + + [Test] + public void OnlyOneOptIsDisabled () + { + CodeOptimizationsSettings cos = new CodeOptimizationsSettings (CodeOptimizations.OverrideRemoval); + cos.Disable (CodeOptimizations.BeforeFieldInit, "testasm.dll"); + + Assert.False (cos.IsEnabled (CodeOptimizations.BeforeFieldInit, "testasm.dll")); + Assert.False (cos.IsEnabled (CodeOptimizations.Sealer, "testasm.dll")); + Assert.False (cos.IsEnabled (CodeOptimizations.UnreachableBodies, "testasm.dll")); + } } } \ No newline at end of file -- cgit v1.2.3