summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephentoub <stoub@microsoft.com>2015-06-10 09:24:43 -0400
committerstephentoub <stoub@microsoft.com>2015-06-10 10:35:32 -0400
commit1ac4e76e3f0a5dea311a0642d2abaac3acea43fc (patch)
tree3efc8ad6b68af67d51613aab2c63ceb07a42fa3b
parent6b36698f02601918ad3cd549e0debd55862b5347 (diff)
downloadcoreclr-1ac4e76e3f0a5dea311a0642d2abaac3acea43fc.tar.gz
coreclr-1ac4e76e3f0a5dea311a0642d2abaac3acea43fc.tar.bz2
coreclr-1ac4e76e3f0a5dea311a0642d2abaac3acea43fc.zip
Implement ILGenerator on Unix to use System.Console.dll
The System.Console type in mscorlib on Unix is internal and lacks any ability to write out. As such, System.Reflection.Emit.ILGenerator.EmitWriteLine needs to use the System.Console from 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) {