summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-06-10 08:04:54 -0700
committerJan Kotas <jkotas@microsoft.com>2015-06-10 08:04:54 -0700
commitc7bd2353aca230353d3e8cb4f3aacb783af9e2cd (patch)
treea111625f4dee011375da063c0df3dfd455c4fed1
parent095adeaabace2f5d787396c3043205503102722f (diff)
parent1ac4e76e3f0a5dea311a0642d2abaac3acea43fc (diff)
downloadcoreclr-c7bd2353aca230353d3e8cb4f3aacb783af9e2cd.tar.gz
coreclr-c7bd2353aca230353d3e8cb4f3aacb783af9e2cd.tar.bz2
coreclr-c7bd2353aca230353d3e8cb4f3aacb783af9e2cd.zip
Merge pull request #1126 from stephentoub/reflectionemit_writeline
Implement ILGenerator on Unix to use System.Console.dll
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
index 4c44eb01af..fa6d539a46 100644
--- a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
@@ -1174,6 +1174,17 @@ namespace System.Reflection.Emit
this.Emit(OpCodes.Throw);
}
+ private static Type GetConsoleType()
+ {
+#if FEATURE_LEGACYSURFACE
+ return typeof(Console);
+#else
+ return Type.GetType(
+ "System.Console, System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken,
+ throwOnError: true);
+#endif
+ }
+
public virtual void EmitWriteLine(String value)
{
// Emits the IL to call Console.WriteLine with a string.
@@ -1181,7 +1192,7 @@ namespace System.Reflection.Emit
Emit(OpCodes.Ldstr, value);
Type[] parameterTypes = new Type[1];
parameterTypes[0] = typeof(String);
- MethodInfo mi = typeof(Console).GetMethod("WriteLine", parameterTypes);
+ MethodInfo mi = GetConsoleType().GetMethod("WriteLine", parameterTypes);
Emit(OpCodes.Call, mi);
}
@@ -1198,7 +1209,7 @@ namespace System.Reflection.Emit
throw new ArgumentException(Environment.GetResourceString("InvalidOperation_BadILGeneratorUsage"));
}
- MethodInfo prop = typeof(Console).GetMethod("get_Out");
+ MethodInfo prop = GetConsoleType().GetMethod("get_Out");
Emit(OpCodes.Call, prop);
Emit(OpCodes.Ldloc, localBuilder);
Type[] parameterTypes = new Type[1];
@@ -1230,7 +1241,7 @@ namespace System.Reflection.Emit
}
Contract.EndContractBlock();
- MethodInfo prop = typeof(Console).GetMethod("get_Out");
+ MethodInfo prop = GetConsoleType().GetMethod("get_Out");
Emit(OpCodes.Call, prop);
if ((fld.Attributes & FieldAttributes.Static)!=0) {