Skip to content

Add support for 'in' decorator on method parameters for DispatchProxy #47522

@RadmirT

Description

@RadmirT

This code:

       public interface ISample
        {
            void Foo(in int bar);
        }

        public class SampleProxy : DispatchProxy
        {
            public static ISample CreateProxy()
            {
                return DispatchProxy.Create<ISample, SampleProxy>();
            }

            protected override object Invoke(MethodInfo targetMethod, object[] args)
            {
                return null;
            }
        }

        [Test]
        public void CreateProxyTest()
        {
            var proxy = SampleProxy.CreateProxy();
        }

throws the exception

System.TypeLoadException : Signature of the body and declaration in a method implementation do not match.  Type: 'generatedProxy_1'.  Assembly: 'ProxyBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
   at System.Reflection.Emit.TypeBuilder.CreateTypeInfo()
   at System.Reflection.DispatchProxyGenerator.ProxyBuilder.CreateType()
   at System.Reflection.DispatchProxyGenerator.GenerateProxyType(Type baseType, Type interfaceType)
   at System.Reflection.DispatchProxyGenerator.GetProxyType(Type baseType, Type interfaceType)
   at System.Reflection.DispatchProxyGenerator.CreateProxyInstance(Type baseType, Type interfaceType)
   at System.Reflection.DispatchProxy.Create[T,TProxy]()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions