Fix conflicting identity of System.IO.TextReader (dotnet/coreclr#7578)
authorJan Kotas <jkotas@microsoft.com>
Wed, 12 Oct 2016 12:53:28 +0000 (05:53 -0700)
committerGitHub <noreply@github.com>
Wed, 12 Oct 2016 12:53:28 +0000 (05:53 -0700)
System.IO build was switched to use CoreFX copy of System.IO.TextReader and friends. These type have to be removed from CoreLib now to avoid type identity mismatches.

Commit migrated from https://github.com/dotnet/coreclr/commit/8e5272219f343d34c2255f3b3b839e9f1c90e630

src/coreclr/src/mscorlib/facade/TypeForwards.cs [deleted file]
src/coreclr/src/mscorlib/facade/mscorlib.csproj
src/coreclr/src/mscorlib/facade/project.json
src/coreclr/src/mscorlib/model.xml
src/coreclr/src/mscorlib/mscorlib.shared.sources.props
src/coreclr/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs
src/coreclr/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs
src/coreclr/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
src/coreclr/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs
src/coreclr/src/mscorlib/src/System/Security/SecurityElement.cs

diff --git a/src/coreclr/src/mscorlib/facade/TypeForwards.cs b/src/coreclr/src/mscorlib/facade/TypeForwards.cs
deleted file mode 100644 (file)
index ba78711..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Runtime.CompilerServices;
-
-#if WINDOWS_TYPEFORWARDS
-[assembly: TypeForwardedTo(typeof(System.Threading.WinRTSynchronizationContextFactoryBase))]
-[assembly: TypeForwardedTo(typeof(System.Resources.WindowsRuntimeResourceManagerBase))]
-[assembly: TypeForwardedTo(typeof(System.Resources.PRIExceptionInfo))]
-[assembly: TypeForwardedTo(typeof(System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeImportAttribute))]
-[assembly: TypeForwardedTo(typeof(System.Runtime.InteropServices.WindowsRuntime.IRestrictedErrorInfo))]
-[assembly: TypeForwardedTo(typeof(System.StubHelpers.EventArgsMarshaler))]
-[assembly: TypeForwardedTo(typeof(System.StubHelpers.InterfaceMarshaler))]
-#endif
-
-[assembly: TypeForwardedTo(typeof(System.Diagnostics.Tracing.FrameworkEventSource))]
-[assembly: TypeForwardedTo(typeof(System.Globalization.CultureData))]
-[assembly: TypeForwardedTo(typeof(System.Globalization.CalendarData))]
-[assembly: TypeForwardedTo(typeof(System.IO.BufferedStream))]
-[assembly: TypeForwardedTo(typeof(System.Runtime.CompilerServices.JitHelpers))]
-[assembly: TypeForwardedTo(typeof(System.Runtime.CompilerServices.ObjectHandleOnStack))]
-[assembly: TypeForwardedTo(typeof(System.Runtime.CompilerServices.PinningHelper))]
-[assembly: TypeForwardedTo(typeof(System.Runtime.CompilerServices.StackCrawlMarkHandle))]
-[assembly: TypeForwardedTo(typeof(System.Runtime.CompilerServices.StringHandleOnStack))]
-[assembly: TypeForwardedTo(typeof(System.Runtime.CompilerServices.FriendAccessAllowedAttribute))]
-[assembly: TypeForwardedTo(typeof(System.StubHelpers.StubHelpers))]
-[assembly: TypeForwardedTo(typeof(System.StubHelpers.CleanupWorkList))]
-[assembly: TypeForwardedTo(typeof(System.StubHelpers.CleanupWorkListElement))]
-[assembly: TypeForwardedTo(typeof(System.Threading.StackCrawlMark))]
-[assembly: TypeForwardedTo(typeof(System.Threading.Tasks.AsyncCausalityStatus))]
-[assembly: TypeForwardedTo(typeof(System.Threading.Tasks.CausalityRelation))]
-[assembly: TypeForwardedTo(typeof(System.Threading.Tasks.CausalitySynchronousWork))]
-[assembly: TypeForwardedTo(typeof(System.Threading.Tasks.AsyncCausalityTracer))]
-[assembly: TypeForwardedTo(typeof(System.Threading.Tasks.CausalityTraceLevel))]
-
-
index c3a165d..622e2db 100644 (file)
     <DebugType>none</DebugType>
   </PropertyGroup>
 
-  <!-- Some of the type forwards should only be build when targeting Windows. -->
-  <PropertyGroup>
-    <DefineConstants Condition="'$(TargetsWindows)'=='true'">$(DefineConstants);WINDOWS_TYPEFORWARDS</DefineConstants>
-  </PropertyGroup>
-
   <!-- Output paths -->
   <PropertyGroup>
     <BaseIntermediateOutputPath>$(RootBinDir)\obj</BaseIntermediateOutputPath>
   </ItemGroup>
 
   <ItemGroup>
-    <Compile Include="TypeForwards.cs" />
-  </ItemGroup>
-
-  <ItemGroup>
     <None Include="project.json" />
   </ItemGroup>
 
     <SeedTypePreference Include="System.Console">
       <Assembly>System.Console</Assembly>
     </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.BinaryReader">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.BinaryWriter">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.EndOfStreamException">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.MemoryStream">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.SeekOrigin">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.TextReader">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.TextWriter">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.StreamReader">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.StreamWriter">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.StringReader">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.StringWriter">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
+    <SeedTypePreference Include="System.IO.Stream">
+      <Assembly>System.IO</Assembly>
+    </SeedTypePreference>
   </ItemGroup>
 
 </Project>
index 485086e..37f8c1b 100644 (file)
@@ -1,6 +1,7 @@
 {
   "dependencies": {
     "System.Console": "4.0.0",
+    "System.IO": "4.1.0",
     "System.Security.Cryptography.Primitives": "4.0.0",
     "System.Security.Claims": "4.0.0",
   },
index 0b2f80f..445f3b6 100644 (file)
       <Member Name="#ctor(System.String,System.Exception)" />
       <Member Name="#ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)" />
     </Type>
-    <Type Status="ApiFxInternal" Name="System.IO.BufferedStream">
-      <Member Name="#ctor(System.IO.Stream,System.Int32)" />
-      <Member Name="get_UnderlyingStream" />
-      <Member Name="get_BufferSize" />
-    </Type>
     <Type Name="System.IO.FileLoadException">
       <Member Name="#ctor" />
       <Member Name="#ctor(System.String)" />
index 90de16e..68a06ff 100644 (file)
     <ThreadingSources Condition="'$(FeatureCominterop)' == 'true'" Include="$(BclSourcesRoot)\System\Threading\Tasks\IAsyncCausalityTracerStatics.cs" />
   </ItemGroup>
   <ItemGroup>
-    <IoSources Include="$(BclSourcesRoot)\System\IO\__DebugOutputTextWriter.cs" />
+    <IoSources Condition="'$(FeatureCoreClr)'!='true'" Include="$(BclSourcesRoot)\System\IO\__DebugOutputTextWriter.cs" />
     <IoSources Include="$(BclSourcesRoot)\System\IO\__Error.cs" />
     <IoSources Include="$(BclSourcesRoot)\System\IO\__HResults.cs" />
     <IoSources Include="$(BclSourcesRoot)\System\IO\BinaryReader.cs" />
     <IoSources Include="$(BclSourcesRoot)\System\IO\BinaryWriter.cs" />
-    <IoSources Include="$(BclSourcesRoot)\System\IO\BufferedStream.cs" />
+    <IoSources Condition="'$(FeatureCoreClr)'!='true'" Include="$(BclSourcesRoot)\System\IO\BufferedStream.cs" />
     <IoSources Include="$(BclSourcesRoot)\System\IO\Directory.cs" />
     <IoSources Include="$(BclSourcesRoot)\System\IO\DirectoryInfo.cs" />
     <IoSources Include="$(BclSourcesRoot)\System\IO\SearchOption.cs" />
index 5e7f83f..b9e35dc 100644 (file)
@@ -1049,16 +1049,11 @@ namespace System.Reflection.Emit
             return resWriter;
         }
 
-#endif // !FEATURE_CORECLR
-
         /**********************************************
         *
         * Add an existing resource file to the Assembly
         *
         **********************************************/
-        #if FEATURE_CORECLR
-        [System.Security.SecurityCritical] // auto-generated
-        #endif
         public void AddResourceFile(
             String      name,
             String      fileName)
@@ -1071,9 +1066,6 @@ namespace System.Reflection.Emit
         * Add an existing resource file to the Assembly
         *
         **********************************************/
-        #if FEATURE_CORECLR
-        [System.Security.SecurityCritical] // auto-generated
-        #endif
         public void AddResourceFile(
             String      name,
             String      fileName,
@@ -1133,6 +1125,7 @@ namespace System.Reflection.Emit
                     fileName), fileName);
             m_assemblyData.AddResWriter( new ResWriterData( null, null, name, fileName, fullFileName, attribute) );
         }
+#endif // !FEATURE_CORECLR
 
         #region object overrides
         public override bool Equals(object obj)
@@ -1371,8 +1364,9 @@ namespace System.Reflection.Emit
             }
         }
         #endregion
-        
-       
+
+
+#if !FEATURE_CORECLR
         /**********************************************
         *
         * Add an unmanaged Version resource to the
@@ -1505,9 +1499,9 @@ namespace System.Reflection.Emit
                     resourceFileName), resourceFileName);
             m_assemblyData.m_strResourceFileName = strFullFileName;
         }
-        
+#endif // !FEATURE_CORECLR
+
 
-        
         /**********************************************
         *
         * return a dynamic module with the specified name.
index f1a38c6..b2e62d6 100644 (file)
@@ -242,7 +242,7 @@ namespace System.Reflection.Emit {
                     }
                     // CultureInfo attribute overrides the lcid from AssemblyName.                                      
                     CultureInfo culture = new CultureInfo(m_CABuilders[i].m_constructorArgs[0].ToString());
-#if FEATURE_USE_LCID                    
+#if FEATURE_USE_LCID
                     m_nativeVersion.m_lcid = culture.LCID;
 #endif
                 }
index b66fdad..a229f3f 100644 (file)
@@ -9,7 +9,6 @@ namespace System.Reflection.Emit
 
     using System;
     using System.Globalization;
-    using TextWriter = System.IO.TextWriter;
     using System.Diagnostics.SymbolStore;
     using System.Runtime.InteropServices;
     using System.Reflection;
index 15dece9..6c4a7c8 100644 (file)
@@ -7,7 +7,6 @@
 namespace System.Reflection.Emit 
 {
     using System;
-    using TextWriter = System.IO.TextWriter;
     using System.Diagnostics.SymbolStore;
     using System.Runtime.InteropServices;
     using System.Reflection;
@@ -1212,7 +1211,7 @@ namespace System.Reflection.Emit
                 throw new ArgumentException(Environment.GetResourceString("NotSupported_OutputStreamUsingTypeBuilder"));
             }
             parameterTypes[0] = (Type)cls;
-            MethodInfo mi = typeof(TextWriter).GetMethod("WriteLine", parameterTypes);
+            MethodInfo mi = prop.ReturnType.GetMethod("WriteLine", parameterTypes);
              if (mi==null) {
                 throw new ArgumentException(Environment.GetResourceString("Argument_EmitWriteLineType"), "localBuilder");
             }
@@ -1250,7 +1249,7 @@ namespace System.Reflection.Emit
                 throw new NotSupportedException(Environment.GetResourceString("NotSupported_OutputStreamUsingTypeBuilder"));
             }
             parameterTypes[0] = (Type)cls;
-            MethodInfo mi = typeof(TextWriter).GetMethod("WriteLine", parameterTypes);
+            MethodInfo mi = prop.ReturnType.GetMethod("WriteLine", parameterTypes);
             if (mi==null) {
                 throw new ArgumentException(Environment.GetResourceString("Argument_EmitWriteLineType"), "fld");
             }
index aa63029..9f925b5 100644 (file)
@@ -626,11 +626,6 @@ namespace System.Security
         {
             ((StringBuilder)obj).Append( str );
         }
-        
-        private static void ToStringHelperStreamWriter( Object obj, String str )
-        {
-            ((StreamWriter)obj).Write( str );
-        }
 
         public override String ToString ()
         {
@@ -641,11 +636,18 @@ namespace System.Security
             return sb.ToString();
         }
 
+#if !FEATURE_CORECLR
+        private static void ToStringHelperStreamWriter(Object obj, String str)
+        {
+            ((StreamWriter)obj).Write(str);
+        }
+
         internal void ToWriter( StreamWriter writer )
         {
             ToString( "", writer, new ToStringHelperFunc( ToStringHelperStreamWriter ) );
         }
-        
+#endif
+
         private void ToString( String indent, Object obj, ToStringHelperFunc func )
         {
             // First add the indent