In Assembly:
[mono.git] / mcs / class / corlib / System.Reflection.Emit / ModuleBuilder.cs
index 4e4eb8f0c5713dc280dc68cf510ed1503ab8ecbd..672be8b6b6129c6830d81650b440bb8dc32d7280 100644 (file)
@@ -42,10 +42,8 @@ using System.Resources;
 using System.Globalization;
 
 namespace System.Reflection.Emit {
-#if NET_2_0
        [ComVisible (true)]
        [ComDefaultInterface (typeof (_ModuleBuilder))]
-#endif
        [ClassInterface (ClassInterfaceType.None)]
        public class ModuleBuilder : Module, _ModuleBuilder {
 
@@ -103,6 +101,9 @@ namespace System.Reflection.Emit {
                        }
 
                        if (emitSymbolInfo) {
+#if NET_2_1 && !MONOTOUCH
+                               symbolWriter = new Mono.CompilerServices.SymbolWriter.SymbolWriterImpl (this);
+#else
                                Assembly asm = Assembly.LoadWithPartialName ("Mono.CompilerServices.SymbolWriter");
                                if (asm == null)
                                        throw new ExecutionEngineException ("The assembly for default symbol writer cannot be loaded");
@@ -112,6 +113,7 @@ namespace System.Reflection.Emit {
                                        throw new ExecutionEngineException ("The type that implements the default symbol writer interface cannot be found");
 
                                symbolWriter = (ISymbolWriter) Activator.CreateInstance (t, new object[] { this });
+#endif
                                string fileName = fqname;
                                if (assemblyb.AssemblyDir != null)
                                        fileName = Path.Combine (assemblyb.AssemblyDir, fileName);
@@ -199,12 +201,7 @@ namespace System.Reflection.Emit {
                        return DefineGlobalMethod (name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
                }
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
-               public
-#else
-               internal
-#endif
-               MethodBuilder DefineGlobalMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
+               public MethodBuilder DefineGlobalMethod (string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers)
                {
                        if (name == null)
                                throw new ArgumentNullException ("name");
@@ -289,9 +286,7 @@ namespace System.Reflection.Emit {
                        return (TypeBuilder) name_cache [name];
                }
 
-#if NET_2_0
                [ComVisible (true)]
-#endif
                public TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, Type[] interfaces) {
                        return DefineType (name, attr, parent, interfaces, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize);
                }
@@ -323,16 +318,12 @@ namespace System.Reflection.Emit {
                        return eb;
                }
 
-#if NET_2_0
                [ComVisible (true)]
-#endif
                public override Type GetType( string className) {
                        return GetType (className, false, false);
                }
                
-#if NET_2_0
                [ComVisible (true)]
-#endif
                public override Type GetType( string className, bool ignoreCase) {
                        return GetType (className, false, ignoreCase);
                }
@@ -381,10 +372,14 @@ namespace System.Reflection.Emit {
                        return null;
                }
 
-#if NET_2_0
                [ComVisible (true)]
-#endif         
-               public override Type GetType (string className, bool throwOnError, bool ignoreCase) {
+               public override Type GetType (string className, bool throwOnError, bool ignoreCase)
+               {
+                       if (className == null)
+                               throw new ArgumentNullException ("className");
+                       if (className.Length == 0)
+                               throw new ArgumentException ("className");
+
                        int subt;
                        string orig = className;
                        string modifiers;
@@ -456,9 +451,7 @@ namespace System.Reflection.Emit {
                        }
                }
 
-#if NET_2_0
                [ComVisible (true)]
-#endif
                public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
                        SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
                }
@@ -549,7 +542,6 @@ namespace System.Reflection.Emit {
                        throw new NotImplementedException ();
                }
 
-#if NET_2_0 || BOOTSTRAP_NET_2_0
                public void DefineManifestResource (string name, Stream stream, ResourceAttributes attribute) {
                        if (name == null)
                                throw new ArgumentNullException ("name");
@@ -574,7 +566,6 @@ namespace System.Reflection.Emit {
                        resources [p].attrs = attribute;
                        resources [p].stream = stream;
                }
-#endif
 
                [MonoTODO]
                public void SetSymCustomAttribute (string name, byte[] data)
@@ -606,9 +597,7 @@ namespace System.Reflection.Emit {
                        return GetMethodToken (GetArrayMethod (arrayClass, methodName, callingConvention, returnType, parameterTypes));
                }
 
-#if NET_2_0
                [ComVisible (true)]
-#endif
                public MethodToken GetConstructorToken (ConstructorInfo con)
                {
                        if (con == null)