Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 4d21b39

Browse files
author
Pallavi Taneja
committed
Expose Type.GetTypeCode() and Type.Delimiter
1 parent 74e8a63 commit 4d21b39

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

src/System.Runtime/ref/System.Runtime.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,7 @@ public abstract partial class Type
18831883
{
18841884
public static readonly System.Type[] EmptyTypes;
18851885
public static readonly object Missing;
1886+
public static readonly char Delimiter;
18861887
internal Type() { }
18871888
public abstract string AssemblyQualifiedName { get; }
18881889
public abstract string FullName { get; }
@@ -1906,6 +1907,7 @@ internal Type() { }
19061907
public static System.Type GetType(string typeName) { return default(System.Type); }
19071908
public static System.Type GetType(string typeName, bool throwOnError) { return default(System.Type); }
19081909
public static System.Type GetType(string typeName, bool throwOnError, bool ignoreCase) { return default(System.Type); }
1910+
public static System.TypeCode GetTypeCode(System.Type type) { return default(System.TypeCode); }
19091911
public static System.Type GetTypeFromHandle(System.RuntimeTypeHandle handle) { return default(System.Type); }
19101912
public abstract System.Type MakeArrayType();
19111913
public abstract System.Type MakeArrayType(int rank);

src/System.Runtime/tests/System.Runtime.Tests.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,17 @@
119119
</ItemGroup>
120120
<ItemGroup>
121121
<!-- Compile tests against the System.Runtime contract, but copy our local-built implementation for testing -->
122+
<ProjectReference Include="..\ref\System.Runtime.csproj">
123+
<Project>{446de6f0-47a0-4c2f-a918-768a76ccf461}</Project>
124+
<Name>System.Runtime</Name>
125+
<!-- Don't copy the reference assembly to output -->
126+
<Private>false</Private>
127+
<UndefineProperties>OSGroup</UndefineProperties>
128+
</ProjectReference>
122129
<ProjectReference Include="..\src\System.Runtime.csproj">
130+
<Project>{1e689c1b-690c-4799-bde9-6e7990585894}</Project>
131+
<Name>System.Runtime.CoreCLR</Name>
132+
<!-- Don't reference implementation assembly, but do deploy it. -->
123133
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
124134
<OutputItemType>Content</OutputItemType>
125135
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

src/System.Runtime/tests/System/Type.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,37 @@ public static void TestGetTypeByNameInvalid(string typeName, Type expectedExcept
254254

255255
Assert.Throws(expectedException, () => Type.GetType(typeName, throwOnError: true, ignoreCase: false));
256256
}
257+
258+
[Fact]
259+
public static void Delimiter()
260+
{
261+
Assert.NotNull(Type.Delimiter);
262+
}
263+
264+
[Theory]
265+
[InlineData(typeof(bool), TypeCode.Boolean)]
266+
[InlineData(typeof(byte), TypeCode.Byte)]
267+
[InlineData(typeof(char), TypeCode.Char)]
268+
[InlineData(typeof(DateTime), TypeCode.DateTime)]
269+
[InlineData(typeof(decimal), TypeCode.Decimal)]
270+
[InlineData(typeof(double), TypeCode.Double)]
271+
[InlineData(null, TypeCode.Empty)]
272+
[InlineData(typeof(short), TypeCode.Int16)]
273+
[InlineData(typeof(int), TypeCode.Int32)]
274+
[InlineData(typeof(long), TypeCode.Int64)]
275+
[InlineData(typeof(object), TypeCode.Object)]
276+
[InlineData(typeof(System.Nullable), TypeCode.Object)]
277+
[InlineData(typeof(Nullable<int>), TypeCode.Object)]
278+
[InlineData(typeof(Dictionary<,>), TypeCode.Object)]
279+
[InlineData(typeof(Exception), TypeCode.Object)]
280+
[InlineData(typeof(sbyte), TypeCode.SByte)]
281+
[InlineData(typeof(float), TypeCode.Single)]
282+
[InlineData(typeof(string), TypeCode.String)]
283+
[InlineData(typeof(ushort), TypeCode.UInt16)]
284+
[InlineData(typeof(uint), TypeCode.UInt32)]
285+
[InlineData(typeof(ulong), TypeCode.UInt64)]
286+
public static void GetTypeCode(Type t, TypeCode typeCode)
287+
{
288+
Assert.Equal(typeCode, Type.GetTypeCode(t));
289+
}
257290
}

src/System.Runtime/tests/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"System.Console": "4.0.0-rc3-23910",
66
"System.Globalization": "4.0.10",
77
"System.Reflection": "4.0.10",
8-
"System.Runtime": "4.0.20",
98
"System.Runtime.Extensions": "4.0.10",
109
"System.Runtime.InteropServices": "4.0.20",
1110
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-rc3-23910",

0 commit comments

Comments
 (0)