src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs
/// <summary>
/// Overrides from IntPtr and UIntPtr are implicitly included on nint and nuint.
/// </summary>
Overrides from IntPtr and UIntPtr are implicitly included on nint and nuint.
Overrides from IntPtr and UIntPtr are implicitly included on nint and nuint .
[Theory]
        [InlineData(false)]
        [InlineData(true)]
        public void OverriddenMembers(bool useCompilationReference)
        {
            var sourceA =
@"namespace System
{
    public class Object
    {
        public virtual string ToString() => null;
        public virtual int GetHashCode() => 0;
        public virtual bool Equals(object obj) => false;
    }
    public class String { }
    public abstract class ValueType
    {
        public override string ToString() => null;
        public override int GetHashCode() => 0;
        public override bool Equals(object obj) => false;
    }
    public struct Void { }
    public struct Boolean { }
    public struct Int32 { }
    public struct IntPtr
    {
        public override string ToString() => null;
        public override int GetHashCode() => 0;
        public override bool Equals(object obj) => false;
    }
    public struct UIntPtr
    {
        public override string ToString() => null;
        public override int GetHashCode() => 0;
        public override bool Equals(object obj) => false;
    }
}";
            var comp = CreateEmptyCompilation(sourceA);
            comp.VerifyDiagnostics();
            var refA = AsReference(comp, useCompilationReference);
            var sourceB =
@"class Program
{
    static void F1(nint x, nint y)
    {
        _ = x.ToString();
        _ = x.GetHashCode();
        _ = x.Equals(y);
    }
    static void F2(nuint x, nuint y)
    {
        _ = x.ToString();
        _ = x.GetHashCode();
        _ = x.Equals(y);
    }
}";
            comp = CreateEmptyCompilation(sourceB, references: new[] { refA }, parseOptions: TestOptions.RegularPreview);
            comp.VerifyDiagnostics();
            verifyType((NamedTypeSymbol)comp.GetMember<MethodSymbol>("Program.F1").Parameters[0].Type, signed: true);
            verifyType((NamedTypeSymbol)comp.GetMember<MethodSymbol>("Program.F2").Parameters[0].Type, signed: false);
            static void verifyType(NamedTypeSymbol type, bool signed)
            {
                Assert.True(type.IsNativeIntegerType);
                VerifyType(type, signed: signed, isNativeInt: true);
                VerifyType(type.GetPublicSymbol(), signed: signed, isNativeInt: true);
                var members = type.GetMembers().Sort(SymbolComparison);
                var actualMembers = members.SelectAsArray(m => m.ToTestDisplayString());
                var expectedMembers = new[]
                {
                    $"System.Boolean {type}.Equals(System.Object obj)",
                    $"System.Int32 {type}.GetHashCode()",
                    $"System.String {type}.ToString()",
                    $"{type}..ctor()",
                };
                AssertEx.Equal(expectedMembers, actualMembers);
                var underlyingType = type.NativeIntegerUnderlyingType;
                VerifyMembers(underlyingType, type, signed);
                VerifyMembers(underlyingType.GetPublicSymbol(), type.GetPublicSymbol(), signed);
            }
        }
[ Theory ] [ InlineData ( false ) ] [ InlineData ( true ) ] public void OverriddenMembers ( bool useCompilationReference ) { var sourceA = @"namespace System
{
    public class Object
    {
        public virtual string ToString() => null;
        public virtual int GetHashCode() => 0;
        public virtual bool Equals(object obj) => false;
    }
    public class String { }
    public abstract class ValueType
    {
        public override string ToString() => null;
        public override int GetHashCode() => 0;
        public override bool Equals(object obj) => false;
    }
    public struct Void { }
    public struct Boolean { }
    public struct Int32 { }
    public struct IntPtr
    {
        public override string ToString() => null;
        public override int GetHashCode() => 0;
        public override bool Equals(object obj) => false;
    }
    public struct UIntPtr
    {
        public override string ToString() => null;
        public override int GetHashCode() => 0;
        public override bool Equals(object obj) => false;
    }
}" ; var comp = CreateEmptyCompilation ( sourceA ) ; comp . VerifyDiagnostics ( ) ; var refA = AsReference ( comp , useCompilationReference ) ; var sourceB = @"class Program
{
    static void F1(nint x, nint y)
    {
        _ = x.ToString();
        _ = x.GetHashCode();
        _ = x.Equals(y);
    }
    static void F2(nuint x, nuint y)
    {
        _ = x.ToString();
        _ = x.GetHashCode();
        _ = x.Equals(y);
    }
}" ; comp = CreateEmptyCompilation ( sourceB , references : new [ ] { refA } , parseOptions : TestOptions . RegularPreview ) ; comp . VerifyDiagnostics ( ) ; verifyType ( ( NamedTypeSymbol ) comp . GetMember < MethodSymbol > ( " " ) . Parameters [ 0 ] . Type , signed : true ) ; verifyType ( ( NamedTypeSymbol ) comp . GetMember < MethodSymbol > ( " " ) . Parameters [ 0 ] . Type , signed : false ) ; static void verifyType ( NamedTypeSymbol type , bool signed ) { Assert . True ( type . IsNativeIntegerType ) ; VerifyType ( type , signed : signed , isNativeInt : true ) ; VerifyType ( type . GetPublicSymbol ( ) , signed : signed , isNativeInt : true ) ; var members = type . GetMembers ( ) . Sort ( SymbolComparison ) ; var actualMembers = members . SelectAsArray ( m => m . ToTestDisplayString ( ) ) ; var expectedMembers = new [ ] { $" System.Boolean  { type } .Equals(System.Object obj) " , $" System.Int32  { type } .GetHashCode() " , $" System.String  { type } .ToString() " , $" { type } ..ctor() " , } ; AssertEx . Equal ( expectedMembers , actualMembers ) ; var underlyingType = type . NativeIntegerUnderlyingType ; VerifyMembers ( underlyingType , type , signed ) ; VerifyMembers ( underlyingType . GetPublicSymbol ( ) , type . GetPublicSymbol ( ) , signed ) ; } }
Overrides from IntPtr and UIntPtr are implicitly included on nint and nuint.
Overrides from IntPtr and UIntPtr are implicitly included on nint and nuint .
useCompilationReference
bool