From 610672288e792982a8e84efe210d80b56e4419ba Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 28 Jun 2023 23:54:37 +0200 Subject: [PATCH 1/8] Enable ILStrip during AOT compilation of library tests --- src/mono/msbuild/apple/build/AppleBuild.props | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mono/msbuild/apple/build/AppleBuild.props b/src/mono/msbuild/apple/build/AppleBuild.props index 046c34173401b..907b15bb0ca96 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.props @@ -16,8 +16,7 @@ true false - - + true <_IsLibraryMode Condition="'$(NativeLib)' != ''">true From c145e3ad0cf64be6745c8f1738fdfc4afb68541e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 24 Jul 2023 16:44:37 +0200 Subject: [PATCH 2/8] Make System.Runtime tests resilient against ILStrip --- .../tests/System/Reflection/MethodBaseTests.cs | 6 ++++++ .../tests/System/Reflection/MethodBodyTests.cs | 5 +++++ .../CompilerServices/MethodImplAttributeTests.cs | 13 +++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System/Reflection/MethodBaseTests.cs b/src/libraries/System.Runtime/tests/System/Reflection/MethodBaseTests.cs index 61c811fbbd8ef..56d6a8b62e194 100644 --- a/src/libraries/System.Runtime/tests/System/Reflection/MethodBaseTests.cs +++ b/src/libraries/System.Runtime/tests/System/Reflection/MethodBaseTests.cs @@ -3,6 +3,7 @@ using System; using System.Reflection; +using Microsoft.DotNet.XUnitExtensions; using Xunit; #pragma warning disable 0219 // field is never used @@ -55,6 +56,11 @@ public static void TestMethodBody() { MethodBase mbase = typeof(MethodBaseTests).GetMethod("MyOtherMethod", BindingFlags.Static | BindingFlags.Public); MethodBody mb = mbase.GetMethodBody(); + + var il = mb.GetILAsByteArray(); + if (il?.Length == 1 && il[0] == 0x2a) // ILStrip replaces method bodies with the 'ret' IL opcode i.e. 0x2a + throw new SkipTestException("The method body was processed using ILStrip."); + Assert.True(mb.InitLocals); // local variables are initialized #if DEBUG Assert.Equal(2, mb.MaxStackSize); diff --git a/src/libraries/System.Runtime/tests/System/Reflection/MethodBodyTests.cs b/src/libraries/System.Runtime/tests/System/Reflection/MethodBodyTests.cs index 16e9a1003ae27..3e4abe29bea7c 100644 --- a/src/libraries/System.Runtime/tests/System/Reflection/MethodBodyTests.cs +++ b/src/libraries/System.Runtime/tests/System/Reflection/MethodBodyTests.cs @@ -3,6 +3,7 @@ using System; using System.Reflection; +using Microsoft.DotNet.XUnitExtensions; using Xunit; #pragma warning disable 0219 // field is never used @@ -17,6 +18,10 @@ public static void Test_MethodBody_ExceptionHandlingClause() MethodInfo mi = typeof(MethodBodyTests).GetMethod("MethodBodyExample", BindingFlags.NonPublic | BindingFlags.Static); MethodBody mb = mi.GetMethodBody(); + var il = mb.GetILAsByteArray(); + if (il?.Length == 1 && il[0] == 0x2a) // ILStrip replaces method bodies with the 'ret' IL opcode i.e. 0x2a + throw new SkipTestException("The method body was processed using ILStrip."); + Assert.True(mb.InitLocals); // local variables are initialized #if DEBUG Assert.Equal(2, mb.MaxStackSize); diff --git a/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/MethodImplAttributeTests.cs b/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/MethodImplAttributeTests.cs index 9f3ecf21fe0cc..e5920b896e6f1 100644 --- a/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/MethodImplAttributeTests.cs +++ b/src/libraries/System.Runtime/tests/System/Runtime/CompilerServices/MethodImplAttributeTests.cs @@ -13,8 +13,17 @@ public static class MethodImplAttributeTests public static void AggressiveOptimizationTest() { MethodImplAttributes implAttributes = MethodBase.GetCurrentMethod().MethodImplementationFlags; - Assert.Equal(MethodImplAttributes.AggressiveOptimization, implAttributes); - Assert.Equal(MethodImplOptions.AggressiveOptimization, (MethodImplOptions)implAttributes); + if (implAttributes.HasFlag(MethodImplAttributes.NoInlining)) + { + // when the assembly was processed with ILStrip, the NoInlining flag is set + Assert.Equal(MethodImplAttributes.AggressiveOptimization | MethodImplAttributes.NoInlining, implAttributes); + Assert.Equal(MethodImplOptions.AggressiveOptimization | MethodImplOptions.NoInlining, (MethodImplOptions)implAttributes); + } + else + { + Assert.Equal(MethodImplAttributes.AggressiveOptimization, implAttributes); + Assert.Equal(MethodImplOptions.AggressiveOptimization, (MethodImplOptions)implAttributes); + } } } } From 7dd7e9c49cb19bf537a99e1b638afc071fef24b1 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 9 Aug 2023 12:18:17 +0200 Subject: [PATCH 3/8] Update System.Reflection tests to support noinlining attribute --- .../tests/src/Tests/Constructor/ConstructorTests.cs | 10 +++++++++- .../tests/src/Tests/Method/MethodTests.cs | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Constructor/ConstructorTests.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Constructor/ConstructorTests.cs index 90e4595f9ac00..a87a1d0b001cf 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Constructor/ConstructorTests.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Constructor/ConstructorTests.cs @@ -31,7 +31,15 @@ private static void TestConstructors1Worker(Type t) Assert.False(c.IsConstructedGenericMethod()); Assert.False(c.IsGenericMethod); Assert.Equal(MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, c.Attributes); - Assert.Equal(MethodImplAttributes.IL, c.MethodImplementationFlags); + if (c.MethodImplementationFlags.HasFlag(MethodImplAttributes.NoInlining)) + { + // when the assembly was processed with ILStrip, the NoInlining flag is set + Assert.Equal(MethodImplAttributes.IL | MethodImplAttributes.NoInlining, c.MethodImplementationFlags); + } + else + { + Assert.Equal(MethodImplAttributes.IL, c.MethodImplementationFlags); + } Assert.Equal(CallingConventions.Standard | CallingConventions.HasThis, c.CallingConvention); ParameterInfo[] ps = c.GetParameters(); diff --git a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Method/MethodTests.cs b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Method/MethodTests.cs index 6f0f25ae95a63..de598a64e3c01 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Method/MethodTests.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/tests/src/Tests/Method/MethodTests.cs @@ -30,7 +30,15 @@ private static void TestMethods1Worker(Type t) Assert.False(m.IsConstructedGenericMethod()); Assert.False(m.IsGenericMethod); Assert.Equal(MethodAttributes.Public | MethodAttributes.HideBySig, m.Attributes); - Assert.Equal(MethodImplAttributes.IL, m.MethodImplementationFlags); + if (m.MethodImplementationFlags.HasFlag(MethodImplAttributes.NoInlining)) + { + // when the assembly was processed with ILStrip, the NoInlining flag is set + Assert.Equal(MethodImplAttributes.IL | MethodImplAttributes.NoInlining, m.MethodImplementationFlags); + } + else + { + Assert.Equal(MethodImplAttributes.IL, m.MethodImplementationFlags); + } Assert.Equal(CallingConventions.Standard | CallingConventions.HasThis, m.CallingConvention); Type theT = t.GetGenericArguments()[0]; From 95a9268f4703ac854d9d23e002b8cd61739b504d Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 21 Dec 2023 11:32:04 +0100 Subject: [PATCH 4/8] [tests] Fix failing tests --- .../Decoding/SignatureDecoderTests.cs | 19 +++++++++++-------- .../DebugTestsNoListeners.Interpolation.cs | 3 +++ .../DebugTestsNoListeners.cs | 4 ++++ .../DebugTestsUsingListeners.cs | 7 +++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs index 616045dd05cad..e11c3e32445a4 100644 --- a/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs +++ b/src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs @@ -258,14 +258,17 @@ public void PinnedAndUnpinnedLocals() Assert.Equal("DoSomething", reader.GetString(methodDef.Name)); MethodBodyBlock body = peReader.GetMethodBody(methodDef.RelativeVirtualAddress); - StandaloneSignature localSignature = reader.GetStandaloneSignature(body.LocalSignature); - - ImmutableArray localTypes = localSignature.DecodeLocalSignature(provider, genericContext: null); - - // Compiler can generate temporaries or re-order so just check the ones we expect are there. - // (They could get optimized away too. If that happens in practice, change this test to use hard-coded signatures.) - Assert.Contains("uint8[] pinned", localTypes); - Assert.Contains("uint8[]", localTypes); + var il = body.GetILBytes(); + // ILStrip replaces method body with the 'ret' IL opcode i.e. 0x2a + if (!(il?.Length == 1 && il[0] == 0x2a)) { + StandaloneSignature localSignature = reader.GetStandaloneSignature(body.LocalSignature); + ImmutableArray localTypes = localSignature.DecodeLocalSignature(provider, genericContext: null); + + // Compiler can generate temporaries or re-order so just check the ones we expect are there. + // (They could get optimized away too. If that happens in practice, change this test to use hard-coded signatures.) + Assert.Contains("uint8[] pinned", localTypes); + Assert.Contains("uint8[]", localTypes); + } } } diff --git a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.Interpolation.cs b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.Interpolation.cs index d36acad1f825a..383fae93311d6 100644 --- a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.Interpolation.cs +++ b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.Interpolation.cs @@ -43,6 +43,7 @@ public void Asserts_Interpolation_Syntax() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void WriteIf_Interpolation() { Debug.WriteIfInterpolatedStringHandler handler; @@ -76,6 +77,7 @@ public void WriteIf_Interpolation_Syntax() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void WriteLineIf_Interpolation() { Debug.WriteIfInterpolatedStringHandler handler; @@ -97,6 +99,7 @@ public void WriteLineIf_Interpolation() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void WriteLineIf_Interpolation_Syntax() { VerifyLogged(() => Debug.WriteLineIf(true, $"{EmptyToString.Instance}logged"), "logged" + Environment.NewLine); diff --git a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.cs b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.cs index 359df1c062da3..bce94683b3cd6 100644 --- a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.cs +++ b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.cs @@ -20,6 +20,7 @@ protected void GoToNextLine() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Debug_Write_Indents() { // This test when run alone verifies Debug.Write indentation, even on first call, is correct. @@ -67,6 +68,7 @@ public void Debug_WriteNull_SkipsIndentation() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Debug_WriteLineNull_IndentsEmptyStringProperly() { Debug.Indent(); @@ -100,6 +102,7 @@ public void Fail() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Write() { VerifyLogged(() => Debug.Write(5), "5"); @@ -159,6 +162,7 @@ public void WriteIf() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void WriteLineIf() { VerifyLogged(() => Debug.WriteLineIf(true, 5), "5" + Environment.NewLine); diff --git a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsUsingListeners.cs b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsUsingListeners.cs index f5d40cd4b47c8..64b8f3119c1a3 100644 --- a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsUsingListeners.cs +++ b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsUsingListeners.cs @@ -54,6 +54,7 @@ public void Trace_Write_TraceListenerAlwaysIndentsOnFirstCall() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_Write_Indents() { // This test when run alone verifies Trace.Write indentation, even on first call, is correct. @@ -74,6 +75,7 @@ public void Trace_WriteLine_Indents() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_WriteLine_WontIndentAfterWrite() { Trace.Indent(); @@ -129,6 +131,7 @@ public void Trace_WriteLineNull_IndentsEmptyStringProperly() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_UpdatingDebugIndentation_UpdatesTraceIndentation_AndViceVersa() { int before = Debug.IndentSize * Debug.IndentLevel; @@ -181,6 +184,7 @@ public void Trace_UpdatingDebugIndentation_UpdatesTraceIndentation_AndViceVersa( } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_Refresh_ResetsIndentSize() { int before = Debug.IndentSize * Debug.IndentLevel; @@ -196,6 +200,7 @@ public void Trace_Refresh_ResetsIndentSize() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_ClearTraceListeners_StopsWritingToDebugger() { VerifyLogged(() => Debug.Write("pizza"), "pizza"); @@ -211,6 +216,7 @@ public void Trace_ClearTraceListeners_StopsWritingToDebugger() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void TraceWriteIf() { VerifyLogged(() => Trace.WriteIf(true, 5), "5"); @@ -229,6 +235,7 @@ public void TraceWriteIf() } [Fact] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void TraceWriteLineIf() { VerifyLogged(() => Trace.WriteLineIf(true, 5), "5" + Environment.NewLine); From 711c1f5a4c5470ca221b2afd6e936ebf82f315dc Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 16 Jan 2024 14:13:15 +0100 Subject: [PATCH 5/8] [infra] Disable ILStrip for System.Diagnostics.Debug.Tests --- .../DebugTestsNoListeners.Interpolation.cs | 3 --- .../DebugTestsNoListeners.cs | 4 ---- .../DebugTestsUsingListeners.cs | 7 ------- .../System.Diagnostics.Debug.Tests.csproj | 2 ++ src/mono/msbuild/apple/build/AppleBuild.props | 2 +- 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.Interpolation.cs b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.Interpolation.cs index 383fae93311d6..d36acad1f825a 100644 --- a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.Interpolation.cs +++ b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.Interpolation.cs @@ -43,7 +43,6 @@ public void Asserts_Interpolation_Syntax() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void WriteIf_Interpolation() { Debug.WriteIfInterpolatedStringHandler handler; @@ -77,7 +76,6 @@ public void WriteIf_Interpolation_Syntax() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void WriteLineIf_Interpolation() { Debug.WriteIfInterpolatedStringHandler handler; @@ -99,7 +97,6 @@ public void WriteLineIf_Interpolation() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void WriteLineIf_Interpolation_Syntax() { VerifyLogged(() => Debug.WriteLineIf(true, $"{EmptyToString.Instance}logged"), "logged" + Environment.NewLine); diff --git a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.cs b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.cs index bce94683b3cd6..359df1c062da3 100644 --- a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.cs +++ b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsNoListeners.cs @@ -20,7 +20,6 @@ protected void GoToNextLine() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Debug_Write_Indents() { // This test when run alone verifies Debug.Write indentation, even on first call, is correct. @@ -68,7 +67,6 @@ public void Debug_WriteNull_SkipsIndentation() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Debug_WriteLineNull_IndentsEmptyStringProperly() { Debug.Indent(); @@ -102,7 +100,6 @@ public void Fail() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Write() { VerifyLogged(() => Debug.Write(5), "5"); @@ -162,7 +159,6 @@ public void WriteIf() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void WriteLineIf() { VerifyLogged(() => Debug.WriteLineIf(true, 5), "5" + Environment.NewLine); diff --git a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsUsingListeners.cs b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsUsingListeners.cs index 64b8f3119c1a3..f5d40cd4b47c8 100644 --- a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsUsingListeners.cs +++ b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/DebugTestsUsingListeners.cs @@ -54,7 +54,6 @@ public void Trace_Write_TraceListenerAlwaysIndentsOnFirstCall() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_Write_Indents() { // This test when run alone verifies Trace.Write indentation, even on first call, is correct. @@ -75,7 +74,6 @@ public void Trace_WriteLine_Indents() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_WriteLine_WontIndentAfterWrite() { Trace.Indent(); @@ -131,7 +129,6 @@ public void Trace_WriteLineNull_IndentsEmptyStringProperly() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_UpdatingDebugIndentation_UpdatesTraceIndentation_AndViceVersa() { int before = Debug.IndentSize * Debug.IndentLevel; @@ -184,7 +181,6 @@ public void Trace_UpdatingDebugIndentation_UpdatesTraceIndentation_AndViceVersa( } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_Refresh_ResetsIndentSize() { int before = Debug.IndentSize * Debug.IndentLevel; @@ -200,7 +196,6 @@ public void Trace_Refresh_ResetsIndentSize() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void Trace_ClearTraceListeners_StopsWritingToDebugger() { VerifyLogged(() => Debug.Write("pizza"), "pizza"); @@ -216,7 +211,6 @@ public void Trace_ClearTraceListeners_StopsWritingToDebugger() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void TraceWriteIf() { VerifyLogged(() => Trace.WriteIf(true, 5), "5"); @@ -235,7 +229,6 @@ public void TraceWriteIf() } [Fact] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst, "Trace and debug listeners were processed using ILStrip.")] public void TraceWriteLineIf() { VerifyLogged(() => Trace.WriteLineIf(true, 5), "5" + Environment.NewLine); diff --git a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/System.Diagnostics.Debug.Tests.csproj b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/System.Diagnostics.Debug.Tests.csproj index f6e9e497eca39..f27284e29a907 100644 --- a/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/System.Diagnostics.Debug.Tests.csproj +++ b/src/libraries/System.Runtime/tests/System.Diagnostics.Debug.Tests/System.Diagnostics.Debug.Tests.csproj @@ -5,6 +5,8 @@ true false + + false diff --git a/src/mono/msbuild/apple/build/AppleBuild.props b/src/mono/msbuild/apple/build/AppleBuild.props index a90ce1c8c3e64..57ee697d31c7a 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.props @@ -16,7 +16,7 @@ true false - true + true <_IsLibraryMode Condition="'$(UseNativeAOTRuntime)' != 'true' and '$(NativeLib)' != ''">true From 2b47415f82e8727095543419947bf0e56f921ec0 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 17 Jan 2024 18:54:58 +0100 Subject: [PATCH 6/8] [infra] Don't run ILStrip for library mode --- src/mono/msbuild/apple/build/AppleBuild.props | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mono/msbuild/apple/build/AppleBuild.props b/src/mono/msbuild/apple/build/AppleBuild.props index 57ee697d31c7a..97aa33ed6f7e9 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.props @@ -16,9 +16,8 @@ true false - true - <_IsLibraryMode Condition="'$(UseNativeAOTRuntime)' != 'true' and '$(NativeLib)' != ''">true + true <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' == 'true'">_AppleNativeAotCompile <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' != 'true'">_AppleAotCompile From 5fbc68246f5068e0e332b7747d4d4c54f2edd2c1 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 17 Jan 2024 21:14:26 +0100 Subject: [PATCH 7/8] Fix typo --- src/mono/msbuild/apple/build/AppleBuild.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/msbuild/apple/build/AppleBuild.props b/src/mono/msbuild/apple/build/AppleBuild.props index ba4995c855a84..22984e921c968 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.props +++ b/src/mono/msbuild/apple/build/AppleBuild.props @@ -19,7 +19,7 @@ <_IsLibraryMode Condition="('$(UseNativeAOTRuntime)' != 'true' and '$(NativeLib)' != '') or ('$(UseNativeAOTRuntime)' == 'true' and '$(NativeLib)' == 'Shared')">true - true + true <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' == 'true'">_AppleNativeAotCompile <_AotCompileTargetName Condition="'$(UseNativeAOTRuntime)' != 'true'">_AppleAotCompile From 9cdca01b17143405b7ebf1fdeca47a0e24a10e23 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 24 Jan 2024 15:45:55 +0100 Subject: [PATCH 8/8] Add ShouldILStrip to _ApplePropertyNames --- eng/testing/tests.ioslike.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/testing/tests.ioslike.targets b/eng/testing/tests.ioslike.targets index d4dfbe3ebe1e4..50f89bfef82a4 100644 --- a/eng/testing/tests.ioslike.targets +++ b/eng/testing/tests.ioslike.targets @@ -125,6 +125,7 @@ <_ApplePropertyNames Include="UseConsoleUITemplate" /> <_ApplePropertyNames Include="UseRuntimeComponents" /> <_ApplePropertyNames Include="IncludesTestRunner" /> + <_ApplePropertyNames Include="ShouldILStrip" /> <_ApplePropertiesToPass Include="$(%(_ApplePropertyNames.Identity))"