Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge r110288 from HEAD.

svn path=/branches/mono-2-0/mcs/; revision=110291
  • Loading branch information...
commit d7b1a66b945f37e7a62ce28a2cbb4618dbca842b 1 parent 7b06e01
@vargaz vargaz authored
View
5 mcs/class/corlib/System.Reflection.Emit/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-12 Zoltan Varga <vargaz@gmail.com>
+
+ * TypeBuilder.cs (CreateType): Avoid creating a default ctor if the
+ type has a constructor defined using DefineMethod. Fixes #416632.
+
2008-07-11 Marek Safar <marek.safar@gmail.com>
* ModuleBuilder.cs: Couple of micro optimizations.
View
16 mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
@@ -751,6 +751,20 @@ private bool is_nested_in (Type t)
}
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 @@ public Type CreateType()
// 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){
Please sign in to comment.
Something went wrong with that request. Please try again.