diff options
Diffstat (limited to 'src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs')
-rw-r--r-- | src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs | 75 |
1 files changed, 30 insertions, 45 deletions
diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs index c3f9eb4452..18139324a3 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs @@ -11,25 +11,28 @@ ** ** ============================================================*/ -namespace System.Runtime.Serialization { - - using System; - using System.Reflection; - using System.Collections; - using System.Collections.Generic; - using System.Security; - using System.Runtime.Remoting; - using System.Runtime.CompilerServices; - using System.Runtime.Versioning; - using System.Threading; - using System.IO; - using System.Text; - using System.Globalization; - using System.Diagnostics; - using System.Diagnostics.Contracts; - public static class FormatterServices { - +using System; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using System.Security; +using System.Runtime.Remoting; +using System.Runtime.CompilerServices; +using System.Runtime.Versioning; +using System.Threading; +using System.IO; +using System.Text; +using System.Globalization; +using System.Diagnostics; +using System.Diagnostics.Contracts; + +namespace System.Runtime.Serialization +{ + // This class duplicates a class on CoreFX. We are keeping it here -- just this one method -- + // as it was widely invoked by reflection to workaround it being missing in .NET Core 1.0 + internal static class FormatterServices + { // Gets a new instance of the object. The entire object is initalized to 0 and no // constructors have been run. **THIS MEANS THAT THE OBJECT MAY NOT BE IN A STATE // CONSISTENT WITH ITS INTERNAL REQUIREMENTS** This method should only be used for @@ -37,42 +40,24 @@ namespace System.Runtime.Serialization { // will not create an unitialized string because it is non-sensical to create an empty // instance of an immutable type. // - public static Object GetUninitializedObject(Type type) { - if ((object)type == null) { + public static Object GetUninitializedObject(Type type) + { + if ((object)type == null) + { throw new ArgumentNullException(nameof(type)); } Contract.EndContractBlock(); - - if (!(type is RuntimeType)) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidType", type.ToString())); + + if (!(type is RuntimeType)) + { + throw new SerializationException(SR.Format(SR.Serialization_InvalidType, type.ToString())); } return nativeGetUninitializedObject((RuntimeType)type); } - + [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern Object nativeGetUninitializedObject(RuntimeType type); - private static Binder s_binder = Type.DefaultBinder; - - /*============================LoadAssemblyFromString============================ - **Action: Loads an assembly from a given string. The current assembly loading story - ** is quite confusing. If the assembly is in the fusion cache, we can load it - ** using the stringized-name which we transmitted over the wire. If that fails, - ** we try for a lookup of the assembly using the simple name which is the first - ** part of the assembly name. If we can't find it that way, we'll return null - ** as our failure result. - **Returns: The loaded assembly or null if it can't be found. - **Arguments: assemblyName -- The stringized assembly name. - **Exceptions: None - ==============================================================================*/ - internal static Assembly LoadAssemblyFromString(String assemblyName) { - // - // Try using the stringized assembly name to load from the fusion cache. - // - BCLDebug.Trace("SER", "[LoadAssemblyFromString]Looking for assembly: ", assemblyName); - Assembly found = Assembly.Load(assemblyName); - return found; - } } } |