Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSantiago Fernandez Madero <safern@microsoft.com>2017-02-03 19:26:07 +0300
committerTarek Mahmoud Sayed <tarekms@microsoft.com>2017-02-03 19:26:07 +0300
commit2ac9efa1502c84a63895d74ea7f908239e431592 (patch)
tree9e0ea9d22533e514478183a336dd5d48372a4cbb /src/System.Runtime
parent25e22d1bd66951f08f83f58ea7adb24987c2b404 (diff)
Adding missing apis to .NET Core that where added to netstandard 2.0 (#15643)
* IntialCommit * Delete argiterator tests * Tests for TypedReference APIs and FieldInfo * baselines
Diffstat (limited to 'src/System.Runtime')
-rw-r--r--src/System.Runtime/ref/System.Runtime.cs46
-rw-r--r--src/System.Runtime/tests/System.Runtime.Tests.csproj1
-rw-r--r--src/System.Runtime/tests/System/TypedReferenceTests.cs111
3 files changed, 154 insertions, 4 deletions
diff --git a/src/System.Runtime/ref/System.Runtime.cs b/src/System.Runtime/ref/System.Runtime.cs
index ede8684aa5..45a9334987 100644
--- a/src/System.Runtime/ref/System.Runtime.cs
+++ b/src/System.Runtime/ref/System.Runtime.cs
@@ -165,6 +165,22 @@ namespace System
public void Handle(System.Func<System.Exception, bool> predicate) { }
public override string ToString() { throw null; }
}
+ [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
+ public partial struct ArgIterator
+ {
+ public ArgIterator(System.RuntimeArgumentHandle arglist) { }
+ [System.CLSCompliantAttribute(false)]
+ public unsafe ArgIterator(System.RuntimeArgumentHandle arglist, void *ptr) { }
+ public void End() { }
+ public override bool Equals(Object o) { throw null; }
+ public override int GetHashCode() { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public System.TypedReference GetNextArg() { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public System.TypedReference GetNextArg(System.RuntimeTypeHandle rth) { throw null; }
+ public unsafe System.RuntimeTypeHandle GetNextArgType() { throw null; }
+ public int GetRemainingCount() { throw null; }
+ }
public partial class ArgumentException : System.SystemException, System.Runtime.Serialization.ISerializable
{
public ArgumentException() { }
@@ -1479,8 +1495,7 @@ namespace System
public static bool TryParse(string s, out long result) { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
- public partial struct IntPtr : System.Runtime.Serialization.ISerializable
-, IEquatable<IntPtr>
+ public partial struct IntPtr : System.Runtime.Serialization.ISerializable, IEquatable<IntPtr>
{
public static readonly System.IntPtr Zero;
public IntPtr(int value) { throw null; }
@@ -1803,6 +1818,10 @@ namespace System
public System.Reflection.Assembly RequestingAssembly { get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
+ public partial struct RuntimeArgumentHandle
+ {
+ }
+ [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct RuntimeFieldHandle : System.Runtime.Serialization.ISerializable
{
public override bool Equals(object obj) { throw null; }
@@ -1983,6 +2002,8 @@ namespace System
public static string Concat(string str0, string str1) { throw null; }
public static string Concat(string str0, string str1, string str2) { throw null; }
public static string Concat(string str0, string str1, string str2, string str3) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static string Concat(object arg0, object arg1, object arg2, object arg3, __arglist) { throw null; }
public static string Concat(params string[] values) { throw null; }
public static string Concat<T>(System.Collections.Generic.IEnumerable<T> values) { throw null; }
public bool Contains(string value) { throw null; }
@@ -2741,6 +2762,20 @@ namespace System
UInt32 = 10,
UInt64 = 12,
}
+ [System.CLSCompliantAttribute(false)]
+ [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
+ public partial struct TypedReference
+ {
+ public override bool Equals(Object o) { throw null; }
+ public override int GetHashCode() { throw null; }
+ public static System.Type GetTargetType(TypedReference value) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public static System.TypedReference MakeTypedReference(object target, System.Reflection.FieldInfo[] flds) { throw null; }
+ [System.CLSCompliantAttribute(false)]
+ public unsafe static void SetTypedReference(System.TypedReference target, object value) { }
+ public static System.RuntimeTypeHandle TargetTypeToken(System.TypedReference value) { throw null; }
+ public unsafe static object ToObject(System.TypedReference value) { throw null; }
+ }
public sealed partial class TypeInitializationException : System.SystemException
{
public TypeInitializationException(string fullTypeName, System.Exception innerException) { }
@@ -2898,8 +2933,7 @@ namespace System
}
[System.CLSCompliantAttribute(false)]
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
- public partial struct UIntPtr : System.Runtime.Serialization.ISerializable
-, IEquatable<UIntPtr>
+ public partial struct UIntPtr : System.Runtime.Serialization.ISerializable, IEquatable<UIntPtr>
{
public static readonly System.UIntPtr Zero;
public UIntPtr(uint value) { throw null; }
@@ -5499,9 +5533,13 @@ namespace System.Reflection
public virtual object GetRawConstantValue() { throw null; }
public virtual Type[] GetRequiredCustomModifiers() { throw null; }
public abstract object GetValue(object obj);
+ [System.CLSCompliantAttribute(false)]
+ public virtual object GetValueDirect(System.TypedReference obj) { throw null; }
public override MemberTypes MemberType { get { throw null; } }
public void SetValue(object obj, object value) { }
public abstract void SetValue(object obj, object value, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture);
+ [System.CLSCompliantAttribute(false)]
+ public virtual void SetValueDirect(System.TypedReference obj, object value) { }
}
[System.FlagsAttribute]
public enum GenericParameterAttributes
diff --git a/src/System.Runtime/tests/System.Runtime.Tests.csproj b/src/System.Runtime/tests/System.Runtime.Tests.csproj
index 985ad87c5f..875bdf00af 100644
--- a/src/System.Runtime/tests/System.Runtime.Tests.csproj
+++ b/src/System.Runtime/tests/System.Runtime.Tests.csproj
@@ -130,6 +130,7 @@
<Compile Include="System\Runtime\CompilerServices\ConditionalWeakTableTests.netcoreapp.cs" />
<Compile Include="System\UIntPtrTests.netcoreapp.cs" />
<Compile Include="System\ComponentModel\DefaultValueAttributeTests.netcoreapp.cs" />
+ <Compile Include="System\TypedReferenceTests.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netcoreapp'">
<Compile Include="System\StringSplitExtensions.cs" />
diff --git a/src/System.Runtime/tests/System/TypedReferenceTests.cs b/src/System.Runtime/tests/System/TypedReferenceTests.cs
new file mode 100644
index 0000000000..aed792059c
--- /dev/null
+++ b/src/System.Runtime/tests/System/TypedReferenceTests.cs
@@ -0,0 +1,111 @@
+//
+// TypedReferenceTest.cs
+//
+// Authors:
+// Marek Safar <marek.safar@gmail.com>
+//
+// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Licensed to the .NET Foundation under one or more agreements.
+// See the LICENSE file in the project root for more information.
+
+using System.Collections.Generic;
+using System.Reflection;
+using Xunit;
+
+namespace System.Tests
+{
+ public static class TypedReferenceTests
+ {
+ struct OneStruct
+ {
+ public string field;
+ public int b;
+ }
+
+ class OtherType
+ {
+ public OneStruct oneStruct;
+ }
+
+ [Fact]
+ public static void NegativeMakeTypedReference()
+ {
+ OtherType data = new OtherType { oneStruct = new OneStruct { field = "field", b = 2343 } };
+ Type dataType = data.GetType();
+ Assert.Throws<ArgumentNullException>(() => { TypedReference.MakeTypedReference(null, dataType.GetFields()); });
+ Assert.Throws<ArgumentNullException>(() => { TypedReference.MakeTypedReference(data, null); });
+ Assert.Throws<ArgumentException>(() => { TypedReference.MakeTypedReference(data, Array.Empty<FieldInfo>()); });
+ Assert.Throws<ArgumentException>(() => { TypedReference.MakeTypedReference(data, new FieldInfo[] { dataType.GetField("oneStruct"), null }); });
+ Assert.Throws<ArgumentException>(() => { TypedReference.MakeTypedReference(data, new FieldInfo[] { dataType.GetField("oneStruct"), typeof(OneStruct).GetField("b") }); });
+ }
+
+ [Fact]
+ public static void MakeTypedReference_ToObjectTests()
+ {
+ OneStruct structObj = new OneStruct { field = "field", b = 2343 };
+ OtherType data = new OtherType { oneStruct = structObj };
+ Type dataType = data.GetType();
+ TypedReference reference = TypedReference.MakeTypedReference(data, new FieldInfo[] { dataType.GetField("oneStruct"), typeof(OneStruct).GetField("field") });
+ Assert.Equal("field", TypedReference.ToObject(reference));
+
+ reference = TypedReference.MakeTypedReference(data, new FieldInfo[] { dataType.GetField("oneStruct") });
+ Assert.Equal(structObj, TypedReference.ToObject(reference));
+ }
+
+ [Fact]
+ public static void GetTargetTypeTests()
+ {
+ int intValue = 13223;
+ TypedReference reference = __makeref(intValue);
+ Assert.Equal(intValue.GetType(), TypedReference.GetTargetType(reference));
+
+ long lValue = long.MaxValue;
+ reference = __makeref(lValue);
+ Assert.Equal(lValue.GetType(), TypedReference.GetTargetType(reference));
+
+ string strValue = "a value";
+ reference = __makeref(strValue);
+ Assert.Equal(strValue.GetType(), TypedReference.GetTargetType(reference));
+
+ char charValue = 'A';
+ reference = __makeref(charValue);
+ Assert.Equal(charValue.GetType(), TypedReference.GetTargetType(reference));
+
+ byte byteValue = byte.MaxValue;
+ reference = __makeref(byteValue);
+ Assert.Equal(byteValue.GetType(), TypedReference.GetTargetType(reference));
+
+ double doubleValue = double.MaxValue;
+ reference = __makeref(doubleValue);
+ Assert.Equal(doubleValue.GetType(), TypedReference.GetTargetType(reference));
+
+ float floatValue = float.MaxValue;
+ reference = __makeref(floatValue);
+ Assert.Equal(floatValue.GetType(), TypedReference.GetTargetType(reference));
+
+ bool boolValue = true;
+ reference = __makeref(boolValue);
+ Assert.Equal(boolValue.GetType(), TypedReference.GetTargetType(reference));
+ }
+ }
+}