Skip to content

Frozen collection tests fail on NativeAOT #88628

@eerhardt

Description

@eerhardt

LookupItems_AllItemsFoundAsExpected test is failing on runtime-extra-platforms.

https://dev.azure.com/dnceng-public/public/_build/results?buildId=333900&view=results

System.NotSupportedException : 'Xunit.Sdk.AssertEqualityComparer1[System.Collections.Generic.HashSet1[System.Collections.Generic.KeyValuePair2[System.UIntPtr,System.UIntPtr]]].CompareTypedSets[System.Collections.Generic.KeyValuePair2[System.UIntPtr,System.UIntPtr]](https://dev.azure.com/dnceng-public/public/_build/results?buildId=333900&view=ms.vss-test-web.build-test-results-tab&runId=6918600&resultId=106768&paneView=debug)' is missing native code. MethodInfo.MakeGenericMethod() is not compatible with AOT compilation. Inspect and fix AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility

Stack trace
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.GetUncachedMethodInvoker(RuntimeTypeInfo[], MemberInfo) + 0x74
   at System.Reflection.Runtime.MethodInfos.RuntimeNamedMethodInfo`1.MakeGenericMethod(Type[]) + 0x1ff
   at System.Collections.Frozen.Tests.FrozenDictionary_Generic_Tests`2.LookupItems_AllItemsFoundAsExpected(Int32 size, IEqualityComparer`1 comparer, Boolean specifySameComparer) + 0x296
   at System.Collections.Immutable.Tests!<BaseAddress>+0xc2051e
   at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x167

This test failed in #78046 for the same reason. To fix that issue, we added an rd.xml file to ensure Int32 native code was generated during PublishAot.

However, with #88093, we now added more primitive types to the test - see System.UIntPtr above.

To fix this, we need to add more types to the rd.xml file that was added in #78005.

<Type Name="Xunit.Sdk.AssertEqualityComparer`1[[System.Collections.Generic.HashSet`1[[System.Collections.Generic.KeyValuePair`2[[System.UInt64, System.Private.CoreLib],[System.UInt64, System.Private.CoreLib]],System.Private.CoreLib]],System.Private.CoreLib]]" Dynamic="Required All">
<Method Name="CompareTypedSets" Dynamic="Required All">
<GenericArgument Name="System.Collections.Generic.KeyValuePair`2[[System.UInt64,System.Private.CoreLib],[System.UInt64,System.Private.CoreLib]],System.Private.CoreLib" />
</Method>
</Type>

cc @adamsitnik @VSadov

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions