Skip to content

Commit c670547

Browse files
Enabling 9 new libraries tests for NativeAOT (#72167)
1 parent 91dda98 commit c670547

File tree

27 files changed

+196
-58
lines changed

27 files changed

+196
-58
lines changed

src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeAugments.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public static object NewObject(RuntimeTypeHandle typeHandle)
8686
|| eeType == EETypePtr.EETypePtrOf<string>()
8787
)
8888
return null;
89+
if (eeType.IsByRefLike)
90+
throw new System.Reflection.TargetException();
8991
return RuntimeImports.RhNewObject(eeType);
9092
}
9193

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ private static bool GetLinqExpressionsBuiltWithIsInterpretingOnly()
152152
public static bool IsAssemblyLoadingSupported => !IsNativeAot;
153153
public static bool IsMethodBodySupported => !IsNativeAot;
154154
public static bool IsDebuggerTypeProxyAttributeSupported => !IsNativeAot;
155+
public static bool HasAssemblyFiles => !string.IsNullOrEmpty(typeof(PlatformDetection).Assembly.Location);
156+
public static bool HasHostExecutable => HasAssemblyFiles; // single-file don't have a host
155157

156158
private static volatile Tuple<bool> s_lazyNonZeroLowerBoundArraySupported;
157159
public static bool IsNonZeroLowerBoundArraySupported

src/libraries/System.Buffers/tests/ArrayPool/UnitTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,9 @@ public static void RentingSpecificLengthsYieldsExpectedLengths(int requestedMini
345345
}
346346
}
347347

348-
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.Is64BitProcess))]
348+
public static bool Is64BitProcessAndRemoteExecutorSupported => PlatformDetection.Is64BitProcess && RemoteExecutor.IsSupported;
349+
350+
[ConditionalTheory(nameof(Is64BitProcessAndRemoteExecutorSupported))]
349351
[InlineData(1024 * 1024 * 1024 - 1, true)]
350352
[InlineData(1024 * 1024 * 1024, true)]
351353
[InlineData(1024 * 1024 * 1024 + 1, false)]

src/libraries/System.Collections.Concurrent/tests/BlockingCollectionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static void TestBugFix914998()
170170
Assert.Equal(1, BlockingCollection<int>.TryTakeFromAny(producerArray, out ignored, -1));
171171
}
172172

173-
[Fact]
173+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
174174
public static void TestDebuggerAttributes()
175175
{
176176
DebuggerAttributes.ValidateDebuggerDisplayReferences(new BlockingCollection<int>());
@@ -181,7 +181,7 @@ public static void TestDebuggerAttributes()
181181
Assert.Equal(col, items);
182182
}
183183

184-
[Fact]
184+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
185185
public static void TestDebuggerAttributes_Null()
186186
{
187187
Type proxyType = DebuggerAttributes.GetProxyType(new BlockingCollection<int>());

src/libraries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionaryTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ public static void TestConstructor()
622622
Assert.Equal(1, dictionary.Values.Count);
623623
}
624624

625-
[Fact]
625+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
626626
public static void TestDebuggerAttributes()
627627
{
628628
DebuggerAttributes.ValidateDebuggerDisplayReferences(new ConcurrentDictionary<string, int>());
@@ -635,7 +635,7 @@ public static void TestDebuggerAttributes()
635635
Assert.Equal(dict, items);
636636
}
637637

638-
[Fact]
638+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
639639
public static void TestDebuggerAttributes_Null()
640640
{
641641
Type proxyType = DebuggerAttributes.GetProxyType(new ConcurrentDictionary<string, int>());

src/libraries/System.Collections.Concurrent/tests/ProducerConsumerCollectionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ public void ManyConcurrentAddsTakes_ForceContentionWithGetEnumerator(int initial
953953
Assert.Equal(initialCount, c.Count);
954954
}
955955

956-
[Theory]
956+
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
957957
[InlineData(0)]
958958
[InlineData(10)]
959959
public void DebuggerAttributes_Success(int count)
@@ -966,7 +966,7 @@ public void DebuggerAttributes_Success(int count)
966966
Assert.Equal(c, items.Cast<int>());
967967
}
968968

969-
[Fact]
969+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDebuggerTypeProxyAttributeSupported))]
970970
public void DebuggerTypeProxy_Ctor_NullArgument_Throws()
971971
{
972972
IProducerConsumerCollection<int> c = CreateProducerConsumerCollection();

src/libraries/System.Drawing.Common/tests/BitmapTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ public void GetHicon_Disposed_ThrowsArgumentException()
790790

791791
[ConditionalFact(Helpers.IsDrawingSupported)]
792792
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "In .NET Framework we use GDI 1.0")]
793+
[ActiveIssue("https://github.com/dotnet/runtime/issues/72165", typeof(PlatformDetection), nameof(PlatformDetection.IsNativeAot))]
793794
public void SaveWmfAsPngDoesntChangeImageBoundaries()
794795
{
795796
if (PlatformDetection.IsWindows7)

src/libraries/System.Drawing.Common/tests/IconTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ void VerifyPngNotSupported()
647647
}
648648
else
649649
{
650-
VerifyPngNotSupported();
650+
if (AppContext.TryGetSwitch(DontSupportPngFramesInIcons, out bool enabled) && enabled)
651+
VerifyPngNotSupported();
651652
}
652653
}
653654

src/libraries/System.Drawing.Common/tests/System.Drawing.Common.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
<TargetFrameworks>$(NetCoreAppCurrent)-windows;net48</TargetFrameworks>
66
<IgnoreForCI Condition="'$(TargetsMobile)' == 'true'">true</IgnoreForCI>
77
</PropertyGroup>
8+
<ItemGroup>
9+
<RdXmlFile Include="default.rd.xml" />
10+
</ItemGroup>
811
<ItemGroup>
912
<Compile Include="AssemblyInfo.cs" />
1013
<Compile Include="BitmapTests.cs" />

src/libraries/System.Drawing.Common/tests/System/Drawing/FontConverterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void EmptyStringInput()
8181
Assert.Null(font);
8282
}
8383

84-
[ConditionalFact(Helpers.IsDrawingSupported)]
84+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsDrawingSupported), nameof(PlatformDetection.IsNotBuiltWithAggressiveTrimming))]
8585
public void GetFontPropsSorted()
8686
{
8787
// The order provided since .NET Framework

0 commit comments

Comments
 (0)