diff options
Diffstat (limited to 'mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs')
-rw-r--r-- | mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs index e3042138882..f1790048c80 100644 --- a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs @@ -751,6 +751,20 @@ namespace System.Reflection.Emit } return false; } + + // Return whenever this type has a ctor defined using DefineMethod () + private bool has_ctor_method () { + MethodAttributes ctor_attrs = MethodAttributes.SpecialName | MethodAttributes.RTSpecialName; + + for (int i = 0; i < num_methods; ++i) { + MethodBuilder mb = (MethodBuilder)(methods[i]); + + if (mb.Name == ConstructorInfo.ConstructorName && (mb.Attributes & ctor_attrs) == ctor_attrs) + return true; + } + + return false; + } public Type CreateType() { @@ -804,7 +818,7 @@ namespace System.Reflection.Emit // On classes, define a default constructor if not provided // if (!(IsInterface || IsValueType) && (ctors == null) && (tname != "<Module>") && - (GetAttributeFlagsImpl () & TypeAttributes.Abstract | TypeAttributes.Sealed) != (TypeAttributes.Abstract | TypeAttributes.Sealed)) + (GetAttributeFlagsImpl () & TypeAttributes.Abstract | TypeAttributes.Sealed) != (TypeAttributes.Abstract | TypeAttributes.Sealed) && !has_ctor_method ()) DefineDefaultConstructor (MethodAttributes.Public); if (ctors != null){ |