diff options
author | Zoltan Varga <vargaz@gmail.com> | 2010-03-31 00:12:36 +0400 |
---|---|---|
committer | Zoltan Varga <vargaz@gmail.com> | 2010-03-31 00:12:36 +0400 |
commit | 8d24d7e206dfcb1dc5e66c169672c02f4ed2075c (patch) | |
tree | 022c89026b510856ab4328a342360e4f0a7d848c | |
parent | e84c4ac69c1922f35ef6bbd53e542733275e9089 (diff) |
2010-03-30 Zoltan Varga <vargaz@gmail.com>
* ModuleBuilder.cs (DefinedType): Lookup inside the name_cache before creating
the TypeBuilder since the runtime code can't handle a duplicate type name.
svn path=/branches/mono-2-6/mcs/; revision=154488
-rw-r--r-- | mcs/class/corlib/System.Reflection.Emit/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs | 10 |
2 files changed, 9 insertions, 6 deletions
diff --git a/mcs/class/corlib/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/System.Reflection.Emit/ChangeLog index 5c8d063401c..5c6f43f1753 100644 --- a/mcs/class/corlib/System.Reflection.Emit/ChangeLog +++ b/mcs/class/corlib/System.Reflection.Emit/ChangeLog @@ -1,5 +1,10 @@ 2010-03-30 Zoltan Varga <vargaz@gmail.com> + * ModuleBuilder.cs (DefinedType): Lookup inside the name_cache before creating + the TypeBuilder since the runtime code can't handle a duplicate type name. + +2010-03-30 Zoltan Varga <vargaz@gmail.com> + * CustomAttributeBuilder.cs (IsValidType): Call Enum.GetUnderlyingType () for dynamic enums to avoid crashes in the unmanaged code. Fixes #591800. diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs index e2e4c602afb..909da897da5 100644 --- a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs @@ -271,14 +271,12 @@ namespace System.Reflection.Emit { } private TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packingSize, int typesize) { + if (name_cache.ContainsKey (name)) + throw new ArgumentException ("Duplicate type name within an assembly."); TypeBuilder res = new TypeBuilder (this, name, attr, parent, interfaces, packingSize, typesize, null); AddType (res); - - try { - name_cache.Add (name, res); - } catch { - throw new ArgumentException ("Duplicate type name within an assembly."); - } + + name_cache.Add (name, res); return res; } |