diff options
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs new file mode 100644 index 000000000..5b0b82f18 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/BCLFeatures/ETW/NonEventWithLog.cs @@ -0,0 +1,51 @@ +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 { + [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 [] + { + "ldstr", + "newobj", + "throw", + })] + private void Test2 () + { + Console.WriteLine (); + } + + [NonEvent] + private void Test3 () + { + Console.WriteLine (); + } + } +} |