From 99c7df5de97e87a0deaef23b9da55be89409bc78 Mon Sep 17 00:00:00 2001 From: jfrijters Date: Thu, 18 Jun 2009 06:14:55 +0000 Subject: [PATCH] Added "RuntimeCompatibilityAttribute(WrapNonExceptionThrows = true)" to generated assemblies. --- ikvmc/CompilerClassLoader.cs | 1 + runtime/DynamicClassLoader.cs | 6 +----- runtime/TypeWrapper.cs | 9 +++++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ikvmc/CompilerClassLoader.cs b/ikvmc/CompilerClassLoader.cs index 68c2f9dc..de2bad50 100644 --- a/ikvmc/CompilerClassLoader.cs +++ b/ikvmc/CompilerClassLoader.cs @@ -222,6 +222,7 @@ namespace IKVM.Internal CustomAttributeBuilder debugAttr = new CustomAttributeBuilder(typeof(DebuggableAttribute).GetConstructor(new Type[] { typeof(bool), typeof(bool) }), new object[] { true, this.EmitDebugInfo }); assemblyBuilder.SetCustomAttribute(debugAttr); } + AttributeHelper.SetRuntimeCompatibilityAttribute(assemblyBuilder); if(Environment.Version.Major == 4 && Environment.Version.Minor == 0 && Environment.Version.Build == 20506) { // FXBUG workaround for MethodImpl bug in .NET 4.0 beta 1 diff --git a/runtime/DynamicClassLoader.cs b/runtime/DynamicClassLoader.cs index 89094ca9..ea30ade9 100644 --- a/runtime/DynamicClassLoader.cs +++ b/runtime/DynamicClassLoader.cs @@ -26,7 +26,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; -using System.Runtime.CompilerServices; #if IKVM_REF_EMIT using IKVM.Reflection.Emit; #else @@ -458,10 +457,7 @@ namespace IKVM.Internal #else AppDomain.CurrentDomain.DefineDynamicAssembly(name, access, null, null, null, null, null, true, attribs); #endif - assemblyBuilder.SetCustomAttribute(new CustomAttributeBuilder( - typeof(RuntimeCompatibilityAttribute).GetConstructor(Type.EmptyTypes), new object[0], - new PropertyInfo[] { typeof(RuntimeCompatibilityAttribute).GetProperty("WrapNonExceptionThrows") }, new object[] { true }, - new FieldInfo[0], new object[0])); + AttributeHelper.SetRuntimeCompatibilityAttribute(assemblyBuilder); bool debug = System.Diagnostics.Debugger.IsAttached; CustomAttributeBuilder debugAttr = new CustomAttributeBuilder(typeof(DebuggableAttribute).GetConstructor(new Type[] { typeof(bool), typeof(bool) }), new object[] { true, debug }); assemblyBuilder.SetCustomAttribute(debugAttr); diff --git a/runtime/TypeWrapper.cs b/runtime/TypeWrapper.cs index e0710872..26075474 100644 --- a/runtime/TypeWrapper.cs +++ b/runtime/TypeWrapper.cs @@ -1849,6 +1849,15 @@ namespace IKVM.Internal field.SetCustomAttribute(constantValueAttrib); } #endif // STATIC_COMPILER && !COMPACT_FRAMEWORK + + internal static void SetRuntimeCompatibilityAttribute(AssemblyBuilder assemblyBuilder) + { + Type runtimeCompatibilityAttribute = typeof(System.Runtime.CompilerServices.RuntimeCompatibilityAttribute); + assemblyBuilder.SetCustomAttribute(new CustomAttributeBuilder( + runtimeCompatibilityAttribute.GetConstructor(Type.EmptyTypes), new object[0], + new PropertyInfo[] { runtimeCompatibilityAttribute.GetProperty("WrapNonExceptionThrows") }, new object[] { true }, + new FieldInfo[0], new object[0])); + } } #if !COMPACT_FRAMEWORK