Trim managed debugging support code (#82696)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Tue, 28 Feb 2023 07:22:28 +0000 (16:22 +0900)
committerGitHub <noreply@github.com>
Tue, 28 Feb 2023 07:22:28 +0000 (16:22 +0900)
NativeAOT is not debugged with a managed debugger that would be able to understand these. It's also questionable whether a possible future managed debugger would be using this (versus debugging with IL that gets embedded in debugging symbols like .NET Native does).

16 files changed:
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
src/libraries/System.Collections.Immutable/tests/ImmutableArrayBuilderTest.cs
src/libraries/System.Collections.Immutable/tests/ImmutableDictionaryBuilderTest.cs
src/libraries/System.Collections.Immutable/tests/ImmutableDictionaryTest.cs
src/libraries/System.Collections.Immutable/tests/ImmutableHashSetTest.cs
src/libraries/System.Collections.Immutable/tests/ImmutableListBuilderTest.cs
src/libraries/System.Collections.Immutable/tests/ImmutableSortedSetBuilderTest.cs
src/libraries/System.Collections.Immutable/tests/ImmutableSortedSetTest.cs
src/libraries/System.Collections.Immutable/tests/ImmutableStackTest.cs
src/libraries/System.Collections.NonGeneric/tests/ArrayListTests.cs
src/libraries/System.Collections.NonGeneric/tests/HashtableTests.cs
src/libraries/System.Collections.NonGeneric/tests/QueueTests.cs
src/libraries/System.Collections.NonGeneric/tests/SortedListTests.cs
src/libraries/System.Collections.NonGeneric/tests/StackTests.cs
src/libraries/System.Reflection/tests/AssemblyTests.cs
src/libraries/System.Runtime/tests/System.Runtime.Tests.csproj

index 92233fd..ea6db9b 100644 (file)
@@ -247,6 +247,9 @@ The .NET Foundation licenses this file to you under the MIT license.
       <IlcArg Include="--feature:System.Linq.Expressions.CanCompileToIL=false" />
       <IlcArg Include="--feature:System.Linq.Expressions.CanEmitObjectArrayDelegate=false" />
       <IlcArg Include="--feature:System.Linq.Expressions.CanCreateArbitraryDelegates=false" />
+
+      <!-- The managed debugging support in libraries is unused - trim it -->
+      <IlcArg Condition="'$(IlcKeepManagedDebuggerSupport)' != 'true'" Include="--feature:System.Diagnostics.Debugger.IsSupported=false" />
     </ItemGroup>
 
     <MakeDir Directories="$(NativeIntermediateOutputPath)" />
index 03fdfac..252cb03 100644 (file)
@@ -1091,7 +1091,7 @@ namespace System.Collections.Immutable.Tests
             Assert.Equal(builder, items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void TestDebuggerAttributes_Null()
         {
             Type proxyType = DebuggerAttributes.GetProxyType(ImmutableArray.CreateBuilder<string>(4));
index 0b209a5..60206a7 100644 (file)
@@ -268,7 +268,7 @@ namespace System.Collections.Immutable.Tests
             Assert.Equal(builder, items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void TestDebuggerAttributes_Null()
         {
             Type proxyType = DebuggerAttributes.GetProxyType(ImmutableHashSet.Create<string>());
index 58fe714..586f455 100644 (file)
@@ -363,7 +363,7 @@ namespace System.Collections.Immutable.Tests
             Assert.Equal(dict, items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void TestDebuggerAttributes_Null()
         {
             Type proxyType = DebuggerAttributes.GetProxyType(ImmutableHashSet.Create<string>());
index 0eb795a..5c31691 100644 (file)
@@ -182,7 +182,7 @@ namespace System.Collections.Immutable.Tests
             Assert.Equal(set, items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void TestDebuggerAttributes_Null()
         {
             Type proxyType = DebuggerAttributes.GetProxyType(ImmutableHashSet.Create<string>());
index 3f218d9..f6e60f0 100644 (file)
@@ -416,7 +416,7 @@ namespace System.Collections.Immutable.Tests
             Assert.Equal(builder, items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void TestDebuggerAttributes_Null()
         {
             Type proxyType = DebuggerAttributes.GetProxyType(ImmutableList.CreateBuilder<string>());
index 3c4f9f3..6ec30b9 100644 (file)
@@ -393,7 +393,7 @@ namespace System.Collections.Immutable.Tests
             Assert.Equal(builder, items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void TestDebuggerAttributes_Null()
         {
             Type proxyType = DebuggerAttributes.GetProxyType(ImmutableSortedSet.CreateBuilder<int>());
index 6406e23..c08c91d 100644 (file)
@@ -370,7 +370,7 @@ namespace System.Collections.Immutable.Tests
             Assert.Equal(set, items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void TestDebuggerAttributes_Null()
         {
             Type proxyType = DebuggerAttributes.GetProxyType(ImmutableSortedSet.Create("1", "2", "3"));
index a5fab36..60c3922 100644 (file)
@@ -264,7 +264,7 @@ namespace System.Collections.Immutable.Tests
             Assert.Equal(stack, items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void TestDebuggerAttributes_Null()
         {
             Type proxyType = DebuggerAttributes.GetProxyType(ImmutableStack.Create<string>("1", "2", "3"));
index 8dbe4c8..d106edf 100644 (file)
@@ -78,7 +78,7 @@ namespace System.Collections.Tests
             AssertExtensions.Throws<ArgumentNullException>("c", () => new ArrayList(null)); // Collection is null
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void DebuggerAttribute()
         {
             DebuggerAttributes.ValidateDebuggerDisplayReferences(new ArrayList());
index f442136..e172e12 100644 (file)
@@ -349,7 +349,7 @@ namespace System.Collections.Tests
             AssertExtensions.Throws<ArgumentOutOfRangeException>("loadFactor", () => new Hashtable(100, float.NegativeInfinity, null)); // Load factor is infinity
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public void DebuggerAttribute()
         {
             DebuggerAttributes.ValidateDebuggerDisplayReferences(new Hashtable());
index 2ff12ce..56b5094 100644 (file)
@@ -109,7 +109,7 @@ namespace System.Collections.Tests
             Assert.Equal(testQueue.ToArray(), items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void DebuggerAttribute_NullQueue_ThrowsArgumentNullException()
         {
             bool threwNull = false;
index 2cc43c8..5c6d37d 100644 (file)
@@ -218,7 +218,7 @@ namespace System.Collections.Tests
             Assert.Equal("Count = 0", DebuggerAttributes.ValidateDebuggerDisplayReferences(new SortedList()));
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public void DebuggerAttribute_NormalList()
         {
             var list = new SortedList() { { "a", 1 }, { "b", 2 } };
@@ -228,7 +228,7 @@ namespace System.Collections.Tests
             Assert.Equal(list.Count, items.Length);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public void DebuggerAttribute_SynchronizedList()
         {
             var list = SortedList.Synchronized(new SortedList() { { "a", 1 }, { "b", 2 } });
@@ -238,7 +238,7 @@ namespace System.Collections.Tests
             Assert.Equal(list.Count, items.Length);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public void DebuggerAttribute_NullSortedList_ThrowsArgumentNullException()
         {
             bool threwNull = false;
index 85380c7..b7ef0a7 100644 (file)
@@ -87,7 +87,7 @@ namespace System.Collections.Tests
             Assert.Equal(stack.ToArray(), items);
         }
 
-        [Fact]
+        [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
         public static void DebuggerAttribute_NullStack_ThrowsArgumentNullException()
         {
             bool threwNull = false;
index 0efd41a..53410a3 100644 (file)
@@ -21,7 +21,6 @@ StringAttr("hello", name = "StringAttrSimple"),
 EnumAttr(PublicEnum.Case1, name = "EnumAttrSimple"),
 TypeAttr(typeof(object), name = "TypeAttrSimple")]
 [assembly: CompilationRelaxations(8)]
-[assembly: Debuggable((DebuggableAttribute.DebuggingModes)263)]
 [assembly: CLSCompliant(false)]
 [assembly: TypeForwardedTo(typeof(string))]
 [assembly: TypeForwardedTo(typeof(TypeInForwardedAssembly))]
@@ -60,7 +59,6 @@ namespace System.Reflection.Tests
         [InlineData(typeof(AssemblyDescriptionAttribute))]
         [InlineData(typeof(AssemblyCompanyAttribute))]
         [InlineData(typeof(CLSCompliantAttribute))]
-        [InlineData(typeof(DebuggableAttribute))]
         [InlineData(typeof(Attr))]
         public void CustomAttributes(Type type)
         {
@@ -857,7 +855,6 @@ namespace System.Reflection.Tests
         [InlineData(typeof(AssemblyDescriptionAttribute))]
         [InlineData(typeof(AssemblyCompanyAttribute))]
         [InlineData(typeof(CLSCompliantAttribute))]
-        [InlineData(typeof(DebuggableAttribute))]
         [InlineData(typeof(Attr))]
         public void GetCustomAttributesData(Type attrType)
         {
index 12f8820..e6c2e67 100644 (file)
@@ -7,6 +7,9 @@
     <IncludeRemoteExecutor>true</IncludeRemoteExecutor>
     <!-- Disable nullability public only feature for NullabilityInfoContextTests -->
     <Features>$(Features.Replace('nullablePublicOnly', '')</Features>
+
+    <!-- The test is looking for debugger attributes we would have stripped with NativeAOT -->
+    <IlcKeepManagedDebuggerSupport>true</IlcKeepManagedDebuggerSupport>
   </PropertyGroup>
 
   <!--