Skip to content

Proxy type map doesn't keep entries that can be created dynamically #122598

@MichalStrehovsky

Description

@MichalStrehovsky

Proxy2 is missed.

using System.Runtime.InteropServices;

[assembly: TypeMapAssociation<Program>(typeof(Gen<Atom1>), typeof(Proxy1))]
[assembly: TypeMapAssociation<Program>(typeof(Gen<Atom2>), typeof(Proxy2))]
[assembly: TypeMapAssemblyTarget<Program>("proxymap")]

class Program
{
    static void Main()
    {
        Console.WriteLine(TypeMapping.GetOrCreateProxyTypeMapping<Program>().GetValueOrDefault(new Gen<Atom1>().GetType()));
        Console.WriteLine(typeof(Program).GetMethod(nameof(GetProxyGeneric)).MakeGenericMethod(typeof(Atom2)).Invoke(null, []));
    }

    public static Type GetProxyGeneric<T>() where T : class
    {
        return TypeMapping.GetOrCreateProxyTypeMapping<Program>().GetValueOrDefault(new Gen<T>().GetType());
    }
}

class Gen<T>;

class Atom1;
class Atom2;

class Proxy1;
class Proxy2;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions