Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace System
public static partial class Activator
{
public static object CreateInstance(System.Type type) { return default(object); }
public static object CreateInstance(System.Type type, System.Boolean nonPublic) { return default(object); }
public static object CreateInstance(System.Type type, params object[] args) { return default(object); }
public static T CreateInstance<T>() { return default(T); }
}
Expand Down Expand Up @@ -1883,6 +1884,7 @@ public abstract partial class Type
{
public static readonly System.Type[] EmptyTypes;
public static readonly object Missing;
public static readonly char Delimiter;
internal Type() { }
public abstract string AssemblyQualifiedName { get; }
public abstract string FullName { get; }
Expand All @@ -1906,6 +1908,7 @@ internal Type() { }
public static System.Type GetType(string typeName) { return default(System.Type); }
public static System.Type GetType(string typeName, bool throwOnError) { return default(System.Type); }
public static System.Type GetType(string typeName, bool throwOnError, bool ignoreCase) { return default(System.Type); }
public static System.TypeCode GetTypeCode(System.Type type) { return default(System.TypeCode); }
public static System.Type GetTypeFromHandle(System.RuntimeTypeHandle handle) { return default(System.Type); }
public abstract System.Type MakeArrayType();
public abstract System.Type MakeArrayType(int rank);
Expand Down
10 changes: 10 additions & 0 deletions src/System.Runtime/tests/System.Runtime.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,17 @@
</ItemGroup>
<ItemGroup>
<!-- Compile tests against the System.Runtime contract, but copy our local-built implementation for testing -->
<ProjectReference Include="..\ref\System.Runtime.csproj">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to indicate we are not testing any of the other new System.Runtime APIs higher then 4.0.20?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that surprised me as well. The tests I wrote were not able to find new methods so I dug in and found this to be the issue.

<Project>{446de6f0-47a0-4c2f-a918-768a76ccf461}</Project>
<Name>System.Runtime</Name>
<!-- Don't copy the reference assembly to output -->
<Private>false</Private>
<UndefineProperties>OSGroup</UndefineProperties>
</ProjectReference>
<ProjectReference Include="..\src\System.Runtime.csproj">
<Project>{1e689c1b-690c-4799-bde9-6e7990585894}</Project>
<Name>System.Runtime</Name>
<!-- Don't reference implementation assembly, but do deploy it. -->
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<OutputItemType>Content</OutputItemType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
37 changes: 37 additions & 0 deletions src/System.Runtime/tests/System/Activator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,43 @@ public static void TestCreateInstance_Generic_Invalid()
Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance<TypeWithDefaultCtorThatThrows>()); // Type has a default constructor that throws
}


class PrivateType
{
public PrivateType() { }
}

class PrivateTypeWithDefaultCtor
{
private PrivateTypeWithDefaultCtor() { }
}

class PrivateTypeWithoutDefaultCtor
{
private PrivateTypeWithoutDefaultCtor(int x) { }
}

class PrivateTypeWithDefaultCtorThatThrows
{
public PrivateTypeWithDefaultCtorThatThrows() { throw new Exception(); }
}

[Fact]
public static void TestCreateInstance_Type_Bool()
{
Assert.Equal(typeof(PrivateType), Activator.CreateInstance(typeof(PrivateType), true).GetType());
Assert.Equal(typeof(PrivateType), Activator.CreateInstance(typeof(PrivateType), false).GetType());

Assert.Equal(typeof(PrivateTypeWithDefaultCtor), Activator.CreateInstance(typeof(PrivateTypeWithDefaultCtor), true).GetType());
Assert.Throws<MissingMethodException>(() => Activator.CreateInstance(typeof(PrivateTypeWithDefaultCtor), false).GetType());

Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(typeof(PrivateTypeWithDefaultCtorThatThrows), true).GetType());
Assert.Throws<TargetInvocationException>(() => Activator.CreateInstance(typeof(PrivateTypeWithDefaultCtorThatThrows), false).GetType());

Assert.Throws<MissingMethodException>(() => Activator.CreateInstance(typeof(PrivateTypeWithoutDefaultCtor), true).GetType());
Assert.Throws<MissingMethodException>(() => Activator.CreateInstance(typeof(PrivateTypeWithoutDefaultCtor), false).GetType());
}

public class Choice1 : Attribute
{
public Choice1()
Expand Down
33 changes: 33 additions & 0 deletions src/System.Runtime/tests/System/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,37 @@ public static void TestGetTypeByNameInvalid(string typeName, Type expectedExcept

Assert.Throws(expectedException, () => Type.GetType(typeName, throwOnError: true, ignoreCase: false));
}

[Fact]
public static void Delimiter()
{
Assert.NotNull(Type.Delimiter);
}

[Theory]
[InlineData(typeof(bool), TypeCode.Boolean)]
[InlineData(typeof(byte), TypeCode.Byte)]
[InlineData(typeof(char), TypeCode.Char)]
[InlineData(typeof(DateTime), TypeCode.DateTime)]
[InlineData(typeof(decimal), TypeCode.Decimal)]
[InlineData(typeof(double), TypeCode.Double)]
[InlineData(null, TypeCode.Empty)]
[InlineData(typeof(short), TypeCode.Int16)]
[InlineData(typeof(int), TypeCode.Int32)]
[InlineData(typeof(long), TypeCode.Int64)]
[InlineData(typeof(object), TypeCode.Object)]
[InlineData(typeof(System.Nullable), TypeCode.Object)]
[InlineData(typeof(Nullable<int>), TypeCode.Object)]
[InlineData(typeof(Dictionary<,>), TypeCode.Object)]
[InlineData(typeof(Exception), TypeCode.Object)]
[InlineData(typeof(sbyte), TypeCode.SByte)]
[InlineData(typeof(float), TypeCode.Single)]
[InlineData(typeof(string), TypeCode.String)]
[InlineData(typeof(ushort), TypeCode.UInt16)]
[InlineData(typeof(uint), TypeCode.UInt32)]
[InlineData(typeof(ulong), TypeCode.UInt64)]
public static void GetTypeCode(Type t, TypeCode typeCode)
{
Assert.Equal(typeCode, Type.GetTypeCode(t));
}
}
1 change: 0 additions & 1 deletion src/System.Runtime/tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"System.Console": "4.0.0-rc3-23910",
"System.Globalization": "4.0.10",
"System.Reflection": "4.0.10",
"System.Runtime": "4.0.20",
"System.Runtime.Extensions": "4.0.10",
"System.Runtime.InteropServices": "4.0.20",
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-rc3-23910",
Expand Down