Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eng/testing/tests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
and '$(UseNativeAOTRuntime)' != 'true'
and '$(TargetOS)' != 'wasi'
and '$(TargetOS)' != 'android'
and '$(TargetsAppleMobile)' != 'true'
and '$(RuntimeFlavor)' != 'Mono'
and '$(UseRuntimeAsync)' != 'false'">
<EnablePreviewFeatures>true</EnablePreviewFeatures>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ public static void Ctor_Simple_Method_Tests()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))]
public static void Clone_LongLength_Works()
{
BitArray bitArray = new BitArray(int.MaxValue - 30);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ namespace System.Reflection.Metadata.Decoding.Tests
{
public class CustomAttributeDecoderTests
{
// After ILLink/trimming, type references may point to System.Private.CoreLib
// instead of System.Runtime. Read the actual assembly reference from metadata
// so that expected values match what the decoder produces.
private static readonly string s_systemTypeString = GetSystemTypeStringFromMetadata();

private static string GetSystemTypeStringFromMetadata()
{
string location = AssemblyPathHelper.GetAssemblyLocation(typeof(HasAttributes).Assembly);
if (string.IsNullOrEmpty(location) || !File.Exists(location))
return $"[{MetadataReaderTestHelpers.RuntimeAssemblyName}]System.Type";

using FileStream stream = File.OpenRead(location);
using PEReader peReader = new PEReader(stream);
MetadataReader reader = peReader.GetMetadataReader();

foreach (TypeReferenceHandle trh in reader.TypeReferences)
{
TypeReference tr = reader.GetTypeReference(trh);
if (reader.GetString(tr.Name) == "Type" && reader.GetString(tr.Namespace) == "System"
&& tr.ResolutionScope.Kind == HandleKind.AssemblyReference)
{
AssemblyReference asmRef = reader.GetAssemblyReference((AssemblyReferenceHandle)tr.ResolutionScope);
return $"[{reader.GetString(asmRef.Name)}]System.Type";
}
}

return $"[{MetadataReaderTestHelpers.RuntimeAssemblyName}]System.Type";
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles), nameof(PlatformDetection.IsMonoRuntime))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/60579", TestPlatforms.iOS | TestPlatforms.tvOS)]
public void TestCustomAttributeDecoder()
Expand Down Expand Up @@ -86,7 +115,6 @@ public void TestCustomAttributeDecoder()

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/73593", TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))]
public void TestCustomAttributeDecoderUsingReflection()
{
Type type = typeof(HasAttributes);
Expand Down Expand Up @@ -595,7 +623,7 @@ public TestAttribute(UInt64Enum[] value) { }
private string TypeToString(Type type)
{
if (type == typeof(Type))
return $"[{MetadataReaderTestHelpers.RuntimeAssemblyName}]System.Type";
return s_systemTypeString;

if (type.IsArray)
{
Expand Down Expand Up @@ -674,13 +702,13 @@ private class CustomAttributeTypeProvider : DisassemblingTypeProvider, ICustomAt
{
public string GetSystemType()
{
return $"[{MetadataReaderTestHelpers.RuntimeAssemblyName}]System.Type";
return s_systemTypeString;
}

public bool IsSystemType(string type)
{
return type == $"[{MetadataReaderTestHelpers.RuntimeAssemblyName}]System.Type" // encountered as typeref
|| Type.GetType(type) == typeof(Type); // encountered as serialized to reflection notation
return type == s_systemTypeString // encountered as typeref
|| Type.GetType(type) == typeof(Type); // encountered as serialized to reflection notation
}

public string GetTypeFromSerializedName(string name)
Expand All @@ -690,36 +718,36 @@ public string GetTypeFromSerializedName(string name)

public PrimitiveTypeCode GetUnderlyingEnumType(string type)
{
Type runtimeType = Type.GetType(type.Replace('/', '+')); // '/' vs '+' is only difference between ilasm and reflection notation for fixed set below.
string normalizedType = type.Replace('/', '+');

if (runtimeType == typeof(SByteEnum))
if (normalizedType == typeof(SByteEnum).FullName)
return PrimitiveTypeCode.SByte;

if (runtimeType == typeof(Int16Enum))
if (normalizedType == typeof(Int16Enum).FullName)
return PrimitiveTypeCode.Int16;

if (runtimeType == typeof(Int32Enum))
if (normalizedType == typeof(Int32Enum).FullName)
return PrimitiveTypeCode.Int32;

if (runtimeType == typeof(Int64Enum))
if (normalizedType == typeof(Int64Enum).FullName)
return PrimitiveTypeCode.Int64;

if (runtimeType == typeof(ByteEnum))
if (normalizedType == typeof(ByteEnum).FullName)
return PrimitiveTypeCode.Byte;

if (runtimeType == typeof(UInt16Enum))
if (normalizedType == typeof(UInt16Enum).FullName)
return PrimitiveTypeCode.UInt16;

if (runtimeType == typeof(UInt32Enum))
if (normalizedType == typeof(UInt32Enum).FullName)
return PrimitiveTypeCode.UInt32;

if (runtimeType == typeof(UInt64Enum))
if (normalizedType == typeof(UInt64Enum).FullName)
return PrimitiveTypeCode.UInt64;

if (runtimeType == typeof(MyEnum))
if (normalizedType == typeof(MyEnum).FullName)
return PrimitiveTypeCode.Byte;

throw new ArgumentOutOfRangeException();
throw new ArgumentOutOfRangeException(nameof(type), $"Unexpected enum type: '{type}'");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private static void AssertEqual(DllImportAttribute d1, DllImportAttribute d2)
}

[Theory]
[ActiveIssue("https://github.com/mono/mono/issues/15340", TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))]
[ActiveIssue("https://github.com/mono/mono/issues/15340", TestRuntimes.Mono)]
[MemberData(nameof(MarshalAsTheoryData))]
public static void TestMarshalAsPseudoCustomAttribute(string fieldName, MarshalAsAttribute expected)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ private static void DeleteDirectory()

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))]
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test uses Reflection.Emit (AssemblyBuilder/IL generation) but is only guarded by HasAssemblyFiles. To keep it consistent with other RefEmit tests in this project and avoid failures on runtimes where RuntimeFeature.IsDynamicCodeSupported is false (common on mobile/AOT), add a guard like PlatformDetection.IsReflectionEmitSupported (or an equivalent skip condition) to this test.

Suggested change
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles))]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.HasAssemblyFiles), nameof(PlatformDetection.IsReflectionEmitSupported))]

Copilot uses AI. Check for mistakes.
[ActiveIssue("https://github.com/dotnet/runtime/issues/31804", TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))]
public static void LoadRefEmitAssembly()
{
Init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public static class CalendarTests
{
[Fact]
[SkipOnPlatform(TestPlatforms.Android, "Doesn't throw on mobile")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))]
public static void TestJapaneseCalendarDateParsing()
{
CultureInfo ciJapanese = new CultureInfo("ja-JP") { DateTimeFormat = { Calendar = new JapaneseCalendar() } };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public static void MethodTakesRefStructAsArgWithDefaultValue_ThrowsNSE()
// Moq heavily utilizes RefEmit, which does not work on most aot workloads
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
[SkipOnMono("https://github.com/dotnet/runtime/issues/40738")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/124344", typeof(PlatformDetection), nameof(PlatformDetection.IsAppleMobile), nameof(PlatformDetection.IsCoreCLR))]
public static void MethodTakesRefToRefStructAsArg_ThrowsNSE()
{
// Use a Binder to trick the reflection stack into treating the returned null
Expand Down
2 changes: 0 additions & 2 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,7 @@
<!-- https://github.com/dotnet/runtime/issues/124344 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.ComponentModel.Composition\tests\System.ComponentModel.Composition.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Composition\tests\System.Composition.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime\tests\System.IO.FileSystem.Tests\DisabledFileLockingTests\System.IO.FileSystem.DisabledFileLocking.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Loader\tests\System.Runtime.Loader.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Diagnostics.FileVersionInfo\tests\System.Diagnostics.FileVersionInfo.Tests\System.Diagnostics.FileVersionInfo.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Diagnostics.StackTrace\tests\System.Diagnostics.StackTrace.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Private.Xml\tests\System.Private.Xml.Tests.csproj" />

Expand Down
Loading