From 884580e45117e60726461751cfc7ec2ff2defebe Mon Sep 17 00:00:00 2001 From: Michael Voorhees Date: Tue, 18 Jul 2023 12:50:56 -0400 Subject: [PATCH] Remove etw --exclude-feature tests. `--exclude-feature` logic was removed. If there is no intent to support this with coreclr bcl then we won't worry about it either. While we do need UnityLinker to continue to handle mono class libraries for awhile longer, the `--exclude-feature` functionality is a niche thing we can drop now. --- .../BCLFeatures.ETWTests.g.cs | 42 --------- .../BCLFeatures/ETW/BaseRemovedEventSource.cs | 89 ------------------- .../ETW/BaseRemovedEventSourceEmptyBody.cs | 85 ------------------ .../BaseRemovedEventSourceNonVoidReturn.cs | 69 -------------- .../BCLFeatures/ETW/Excluded.cs | 69 -------------- .../ETW/LocalsOfModifiedMethodAreRemoved.cs | 73 --------------- .../BCLFeatures/ETW/NonEventWithLog.cs | 53 ----------- .../ETW/StubbedMethodWithExceptionHandlers.cs | 75 ---------------- 8 files changed, 555 deletions(-) delete mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSource.cs delete mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceEmptyBody.cs delete mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceNonVoidReturn.cs delete mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/Excluded.cs delete mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/LocalsOfModifiedMethodAreRemoved.cs delete mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs delete mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/StubbedMethodWithExceptionHandlers.cs diff --git a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/BCLFeatures.ETWTests.g.cs b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/BCLFeatures.ETWTests.g.cs index d2168dda969295..e471fff83035ef 100644 --- a/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/BCLFeatures.ETWTests.g.cs +++ b/src/tools/illink/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/BCLFeatures.ETWTests.g.cs @@ -9,24 +9,6 @@ public sealed partial class ETWTests : LinkerTestBase protected override string TestSuiteName => "BCLFeatures.ETW"; - [Fact] - public Task BaseRemovedEventSource () - { - return RunTest (allowMissingWarnings: true); - } - - [Fact] - public Task BaseRemovedEventSourceEmptyBody () - { - return RunTest (allowMissingWarnings: true); - } - - [Fact] - public Task BaseRemovedEventSourceNonVoidReturn () - { - return RunTest (allowMissingWarnings: true); - } - [Fact] public Task CustomEventSource () { @@ -39,29 +21,5 @@ public Task CustomLibraryEventSource () return RunTest (allowMissingWarnings: true); } - [Fact] - public Task Excluded () - { - return RunTest (allowMissingWarnings: true); - } - - [Fact] - public Task LocalsOfModifiedMethodAreRemoved () - { - return RunTest (allowMissingWarnings: true); - } - - [Fact] - public Task NonEventWithLog () - { - return RunTest (allowMissingWarnings: true); - } - - [Fact] - public Task StubbedMethodWithExceptionHandlers () - { - return RunTest (allowMissingWarnings: true); - } - } } \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSource.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSource.cs deleted file mode 100644 index c5a613b6580df6..00000000000000 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSource.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Diagnostics.Tracing; -using Mono.Linker.Tests.Cases.Expectations.Assertions; -using Mono.Linker.Tests.Cases.Expectations.Metadata; - -namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW -{ - [TestCaseRequirements (TestRunCharacteristics.TargetingNetFramework, "--exclude-feature is not supported on .NET Core")] - [SetupLinkerArgument ("--exclude-feature", "etw")] - // Keep framework code that calls EventSource methods like OnEventCommand - [SetupLinkerTrimMode ("skip")] - public class BaseRemovedEventSource - { - public static void Main () - { - var b = CustomCtorEventSource.Log.IsEnabled (); - if (b) - CustomCtorEventSource.Log.SomeMethod (); - } - } - - [Kept] - [KeptBaseType (typeof (EventSource))] - [KeptMember (".ctor()")] - [KeptMember (".cctor()")] - [EventSource (Name = "MyCompany")] - class CustomCtorEventSource : EventSource - { - public class Keywords - { - public const EventKeywords Page = (EventKeywords) 1; - - public int Unused; - } - - [Kept] - public static CustomCtorEventSource Log = new MyEventSourceBasedOnCustomCtorEventSource (1); - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ldarg.0", - "call", - "ret", - })] - public CustomCtorEventSource (int value) - { - Removed (); - } - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret", - })] - protected override void OnEventCommand (EventCommandEventArgs command) - { - Removed2 (); - } - - static void Removed2 () - { - } - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret", - })] - [Event (8)] - public void SomeMethod () - { - Removed (); - } - - public void Removed () - { - } - } - - [Kept] - [KeptBaseType (typeof (CustomCtorEventSource))] - class MyEventSourceBasedOnCustomCtorEventSource : CustomCtorEventSource - { - [Kept] - public MyEventSourceBasedOnCustomCtorEventSource (int value) : base (value) - { - } - } -} diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceEmptyBody.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceEmptyBody.cs deleted file mode 100644 index b72b66afb1d7ec..00000000000000 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceEmptyBody.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Diagnostics.Tracing; -using Mono.Linker.Tests.Cases.Expectations.Assertions; -using Mono.Linker.Tests.Cases.Expectations.Metadata; - -namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW -{ - [TestCaseRequirements (TestRunCharacteristics.TargetingNetFramework, "--exclude-feature is not supported on .NET Core")] - [SetupLinkerArgument ("--exclude-feature", "etw")] - // Keep framework code that calls EventSource methods like OnEventCommand - [SetupLinkerTrimMode ("skip")] - public class BaseRemovedEventSourceEmptyBody - { - public static void Main () - { - var b = CustomCtorEventSourceEmptyBody.Log.IsEnabled (); - if (b) - CustomCtorEventSourceEmptyBody.Log.SomeMethod (); - } - } - - [Kept] - [KeptBaseType (typeof (EventSource))] - [KeptMember (".ctor()")] - [KeptMember (".cctor()")] - [EventSource (Name = "MyCompany")] - class CustomCtorEventSourceEmptyBody : EventSource - { - public class Keywords - { - public const EventKeywords Page = (EventKeywords) 1; - - public int Unused; - } - - [Kept] - public static CustomCtorEventSourceEmptyBody Log = new MyEventSourceBasedOnCustomCtorEventSourceEmptyBody (1); - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ldarg.0", - "call", - "ret", - })] - public CustomCtorEventSourceEmptyBody (int value) - { - Removed (); - } - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret" - })] - protected override void OnEventCommand (EventCommandEventArgs command) - { - // A nop is removed - } - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret" - })] - [Event (8)] - public void SomeMethod () - { - Removed (); - } - - public void Removed () - { - } - } - - [Kept] - [KeptBaseType (typeof (CustomCtorEventSourceEmptyBody))] - class MyEventSourceBasedOnCustomCtorEventSourceEmptyBody : CustomCtorEventSourceEmptyBody - { - [Kept] - public MyEventSourceBasedOnCustomCtorEventSourceEmptyBody (int value) : base (value) - { - } - } -} \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceNonVoidReturn.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceNonVoidReturn.cs deleted file mode 100644 index d6ac1d1ad292b5..00000000000000 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/BaseRemovedEventSourceNonVoidReturn.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Diagnostics.Tracing; -using Mono.Linker.Tests.Cases.Expectations.Assertions; -using Mono.Linker.Tests.Cases.Expectations.Metadata; - -namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW -{ - [TestCaseRequirements (TestRunCharacteristics.TargetingNetFramework, "--exclude-feature is not supported on .NET Core")] - [SetupLinkerArgument ("--exclude-feature", "etw")] - // Keep framework code that calls EventSource methods like OnEventCommand - [SetupLinkerTrimMode ("skip")] - public class BaseRemovedEventSourceNonVoidReturn - { - public static void Main () - { - var b = CustomCtorEventSourceNonVoidReturn.Log.IsEnabled (); - if (b) - CustomCtorEventSourceNonVoidReturn.Log.SomeMethod (); - } - } - - [Kept] - [KeptBaseType (typeof (EventSource))] - [KeptMember (".ctor()")] - [KeptMember (".cctor()")] - [EventSource (Name = "MyCompany")] - class CustomCtorEventSourceNonVoidReturn : EventSource - { - public class Keywords - { - public const EventKeywords Page = (EventKeywords) 1; - - public int Unused; - } - - [Kept] - public static CustomCtorEventSourceNonVoidReturn Log = new MyEventSourceBasedOnCustomCtorEventSourceNonVoidReturn (1); - - [Kept] - [ExpectedInstructionSequence (new[] { "ldarg.0", "call", "ret", })] - public CustomCtorEventSourceNonVoidReturn (int value) - { - Removed (); - } - - [Kept] - [ExpectedInstructionSequence (new[] { "ldstr", "newobj", "throw" })] - [ExpectLocalsModified] - [Event (8)] - public int SomeMethod () - { - return Removed (); - } - - public int Removed () - { - return 0; - } - } - - [Kept] - [KeptBaseType (typeof (CustomCtorEventSourceNonVoidReturn))] - class MyEventSourceBasedOnCustomCtorEventSourceNonVoidReturn : CustomCtorEventSourceNonVoidReturn - { - [Kept] - public MyEventSourceBasedOnCustomCtorEventSourceNonVoidReturn (int value) : base (value) - { - } - } -} \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/Excluded.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/Excluded.cs deleted file mode 100644 index 6f9f33af0d9dd7..00000000000000 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/Excluded.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Diagnostics.Tracing; -using Mono.Linker.Tests.Cases.Expectations.Assertions; -using Mono.Linker.Tests.Cases.Expectations.Metadata; - -namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW -{ - [TestCaseRequirements (TestRunCharacteristics.TargetingNetFramework, "--exclude-feature is not supported on .NET Core")] - [SetupLinkerArgument ("--exclude-feature", "etw")] - // Keep framework code that calls EventSource methods like OnEventCommand - [SetupLinkerTrimMode ("skip")] - // Used to avoid different compilers generating different IL which can mess up the instruction asserts - [SetupCompileArgument ("/optimize+")] - public class Excluded - { - public static void Main () - { - var b = RemovedEventSource.Log.IsEnabled (); - if (b) - RemovedEventSource.Log.SomeMethod (); - } - } - - [Kept] - [KeptBaseType (typeof (EventSource))] - [KeptMember (".ctor()")] - [KeptMember (".cctor()")] - [EventSource (Name = "MyCompany")] - class RemovedEventSource : EventSource - { - public class Keywords - { - public const EventKeywords Page = (EventKeywords) 1; - - public int Unused; - } - - [Kept] - public static RemovedEventSource Log = new RemovedEventSource (); - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret", - })] - protected override void OnEventCommand (EventCommandEventArgs command) - { - Removed2 (); - } - - static void Removed2 () - { - } - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret", - })] - [Event (8)] - public void SomeMethod () - { - Removed (); - } - - public void Removed () - { - } - } -} diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/LocalsOfModifiedMethodAreRemoved.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/LocalsOfModifiedMethodAreRemoved.cs deleted file mode 100644 index ea9788dbcf4714..00000000000000 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/LocalsOfModifiedMethodAreRemoved.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Diagnostics.Tracing; -using Mono.Linker.Tests.Cases.Expectations.Assertions; -using Mono.Linker.Tests.Cases.Expectations.Metadata; - -namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW -{ - [TestCaseRequirements (TestRunCharacteristics.TargetingNetFramework, "--exclude-feature is not supported on .NET Core")] - [SetupLinkerArgument ("--exclude-feature", "etw")] - // Keep framework code that calls EventSource methods like OnEventCommand - [SetupLinkerTrimMode ("skip")] - // Used to avoid different compilers generating different IL which can mess up the instruction asserts - [SetupCompileArgument ("/optimize+")] - public class LocalsOfModifiedMethodAreRemoved - { - public static void Main () - { - var b = LocalsAreCleared_RemovedEventSource.Log.IsEnabled (); - if (b) - LocalsAreCleared_RemovedEventSource.Log.SomeMethod (); - } - - public class ClassForLocal - { - } - - public static void CallsToForceALocal (int arg1, int arg2, int arg3) - { - } - } - - [Kept] - [KeptBaseType (typeof (EventSource))] - [KeptMember (".ctor()")] - [KeptMember (".cctor()")] - [EventSource (Name = "MyCompany")] - class LocalsAreCleared_RemovedEventSource : EventSource - { - public class Keywords - { - public const EventKeywords Page = (EventKeywords) 1; - - public int Unused; - } - - [Kept] - public static LocalsAreCleared_RemovedEventSource Log = new LocalsAreCleared_RemovedEventSource (); - - [Kept] - [ExpectBodyModified] - [ExpectedLocalsSequence (new string[0])] - protected override void OnEventCommand (EventCommandEventArgs command) - { - // Do some extra stuff to be extra certain the compiler introduced a local instead of using `dup` - var tmp = new LocalsOfModifiedMethodAreRemoved.ClassForLocal (); - LocalsOfModifiedMethodAreRemoved.CallsToForceALocal (1, 3, 4); - LocalsOfModifiedMethodAreRemoved.CallsToForceALocal (1, 4, 4); - var hashcode = tmp.GetHashCode (); - LocalsOfModifiedMethodAreRemoved.CallsToForceALocal (1, hashcode, 3); - } - - [Kept] - [Event (8)] - [ExpectBodyModified] - public void SomeMethod () - { - Removed (); - } - - public void Removed () - { - } - } -} \ No newline at end of file diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs deleted file mode 100644 index f02daab285b58b..00000000000000 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Diagnostics.Tracing; -using Mono.Linker.Tests.Cases.Expectations.Assertions; -using Mono.Linker.Tests.Cases.Expectations.Metadata; - -namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW -{ - [TestCaseRequirements (TestRunCharacteristics.TargetingNetFramework, "--exclude-feature is not supported on .NET Core")] - [SetupLinkerArgument ("--exclude-feature", "etw")] - // Used to avoid different compilers generating different IL which can mess up the instruction asserts - [SetupCompileArgument ("/optimize+")] - public class NonEventWithLog - { - public static void Main () - { - var n = new NonEventWithLogSource (); - n.Test1 (); - } - } - - [Kept] - [KeptBaseType (typeof (EventSource))] - [KeptMember (".ctor()")] - - [EventSource (Name = "MyCompany")] - class NonEventWithLogSource : EventSource - { - - [NonEvent] - [Kept] - internal void Test1 () - { - if (IsEnabled ()) - Test2 (); - } - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret" - })] - private void Test2 () - { - Console.WriteLine (); - } - - [NonEvent] - private void Test3 () - { - Console.WriteLine (); - } - } -} diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/StubbedMethodWithExceptionHandlers.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/StubbedMethodWithExceptionHandlers.cs deleted file mode 100644 index 54c8904a1da7a0..00000000000000 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/StubbedMethodWithExceptionHandlers.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Diagnostics.Tracing; -using Mono.Linker.Tests.Cases.Expectations.Assertions; -using Mono.Linker.Tests.Cases.Expectations.Metadata; - -namespace Mono.Linker.Tests.Cases.BCLFeatures.ETW -{ - [TestCaseRequirements (TestRunCharacteristics.TargetingNetFramework, "--exclude-feature is not supported on .NET Core")] - [SetupLinkerArgument ("--exclude-feature", "etw")] - // Keep framework code that calls EventSource methods like OnEventCommand - [SetupLinkerTrimMode ("skip")] - // Used to avoid different compilers generating different IL which can mess up the instruction asserts - [SetupCompileArgument ("/optimize+")] - public class StubbedMethodWithExceptionHandlers - { - public static void Main () - { - var b = StubbedMethodWithExceptionHandlers_RemovedEventSource.Log.IsEnabled (); - if (b) - StubbedMethodWithExceptionHandlers_RemovedEventSource.Log.SomeMethod (); - } - } - - [Kept] - [KeptBaseType (typeof (EventSource))] - [KeptMember (".ctor()")] - [KeptMember (".cctor()")] - [EventSource (Name = "MyCompany")] - class StubbedMethodWithExceptionHandlers_RemovedEventSource : EventSource - { - public class Keywords - { - public const EventKeywords Page = (EventKeywords) 1; - - public int Unused; - } - - [Kept] - public static StubbedMethodWithExceptionHandlers_RemovedEventSource Log = new StubbedMethodWithExceptionHandlers_RemovedEventSource (); - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret" - })] - protected override void OnEventCommand (EventCommandEventArgs command) - { - try { - Removed (); - } catch { - try { - Removed (); - } catch { - Removed (); - throw; - } - throw; - } - } - - [Kept] - [ExpectedInstructionSequence (new[] - { - "ret" - })] - [Event (8)] - public void SomeMethod () - { - Removed (); - } - - public void Removed () - { - } - } -} \ No newline at end of file