Пример #1
0
        public static void GetConstructorAsInvocationViaMethodAndAssembly()
        {
            MethodBase constructor = typeof(SimpleReferenceType).GetConstructor(Type.EmptyTypes);

            Assert.Equal("instance void EmitDebugging.Tests.Types.SimpleReferenceType::.ctor()",
                         MethodDescriptorFactory.Create(constructor, constructor.DeclaringType.Assembly).Value);
        }
Пример #2
0
        public static void GetConstructorAsDeclaration()
        {
            MethodBase constructor = typeof(SimpleReferenceType).GetConstructor(Type.EmptyTypes);

            Assert.Equal(".method public hidebysig specialname instance void .ctor() cil managed",
                         MethodDescriptorFactory.Create(constructor, true).Value);
        }
 private IEnumerable <MethodDescriptor> DescriptorsFromType(Type type, string key)
 {
     return(type.GetMethods()
            .Where(_methodFilters.Matches)
            .Select(m => MethodDescriptorFactory.Create(m, key))
            .ToList());
 }
Пример #4
0
        public static void GetMethodFiveAsInvocation()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodFive");

            Assert.Equal(
                "instance void EmitDebugging.Tests.Types.SimpleReferenceType::MethodFive(string[], string[]&, valuetype EmitDebugging.Tests.Types.SimpleValueType[], valuetype EmitDebugging.Tests.Types.SimpleValueType[]&)",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #5
0
        public static void GetMethodFiveAsDeclaration()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodFive");

            Assert.Equal(
                ".method public hidebysig instance void MethodFive(string[] V_0, string[]& V_1, valuetype EmitDebugging.Tests.Types.SimpleValueType[] V_2, valuetype EmitDebugging.Tests.Types.SimpleValueType[]& V_3) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #6
0
        public static void GetGenericMethodTwoAsDeclaration()
        {
            MethodInfo method = typeof(SimpleGenericType <,>).GetMethod("MethodTwo");

            Assert.Equal(
                ".method public hidebysig instance void MethodTwo<V>(string V_0, !!V V_1) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #7
0
        public static void GetGenericMethodOneOnValueTypeAsDeclaration()
        {
            MethodInfo method = typeof(SimpleGenericValueType <,>).GetMethod("MethodOne");

            Assert.Equal(
                ".method public hidebysig instance void MethodOne<V>(!T V_0, !!V V_1, !U V_2) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #8
0
        public void GetDescriptionFromMethodInvocation()
        {
            var descriptor = MethodDescriptorFactory.Create(this.GetType().GetMethod("AMethod"), false);

            Assert.Equal(typeof(MethodDescriptor), descriptor.GetType());
            Assert.Equal("instance void EmitDebugging.Tests.MethodDescriptorFactoryTests::AMethod()",
                         descriptor.Value);
        }
Пример #9
0
        public void GetDescriptionFromMethod()
        {
            var descriptor = MethodDescriptorFactory.Create(this.GetType().GetMethod("AMethod"), true);

            Assert.Equal(typeof(MethodDescriptor), descriptor.GetType());
            Assert.Equal(".method public hidebysig instance void AMethod() cil managed",
                         descriptor.Value);
        }
Пример #10
0
        public static void GetMethodFourAsDeclaration()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodFour");

            Assert.Equal(
                ".method public newslot virtual hidebysig instance void MethodFour<T, U, V>(!!T V_0, !!U V_1, !!V V_2) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #11
0
        public static void GetMethodSevenAsDeclaration()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodSeven");

            Assert.Equal(
                ".method public hidebysig static void MethodSeven<T>(!!T V_0) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #12
0
        public static void GetVarArgAsDeclaration()
        {
            MethodBase method = typeof(VarArgMethod).GetMethod("VarArg");

            Assert.Equal(
                ".method public hidebysig static vararg void VarArg(int32 V_0) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #13
0
        public static void GetVarArgAsInvocation()
        {
            MethodBase method = typeof(VarArgMethod).GetMethod("VarArg");

            Assert.Equal(
                "vararg void EmitDebugging.Tests.Types.VarArgMethod::VarArg(int32, ...)",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #14
0
        public static void GetMethodTwoAsDeclaration()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodTwo");

            Assert.Equal(
                ".method public hidebysig instance void MethodTwo(string& V_0, valuetype [mscorlib]System.Guid& V_1, valuetype EmitDebugging.Tests.Types.SimpleValueType& V_2) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #15
0
        public static void GetMethodTwoAsInvocation()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodTwo");

            Assert.Equal(
                "instance void EmitDebugging.Tests.Types.SimpleReferenceType::MethodTwo(string&, valuetype [mscorlib]System.Guid&, valuetype EmitDebugging.Tests.Types.SimpleValueType&)",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #16
0
        public static void GetMethodThreeAsDeclaration()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodThree");

            Assert.Equal(
                ".method public hidebysig static void MethodThree(int64 V_0, valuetype EmitDebugging.Tests.Types.SimpleValueType[] V_1) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #17
0
        public static void GetMethodThreeAsInvocation()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodThree");

            Assert.Equal(
                "void EmitDebugging.Tests.Types.SimpleReferenceType::MethodThree(int64, valuetype EmitDebugging.Tests.Types.SimpleValueType[])",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #18
0
        public void GetDescriptionFromGenericMethod()
        {
            var descriptor = MethodDescriptorFactory.Create(this.GetType().GetMethod("AGenericMethod"));

            Assert.Equal(typeof(MethodGenericDeclarationDescriptor), descriptor.GetType());
            Assert.Equal(".method public hidebysig instance void AGenericMethod<T, U>() cil managed",
                         descriptor.Value);
        }
Пример #19
0
        public static void GetMethodSixAsDeclaration()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod("MethodSix");

            Assert.Equal(
                ".method public hidebysig instance void MethodSix<T, U>(!!T& V_0, !!U V_1) cil managed",
                MethodDescriptorFactory.Create(method, true).Value);
        }
Пример #20
0
        public static void GetConstructorWithArgumentsAsInvocation()
        {
            MethodBase constructor = typeof(SimpleReferenceType).GetConstructor(
                new Type[] { typeof(string) });

            Assert.Equal(
                "instance void EmitDebugging.Tests.Types.SimpleReferenceType::.ctor(string)",
                MethodDescriptorFactory.Create(constructor).Value);
        }
Пример #21
0
        public static void GetConstructorWithArgumentAsDeclaration()
        {
            MethodBase constructor = typeof(SimpleReferenceType).GetConstructor(
                new Type[] { typeof(string) });

            Assert.Equal(
                ".method public hidebysig specialname instance void .ctor(string V_0) cil managed",
                MethodDescriptorFactory.Create(constructor, true).Value);
        }
Пример #22
0
        public void GetDescriptionFromMethodWithDifferentContainingAssembly()
        {
            var descriptor = MethodDescriptorFactory.Create(
                this.GetType().GetMethod("AMethod"), typeof(Guid).Assembly);

            Assert.Equal(typeof(MethodDescriptor), descriptor.GetType());
            Assert.Equal("instance void [EmitDebugging.Tests]EmitDebugging.Tests.MethodDescriptorFactoryTests::AMethod()",
                         descriptor.Value);
        }
Пример #23
0
        public static void GetMethodSevenAsInvocation()
        {
            MethodBase method = typeof(SimpleReferenceType).GetMethod(
                "MethodSeven").MakeGenericMethod(new Type[] { typeof(string) });

            Assert.Equal(
                "void EmitDebugging.Tests.Types.SimpleReferenceType::MethodSeven<string>(!!0)",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #24
0
        public static void GetGenericMethodOneAsInvocation()
        {
            MethodInfo method = typeof(SimpleGenericType <MethodInfo, Uri>).GetMethod(
                "MethodOne").MakeGenericMethod(new Type[] { typeof(string) });

            Assert.Equal(
                "instance void class EmitDebugging.Tests.Types.SimpleGenericType`2<class [mscorlib]System.Reflection.MethodInfo, class [System]System.Uri>::MethodOne<string>(!0, !1, !!0)",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #25
0
        public static void GetMethodFourAsInvocation()
        {
            MethodInfo method = typeof(SimpleReferenceType).GetMethod(
                "MethodFour").MakeGenericMethod(new Type[] { typeof(Guid), typeof(string), typeof(int) });

            Assert.Equal(
                "instance void EmitDebugging.Tests.Types.SimpleReferenceType::MethodFour<valuetype [mscorlib]System.Guid, string, int32>(!!0, !!1, !!2)",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #26
0
        public static void GetMethodSixAsInvocation()
        {
            MethodInfo method = typeof(SimpleReferenceType).GetMethod(
                "MethodSix").MakeGenericMethod(new Type[] { typeof(string), typeof(string) });

            Assert.Equal(
                "instance void EmitDebugging.Tests.Types.SimpleReferenceType::MethodSix<string, string>(!!0&, !!1)",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #27
0
        public static void GetGenericMethodOneOnValueTypeAsInvocation()
        {
            MethodInfo method = typeof(SimpleGenericValueType <Guid, string>).GetMethod(
                "MethodOne").MakeGenericMethod(new Type[] { typeof(int) });

            Assert.Equal(
                "instance void valuetype EmitDebugging.Tests.Types.SimpleGenericValueType`2<valuetype [mscorlib]System.Guid, string>::MethodOne<int32>(!0, !!0, !1)",
                MethodDescriptorFactory.Create(method).Value);
        }
Пример #28
0
        public void GetDescriptionFromGenericMethodInvocation()
        {
            var method = this.GetType().GetMethod("AGenericMethod").MakeGenericMethod(
                new Type[] { typeof(Guid), typeof(Random) });
            var descriptor = MethodDescriptorFactory.Create(method);

            Assert.Equal(typeof(MethodGenericInvocationDescriptor), descriptor.GetType());
            Assert.Equal(
                "instance void EmitDebugging.Tests.MethodDescriptorFactoryTests::AGenericMethod<valuetype [mscorlib]System.Guid, class [mscorlib]System.Random>()",
                descriptor.Value);
        }
Пример #29
0
        public IEnumerable <MethodDescriptor> CreateMethodDescriptors()
        {
            MethodInfo       voidMeth             = typeof(EmptyProvider).GetMethod("VoidMethod");
            MethodInfo       funcMeth             = typeof(EmptyProvider).GetMethod("FuncMethod");
            MethodInfo       randToListMeth       = typeof(EmptyProvider).GetMethod("AddRandomToList");
            MethodDescriptor funcDescriptor       = MethodDescriptorFactory.Create(funcMeth, "1");
            MethodDescriptor actionDescriptor     = MethodDescriptorFactory.Create(voidMeth, "2");
            MethodDescriptor randToListDescriptor = MethodDescriptorFactory.Create(randToListMeth, "3");

            return(new[] { funcDescriptor, actionDescriptor, randToListDescriptor });
        }
Пример #30
0
 public static void GetDescriptionFromMethodBuilder()
 {
     using (var assembly = AssemblyCreationTests.CreateDebuggingAssembly("BuilderGenericDeclaration"))
     {
         using (var type = AssemblyCreationTests.CreateDebuggingType(
                    assembly, assembly.Builder.GetDynamicModule(assembly.Builder.GetName().Name), "Holder"))
         {
             using (var method = type.GetMethodDebugging(
                        type.Builder.DefineMethod("Method",
                                                  MethodAttributes.HideBySig | MethodAttributes.Public)))
             {
                 var descriptor = MethodDescriptorFactory.Create(method.Builder, true);
                 Assert.Equal(typeof(MethodDescriptor), descriptor.GetType());
                 Assert.Equal(".method public hidebysig instance void Method() cil managed",
                              descriptor.Value);
             }
         }
     }
 }