Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Expose ArgIterator (#33369)
Browse files Browse the repository at this point in the history
Expose ArgIterator

Adding IsArgIteratorSupported and IsArgIteratorNotSupported for tests

Asserts PNSE when not supported

Fixes: #32898
  • Loading branch information
maryamariyan committed Nov 12, 2018
1 parent fb3e288 commit e9d7a5f
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static partial class PlatformDetection
public static bool IsArmProcess { get { throw null; } }
public static bool IsArm64Process { get { throw null; } }
public static bool IsAlpine { get { throw null; } }
public static bool IsArgIteratorSupported { get { throw null; } }
public static bool IsCentos6 { get { throw null; } }
public static bool IsDebian { get { throw null; } }
public static bool IsDebian8 { get { throw null; } }
Expand All @@ -66,6 +67,7 @@ public static partial class PlatformDetection
public static bool IsNetNative { get { throw null; } }
public static bool IsNonZeroLowerBoundArraySupported { get { throw null; } }
public static bool IsNotIntMaxValueArrayIndexSupported { get { throw null; } }
public static bool IsArgIteratorNotSupported { get { throw null; } }
public static bool IsNotArmProcess { get { throw null; } }
public static bool IsNotArm64Process { get { throw null; } }
public static bool IsNotFedoraOrRedHatFamily { get { throw null; } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public static partial class PlatformDetection
public static bool IsNotArmProcess => !IsArmProcess;
public static bool IsArm64Process => RuntimeInformation.ProcessArchitecture == Architecture.Arm64;
public static bool IsNotArm64Process => !IsArm64Process;
public static bool IsArgIteratorSupported => IsWindows && (IsNotArmProcess || IsArm64Process);
public static bool IsArgIteratorNotSupported => !IsArgIteratorSupported;

public static bool IsNotInAppContainer => !IsInAppContainer;
public static bool IsWinRTSupported => IsWindows && !IsWindows7;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ MembersMustExist : Member 'System.Activator.CreateInstanceFrom(System.String, Sy
MembersMustExist : Member 'System.Activator.CreateInstanceFrom(System.String, System.String, System.Object[])' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.AppDomainManager' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.AppDomainSetup' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.ArgIterator' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.String.Split(System.Char)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.String.Split(System.String)' does not exist in the implementation but it does exist in the contract.
CannotMakeTypeAbstract : Type 'System.Diagnostics.Debugger' is abstract in the implementation but is not abstract in the contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ MembersMustExist : Member 'System.Activator.CreateInstanceFrom(System.String, Sy
MembersMustExist : Member 'System.Activator.CreateInstanceFrom(System.String, System.String, System.Object[])' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.AppDomainManager' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.AppDomainSetup' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.ArgIterator' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.String.Split(System.Char)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.String.Split(System.String)' does not exist in the implementation but it does exist in the contract.
CannotMakeTypeAbstract : Type 'System.Diagnostics.Debugger' is abstract in the implementation but is not abstract in the contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,13 @@ public static IEnumerable<object[]> GetUninitializedObject_ByRefLikeType_TestDat
{
yield return new object[] { typeof(TypedReference) };

// These types are stubs on .NET Native and thus not byref-like
if (!PlatformDetection.IsNetNative)
yield return new object[] { typeof(RuntimeArgumentHandle) };

// .NET Standard 2.0 doesn't have ArgIterator, but .NET Core 2.0 does
Type argIterator = typeof(object).Assembly.GetType("System.ArgIterator");
if (argIterator != null)
{
yield return new object[] { typeof(RuntimeArgumentHandle) };

// .NET Standard 2.0 doesn't have ArgIterator, but .NET Core 2.0 does
Type argIterator = typeof(object).Assembly.GetType("System.ArgIterator");
if (argIterator != null)
{
yield return new object[] { argIterator };
}
yield return new object[] { argIterator };
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ protected ApplicationException(System.Runtime.Serialization.SerializationInfo in
public ApplicationException(string message) { }
public ApplicationException(string message, System.Exception innerException) { }
}
public ref partial struct ArgIterator
{
private int _dummyPrimitive;
public ArgIterator(System.RuntimeArgumentHandle arglist) { throw null; }
[System.CLSCompliantAttribute(false)]
public unsafe ArgIterator(System.RuntimeArgumentHandle arglist, void* ptr) { throw null; }
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 System.RuntimeTypeHandle GetNextArgType() { throw null; }
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
public int GetRemainingCount() { throw null; }
}
public partial class ArgumentException : System.SystemException
{
public ArgumentException() { }
Expand Down
1 change: 1 addition & 0 deletions src/System.Runtime/src/ApiCompatBaseline.netcoreappaot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ MembersMustExist : Member 'System.String System.Runtime.CompilerServices.Runtime
TypeCannotChangeClassification : Type 'System.DateTimeOffset' is marked as readonly in the contract so it must also be marked readonly in the implementation.
TypeCannotChangeClassification : Type 'System.TimeSpan' is marked as readonly in the contract so it must also be marked readonly in the implementation.
TypeCannotChangeClassification : Type 'System.Runtime.Serialization.SerializationEntry' is marked as readonly in the contract so it must also be marked readonly in the implementation.
TypesMustExist : Type 'System.ArgIterator' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Index' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Range' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.ReadOnlySpan<T>.Item.get(System.Index)' does not exist in the implementation but it does exist in the contract.
Expand Down
1 change: 1 addition & 0 deletions src/System.Runtime/src/ApiCompatBaseline.uapaot.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TypesMustExist : Type 'System.ArgIterator' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Index' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.Range' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.ReadOnlySpan<T>.Item.get(System.Index)' does not exist in the implementation but it does exist in the contract.
Expand Down
1 change: 1 addition & 0 deletions src/System.Runtime/tests/System.Runtime.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
<Compile Include="System\Text\StringBuilderTests.netcoreapp.cs" />
<Compile Include="System\Type\TypePropertyTests.netcoreapp.cs" />
<Compile Include="System\Type\TypeTests.netcoreapp.cs" />
<Compile Include="System\ArgIteratorTests.netcoreapp.cs" />
<Compile Include="System\DoubleTests.netcoreapp.cs" />
<Compile Include="System\SingleTests.netcoreapp.cs" />
</ItemGroup>
Expand Down
32 changes: 32 additions & 0 deletions src/System.Runtime/tests/System/ArgIteratorTests.netcoreapp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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.Globalization;
using System.Reflection;
using Xunit;

namespace System.Tests
{
public static class ArgIteratorTests
{
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsArgIteratorNotSupported))]
public unsafe static void ArgIterator_Throws_PlatformNotSupportedException()
{
Assert.Throws<PlatformNotSupportedException>(() => new ArgIterator(new RuntimeArgumentHandle()));
Assert.Throws<PlatformNotSupportedException>(() => {
fixed (void* p = "test")
{
new ArgIterator(new RuntimeArgumentHandle(), p);
}
});
Assert.Throws<PlatformNotSupportedException>(() => new ArgIterator().End());
Assert.Throws<PlatformNotSupportedException>(() => new ArgIterator().Equals(new object()));
Assert.Throws<PlatformNotSupportedException>(() => new ArgIterator().GetHashCode());
Assert.Throws<PlatformNotSupportedException>(() => new ArgIterator().GetNextArg());
Assert.Throws<PlatformNotSupportedException>(() => new ArgIterator().GetNextArg(new RuntimeTypeHandle()));
Assert.Throws<PlatformNotSupportedException>(() => new ArgIterator().GetNextArgType());
Assert.Throws<PlatformNotSupportedException>(() => new ArgIterator().GetRemainingCount());
}
}
}
11 changes: 6 additions & 5 deletions src/System.Runtime/tests/System/Type/TypeTests.netcoreapp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,19 +218,20 @@ public static IEnumerable<object[]> IsByRefLikeTestData
{
Type theT = typeof(Outside<>).GetTypeInfo().GenericTypeParameters[0];

yield return new object[] { typeof(TypedReference), true };
yield return new object[] { typeof(ArgIterator), true };
yield return new object[] { typeof(ByRefLikeStruct), true };
yield return new object[] { typeof(RegularStruct), false };
yield return new object[] { typeof(RuntimeArgumentHandle), true };
yield return new object[] { typeof(Span<>), true };
yield return new object[] { typeof(Span<int>), true };
yield return new object[] { typeof(Span<>).MakeGenericType(theT), true };
yield return new object[] { typeof(ByRefLikeStruct), true };
yield return new object[] { typeof(RegularStruct), false };
yield return new object[] { typeof(object), false };
yield return new object[] { typeof(Span<int>), true };
yield return new object[] { typeof(Span<int>).MakeByRefType(), false };
yield return new object[] { typeof(Span<int>).MakePointerType(), false };
yield return new object[] { typeof(TypedReference), true };
yield return new object[] { theT, false };
yield return new object[] { typeof(int[]), false };
yield return new object[] { typeof(int[,]), false };
yield return new object[] { typeof(object), false };
if (PlatformDetection.IsWindows) // GetTypeFromCLSID is Windows only
{
yield return new object[] { Type.GetTypeFromCLSID(default(Guid)), false };
Expand Down
2 changes: 0 additions & 2 deletions src/shims/ApiCompatBaseline.netcoreapp.netfx461.ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2705,8 +2705,6 @@ TypesMustExist : Type 'System.ServiceProcess.ServiceInstaller' does not exist in
TypesMustExist : Type 'System.ServiceProcess.ServiceProcessDescriptionAttribute' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'System.ServiceProcess.ServiceProcessInstaller' does not exist in the implementation but it does exist in the contract.

// Not bringing back argiterator
TypesMustExist : Type 'System.ArgIterator' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Console.Write(System.String, System.Object, System.Object, System.Object, System.Object, __arglist)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.Console.WriteLine(System.String, System.Object, System.Object, System.Object, System.Object, __arglist)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'System.String.Concat(System.Object, System.Object, System.Object, System.Object, __arglist)' does not exist in the implementation but it does exist in the contract.
Expand Down

0 comments on commit e9d7a5f

Please sign in to comment.