public static void CallEqualsAfterDisposing()
        {
            AssemblyDebugging assembly = null;

            using (assembly = AssemblyCreationTests.CreateDebuggingAssembly("Me")) { }

            Assert.Throws <ObjectDisposedException>(() => assembly.GetTypeDebugging(null));
        }
        public static void CallDisposeAfterDisposing()
        {
            AssemblyDebugging assembly = null;

            using (assembly = AssemblyCreationTests.CreateDebuggingAssembly("Me")) { }

            assembly.Dispose();
        }
Exemplo n.º 3
0
        public static void CallGetMethodDebuggingWithMethodBuilderAfterDisposing()
        {
            TypeDebugging type = null;

            using (var assembly = AssemblyCreationTests.CreateDebuggingAssembly("Me"))
            {
                using (type = AssemblyCreationTests.CreateDebuggingType(assembly,
                                                                        assembly.Builder.GetDynamicModule("Me"), "Type")) { }

                Assert.Throws <ObjectDisposedException>(() => type.GetMethodDebugging(null as MethodBuilder));
            }
        }
Exemplo n.º 4
0
        public static void CallDisposeAfterDisposing()
        {
            TypeDebugging type = null;

            using (var assembly = AssemblyCreationTests.CreateDebuggingAssembly("Me"))
            {
                using (type = AssemblyCreationTests.CreateDebuggingType(assembly,
                                                                        assembly.Builder.GetDynamicModule("Me"), "Type")) { }

                type.Dispose();
            }
        }
Exemplo n.º 5
0
 public static void GetTypeBuilderDescription()
 {
     using (var assembly = AssemblyCreationTests.CreateDebuggingAssembly("TypeBuilderDescriptor"))
     {
         using (var type = AssemblyCreationTests.CreateDebuggingType(
                    assembly, assembly.Builder.GetDynamicModule(assembly.Builder.GetName().Name), "Holder"))
         {
             var descriptor = new TypeDescriptor(type.Builder);
             Assert.Equal("class TypeBuilderDescriptor.Holder",
                          descriptor.Value);
         }
     }
 }
Exemplo n.º 6
0
        public static void GetGenericTypeBuilderDescription()
        {
            using (var assembly = AssemblyCreationTests.CreateDebuggingAssembly("GenericTypeBuilderDescriptor"))
            {
                using (var type = AssemblyCreationTests.CreateDebuggingType(
                           assembly, assembly.Builder.GetDynamicModule(assembly.Builder.GetName().Name), "Holder"))
                {
                    type.Builder.DefineGenericParameters("T", "U", "V");

                    var descriptor = new TypeDescriptor(type.Builder);
                    Assert.Equal("class GenericTypeBuilderDescriptor.Holder`3<T, U, V>",
                                 descriptor.Value);
                }
            }
        }
Exemplo n.º 7
0
        private static MethodDebugging GetMethod()
        {
            MethodDebugging method = null;

            var name = Guid.NewGuid().ToString("N");

            using (var assembly = AssemblyCreationTests.CreateDebuggingAssembly(name))
            {
                using (var type = AssemblyCreationTests.CreateDebuggingType(
                           assembly, assembly.Builder.GetDynamicModule(name), "Type"))
                {
                    using (method = type.GetMethodDebugging(
                               type.Builder.DefineMethod("Method", MethodAttributes.Public | MethodAttributes.Static))) { }
                }
            }

            return(method);
        }
Exemplo n.º 8
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);
             }
         }
     }
 }