diff --git a/src/System.Runtime/ref/System.Runtime.cs b/src/System.Runtime/ref/System.Runtime.cs index 09e1bbb70a9e..96e942ac203d 100644 --- a/src/System.Runtime/ref/System.Runtime.cs +++ b/src/System.Runtime/ref/System.Runtime.cs @@ -3054,13 +3054,6 @@ public StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind layoutKin public System.Runtime.InteropServices.LayoutKind Value { get { return default(System.Runtime.InteropServices.LayoutKind); } } } } -namespace System.Runtime.Serialization -{ - public static partial class FormatterServices - { - public static Object GetUninitializedObject(Type type) { return default(Object); } - } -} namespace System.Runtime.Versioning { [System.AttributeUsageAttribute((System.AttributeTargets)(1), AllowMultiple = false, Inherited = false)] diff --git a/src/System.Runtime/tests/System.Runtime.Tests.csproj b/src/System.Runtime/tests/System.Runtime.Tests.csproj index 089dfb03c8e7..766a718ee171 100644 --- a/src/System.Runtime/tests/System.Runtime.Tests.csproj +++ b/src/System.Runtime/tests/System.Runtime.Tests.csproj @@ -65,7 +65,6 @@ - diff --git a/src/System.Runtime/tests/System/Runtime/Serialization/FormatterServices.cs b/src/System.Runtime/tests/System/Runtime/Serialization/FormatterServices.cs deleted file mode 100644 index 0c765c0d0f86..000000000000 --- a/src/System.Runtime/tests/System/Runtime/Serialization/FormatterServices.cs +++ /dev/null @@ -1,90 +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; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Runtime.Serialization; -using Xunit; - -namespace System.Tests -{ - public static class FormatterServicesTests - { - [Fact] - public static void NoArgument_Throws_ArgumentNullException() - { - Assert.Throws("type", () => FormatterServices.GetUninitializedObject(null)); - } - - [Theory] - [InlineData(typeof(string))] - [InlineData(typeof(int*))] - public static void StringsAndPointers_Throw_ArgumentException(Type type) - { - Assert.Throws(null /* really should be 'type' */, () => FormatterServices.GetUninitializedObject(type)); - } - - [Fact] - public static void InstantiatedArrays_Throw_ArgumentException() - { - Assert.Throws(null /* really should be 'type' */, () => FormatterServices.GetUninitializedObject((new int[] { }).GetType())); - } - - [Theory] - [InlineData(typeof(Array))] - [InlineData(typeof(ICollection))] - [InlineData(typeof(Stream))] - public static void InterfacesAndAbstractClasses_Throw_MemberAccessException(Type type) - { - Assert.Throws(() => FormatterServices.GetUninitializedObject(type)); - } - - [Theory] - [InlineData(typeof(object))] - [InlineData(typeof(MyClass))] - public static void PlainObjects_Success(Type type) - { - Assert.Equal(type, FormatterServices.GetUninitializedObject(type).GetType()); - } - - [Fact] - public static void Generic_Success() - { - var type = typeof(List); - Assert.Equal(0, ((List)FormatterServices.GetUninitializedObject(type)).Count); - Assert.Equal(type, FormatterServices.GetUninitializedObject(type).GetType()); - } - - [Theory] - [InlineData(typeof(int), 0)] - [InlineData(typeof(short), 0)] - public static void PrimitiveTypes_Success(Type type, object value) - { - Assert.Equal(value.ToString(), FormatterServices.GetUninitializedObject(type).ToString()); - Assert.Equal(type, FormatterServices.GetUninitializedObject(type).GetType()); - } - - [Fact] - public static void Nullable_BecomesNonNullable_Success() - { - Assert.Equal(typeof(int), FormatterServices.GetUninitializedObject(typeof(int?)).GetType()); - } - - [Fact] - public static void Result_Is_Mutable() - { - // Sanity check the object is actually useable - MyClass mc = ((MyClass)FormatterServices.GetUninitializedObject(typeof(MyClass))); - mc.MyMember = "foo"; - Assert.Equal("foo", mc.MyMember); - } - - private class MyClass - { - public string MyMember { get; set; } - } - } -}