From 18efe1d2c24a666b4e06dae46e136ce88e4257c1 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 24 Jan 2022 14:05:09 -0800 Subject: [PATCH 1/9] Expand System.Runtime.InteropServices.NFloat to support the APIs required by Xamarin --- .../src/Resources/Strings.resx | 3 + .../System/Runtime/InteropServices/NFloat.cs | 700 +++++++++++++++++- .../ref/System.Runtime.InteropServices.cs | 112 ++- 3 files changed, 767 insertions(+), 48 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index c651da612d53c4..cb95472d7f96d3 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -528,6 +528,9 @@ Type passed must be an interface. + + Object must be of type NFloat. + Type must be a Pointer. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs index e3cb842f2a5294..571e90d3e9f118 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs @@ -2,7 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; +using Internal.Runtime.CompilerServices; #pragma warning disable SA1121 // We use our own aliases since they differ per platform #if TARGET_32BIT @@ -13,65 +17,691 @@ namespace System.Runtime.InteropServices { - /// - /// is an immutable value type that represents a floating type that has the same size - /// as the native integer size. - /// It is meant to be used as an exchange type at the managed/unmanaged boundary to accurately represent - /// in managed code unmanaged APIs that use a type alias for C or C++'s float on 32-bit platforms - /// or double on 64-bit platforms, such as the CGFloat type in libraries provided by Apple. - /// + /// Defines an immutable value type that represents a floating type that has the same size as the native integer size. + /// It is meant to be used as an exchange type at the managed/unmanaged boundary to accurately represent in managed code unmanaged APIs that use a type alias for C or C++'s float on 32-bit platforms or double on 64-bit platforms, such as the CGFloat type in libraries provided by Apple. [Intrinsic] - public readonly struct NFloat : IEquatable + public readonly struct NFloat + : IComparable, + IComparable, + IEquatable, + ISpanFormattable { + private const NumberStyles DefaultNumberStyles = NumberStyles.Float | NumberStyles.AllowThousands; + private readonly NativeType _value; - /// - /// Constructs an instance from a 32-bit floating point value. - /// - /// The floating-point vaule. + /// Constructs an instance from a 32-bit floating point value. + /// The floating-point value. + [NonVersionable] public NFloat(float value) { _value = value; } - /// - /// Constructs an instance from a 64-bit floating point value. - /// - /// The floating-point vaule. + /// Constructs an instance from a 64-bit floating point value. + /// The floating-point value. + [NonVersionable] public NFloat(double value) { _value = (NativeType)value; } - /// - /// The underlying floating-point value of this instance. - /// - public double Value => _value; + /// Represents the smallest positive NFloat value that is greater than zero. + public static NFloat Epsilon + { + [NonVersionable] + get => new NFloat(NativeType.Epsilon); + } + + /// Represents the largest finite value of a NFloat. + public static NFloat MaxValue + { + [NonVersionable] + get => new NFloat(NativeType.MaxValue); + } + + /// Represents the smallest finite value of a NFloat. + public static NFloat MinValue + { + [NonVersionable] + get => new NFloat(NativeType.MinValue); + } + + /// Represents a value that is not a number (NaN). + public static NFloat NaN + { + [NonVersionable] + get => new NFloat(NativeType.NaN); + } + + /// Represents negative infinity. + public static NFloat NegativeInfinity + { + [NonVersionable] + get => new NFloat(NativeType.NegativeInfinity); + } + + /// Represents positive infinity. + public static NFloat PositiveInfinity + { + [NonVersionable] + get => new NFloat(NativeType.PositiveInfinity); + } + + /// Gets the size, in bytes, of an NFloat. + public static int Size + { + [NonVersionable] + get => sizeof(NativeType); + } + + /// The underlying floating-point value of this instance. + public double Value + { + [NonVersionable] + get => _value; + } + + // + // Unary Arithmetic + // + + /// Computes the unary plus of a value. + /// The value for which to compute its unary plus. + /// The unary plus of . + [NonVersionable] + public static NFloat operator +(NFloat value) => value; + + /// Computes the unary negation of a value. + /// The value for which to compute its unary negation. + /// The unary negation of . + [NonVersionable] + public static NFloat operator -(NFloat value) => new NFloat(-value._value); + + /// Increments a value. + /// The value to increment. + /// The result of incrementing . + [NonVersionable] + public static NFloat operator ++(NFloat value) => new NFloat(value._value + 1); + + /// Decrements a value. + /// The value to decrement. + /// The result of decrementing . + [NonVersionable] + public static NFloat operator --(NFloat value) => new NFloat(value._value - 1); + + // + // Binary Arithmetic + // + + /// Adds two values together to compute their sum. + /// The value to which is added. + /// The value which is added to . + /// The sum of and . + [NonVersionable] + public static NFloat operator +(NFloat left, NFloat right) => new NFloat(left._value + right._value); + + /// Subtracts two values to compute their difference. + /// The value from which is subtracted. + /// The value which is subtracted from . + /// The difference of subtracted from . + [NonVersionable] + public static NFloat operator -(NFloat left, NFloat right) => new NFloat(left._value - right._value); + + /// Multiplies two values together to compute their product. + /// The value which multiplies. + /// The value which multiplies . + /// The product of divided-by . + [NonVersionable] + public static NFloat operator *(NFloat left, NFloat right) => new NFloat(left._value * right._value); + + /// Divides two values together to compute their quotient. + /// The value which divides. + /// The value which divides . + /// The quotient of divided-by . + [NonVersionable] + public static NFloat operator /(NFloat left, NFloat right) => new NFloat(left._value / right._value); + + /// Divides two values together to compute their remainder. + /// The value which divides. + /// The value which divides . + /// The remainder of divided-by . + [NonVersionable] + public static NFloat operator %(NFloat left, NFloat right) => new NFloat(left._value % right._value); + + // + // Comparisons + // + + /// Compares two values to determine equality. + /// The value to compare with . + /// The value to compare with . + /// true if is equal to ; otherwise, false. + [NonVersionable] + public static bool operator ==(NFloat left, NFloat right) => left._value == right._value; + + /// Compares two values to determine inequality. + /// The value to compare with . + /// The value to compare with . + /// true if is not equal to ; otherwise, false. + [NonVersionable] + public static bool operator !=(NFloat left, NFloat right) => left._value != right._value; + + /// Compares two values to determine which is less. + /// The value to compare with . + /// The value to compare with . + /// true if is less than ; otherwise, false. + [NonVersionable] + public static bool operator <(NFloat left, NFloat right) => left._value < right._value; + + /// Compares two values to determine which is less or equal. + /// The value to compare with . + /// The value to compare with . + /// true if is less than or equal to ; otherwise, false. + [NonVersionable] + public static bool operator <=(NFloat left, NFloat right) => left._value >= right._value; + + /// Compares two values to determine which is greater. + /// The value to compare with . + /// The value to compare with . + /// true if is greater than ; otherwise, false. + [NonVersionable] + public static bool operator >(NFloat left, NFloat right) => left._value > right._value; + + /// Compares two values to determine which is greater or equal. + /// The value to compare with . + /// The value to compare with . + /// true if is greater than or equal to ; otherwise, false. + [NonVersionable] + public static bool operator >=(NFloat left, NFloat right) => left._value <= right._value; + + // + // Explicit Convert To NFloat + // + + /// Explicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static explicit operator NFloat(decimal value) => new NFloat((NativeType)value); + + /// Explicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static explicit operator NFloat(double value) => new NFloat((NativeType)value); + + // + // Explicit Convert From NFloat + // + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + public static explicit operator byte(NFloat value) => (byte)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + public static explicit operator char(NFloat value) => (char)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + public static explicit operator decimal(NFloat value) => (decimal)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + public static explicit operator short(NFloat value) => (short)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + public static explicit operator int(NFloat value) => (int)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + public static explicit operator long(NFloat value) => (long)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + public static explicit operator nint(NFloat value) => (nint)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + [CLSCompliant(false)] + public static explicit operator sbyte(NFloat value) => (sbyte)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + public static explicit operator float(NFloat value) => (float)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + [CLSCompliant(false)] + public static explicit operator ushort(NFloat value) => (ushort)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + [CLSCompliant(false)] + public static explicit operator uint(NFloat value) => (uint)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + [CLSCompliant(false)] + public static explicit operator ulong(NFloat value) => (ulong)(value._value); + + /// Explicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + [NonVersionable] + [CLSCompliant(false)] + public static explicit operator nuint(NFloat value) => (nuint)(value._value); + + // + // Implicit Convert To NFloat + // - /// - /// Returns a value indicating whether this instance is equal to a specified object. - /// - /// An object to compare with this instance. - /// true if is an instance of and equals the value of this instance; otherwise, false. - public override bool Equals([NotNullWhen(true)] object? o) => o is NFloat other && Equals(other); + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static implicit operator NFloat(byte value) => new NFloat((NativeType)value); - /// - /// Returns a value indicating whether this instance is equal to a specified value. - /// + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static implicit operator NFloat(char value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static implicit operator NFloat(short value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static implicit operator NFloat(int value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static implicit operator NFloat(long value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static implicit operator NFloat(nint value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + [CLSCompliant(false)] + public static implicit operator NFloat(sbyte value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + public static implicit operator NFloat(float value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + [CLSCompliant(false)] + public static implicit operator NFloat(ushort value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + [CLSCompliant(false)] + public static implicit operator NFloat(uint value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + [CLSCompliant(false)] + public static implicit operator NFloat(ulong value) => new NFloat((NativeType)value); + + /// Implicitly converts a value to its nearest representable native-sized floating-point value. + /// The value to convert. + /// converted to its nearest representable native-sized floating-point value. + [NonVersionable] + [CLSCompliant(false)] + public static implicit operator NFloat(nuint value) => new NFloat((NativeType)value); + + // + // Implicit Convert From NFloat + // + + /// Implicitly converts a native-sized floating-point value to its nearest representable value. + /// The value to convert. + /// converted to its nearest representable value. + public static implicit operator double(NFloat value) => (double)(value._value); + + /// Determines whether the specified value is finite (zero, subnormal, or normal). + /// The floating-point value. + /// true if the value is finite (zero, subnormal or normal); false otherwise. + [NonVersionable] + public static bool IsFinite(NFloat value) => NativeType.IsFinite(value._value); + + /// Determines whether the specified value is infinite (positive or negative infinity). + /// The floating-point value. + /// true if the value is infinite (positive or negative infinity); false otherwise. + [NonVersionable] + public static bool IsInfinity(NFloat value) => NativeType.IsInfinity(value._value); + + /// Determines whether the specified value is NaN (not a number). + /// The floating-point value. + /// true if the value is NaN (not a number); false otherwise. + [NonVersionable] + public static bool IsNaN(NFloat value) => NativeType.IsNaN(value._value); + + /// Determines whether the specified value is negative. + /// The floating-point value. + /// true if the value is negative; false otherwise. + [NonVersionable] + public static bool IsNegative(NFloat value) => NativeType.IsNegative(value._value); + + /// Determines whether the specified value is negative infinity. + /// The floating-point value. + /// true if the value is negative infinity; false otherwise. + [NonVersionable] + public static bool IsNegativeInfinity(NFloat value) => NativeType.IsNegativeInfinity(value._value); + + /// Determines whether the specified value is normal. + /// The floating-point value. + /// true if the value is normal; false otherwise. + [NonVersionable] + public static bool IsNormal(NFloat value) => NativeType.IsNormal(value._value); + + /// Determines whether the specified value is positive infinity. + /// The floating-point value. + /// true if the value is positive infinity; false otherwise. + [NonVersionable] + public static bool IsPositiveInfinity(NFloat value) => NativeType.IsPositiveInfinity(value._value); + + /// Determines whether the specified value is subnormal. + /// The floating-point value. + /// true if the value is subnormal; false otherwise. + [NonVersionable] + public static bool IsSubnormal(NFloat value) => NativeType.IsSubnormal(value._value); + + /// Converts the string representation of a number to its floating-point number equivalent. + /// A string that contains the number to convert. + /// A floating-point number that is equivalent to the numeric value or symbol specified in . + /// is null. + /// does not represent a number in a valid format. + public static NFloat Parse(string s) + { + var result = NativeType.Parse(s); + return new NFloat(result); + } + + /// Converts the string representation of a number in a specified style to its floating-point number equivalent. + /// A string that contains the number to convert. + /// A bitwise combination of enumeration values that indicate the style elements that can be present in . + /// A floating-point number that is equivalent to the numeric value or symbol specified in . + /// + /// is not a value. + /// -or- + /// includes the value. + /// + /// is null. + /// does not represent a number in a valid format. + public static NFloat Parse(string s, NumberStyles style) + { + var result = NativeType.Parse(s, style); + return new NFloat(result); + } + + /// Converts the string representation of a number in a specified culture-specific format to its floating-point number equivalent. + /// A string that contains the number to convert. + /// An object that supplies culture-specific formatting information about . + /// A floating-point number that is equivalent to the numeric value or symbol specified in . + /// is null. + /// does not represent a number in a valid format. + public static NFloat Parse(string s, IFormatProvider? provider) + { + var result = NativeType.Parse(s, provider); + return new NFloat(result); + } + + /// Converts the string representation of a number in a specified style and culture-specific format to its floating-point number equivalent. + /// A string that contains the number to convert. + /// A bitwise combination of enumeration values that indicate the style elements that can be present in . + /// An object that supplies culture-specific formatting information about . + /// A floating-point number that is equivalent to the numeric value or symbol specified in . + /// + /// is not a value. + /// -or- + /// includes the value. + /// + /// is null. + /// does not represent a number in a valid format. + public static NFloat Parse(string s, NumberStyles style, IFormatProvider? provider) + { + var result = NativeType.Parse(s, style, provider); + return new NFloat(result); + } + + /// Converts a character span that contains the string representation of a number in a specified style and culture-specific format to its floating-point number equivalent. + /// A character span that contains the number to convert. + /// A bitwise combination of enumeration values that indicate the style elements that can be present in . + /// An object that supplies culture-specific formatting information about . + /// A floating-point number that is equivalent to the numeric value or symbol specified in . + /// + /// is not a value. + /// -or- + /// includes the value. + /// + /// does not represent a number in a valid format. + public static NFloat Parse(ReadOnlySpan s, NumberStyles style = DefaultNumberStyles, IFormatProvider? provider = null) + { + var result = NativeType.Parse(s, style, provider); + return new NFloat(result); + } + + /// Tries to convert the string representation of a number to its floating-point number equivalent. + /// A read-only character span that contains the number to convert. + /// When this method returns, contains a floating-point number equivalent of the numeric value or symbol contained in if the conversion succeeded or zero if the conversion failed. The conversion fails if the is null, , or is not in a valid format. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// true if was converted successfully; otherwise, false. + public static bool TryParse([NotNullWhen(true)] string? s, out NFloat result) + { + Unsafe.SkipInit(out result); + return NativeType.TryParse(s, out Unsafe.As(ref result)); + } + + /// Tries to convert a character span containing the string representation of a number to its floating-point number equivalent. + /// A read-only character span that contains the number to convert. + /// When this method returns, contains a floating-point number equivalent of the numeric value or symbol contained in if the conversion succeeded or zero if the conversion failed. The conversion fails if the is or is not in a valid format. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// true if was converted successfully; otherwise, false. + public static bool TryParse(ReadOnlySpan s, out NFloat result) + { + Unsafe.SkipInit(out result); + return NativeType.TryParse(s, out Unsafe.As(ref result)); + } + + /// Tries to convert the string representation of a number in a specified style and culture-specific format to its floating-point number equivalent. + /// A read-only character span that contains the number to convert. + /// A bitwise combination of enumeration values that indicate the style elements that can be present in . + /// An object that supplies culture-specific formatting information about . + /// When this method returns, contains a floating-point number equivalent of the numeric value or symbol contained in if the conversion succeeded or zero if the conversion failed. The conversion fails if the is null, , or is not in a format compliant with , or if is not a valid combination of enumeration constants. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// true if was converted successfully; otherwise, false. + /// + /// is not a value. + /// -or- + /// includes the value. + /// + public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out NFloat result) + { + Unsafe.SkipInit(out result); + return NativeType.TryParse(s, style, provider, out Unsafe.As(ref result)); + } + + /// Tries to convert a character span containing the string representation of a number in a specified style and culture-specific format to its floating-point number equivalent. + /// A read-only character span that contains the number to convert. + /// A bitwise combination of enumeration values that indicate the style elements that can be present in . + /// An object that supplies culture-specific formatting information about . + /// When this method returns, contains a floating-point number equivalent of the numeric value or symbol contained in if the conversion succeeded or zero if the conversion failed. The conversion fails if the is or is not in a format compliant with , or if is not a valid combination of enumeration constants. This parameter is passed uninitialized; any value originally supplied in result will be overwritten. + /// true if was converted successfully; otherwise, false. + /// + /// is not a value. + /// -or- + /// includes the value. + /// + public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatProvider? provider, out NFloat result) + { + Unsafe.SkipInit(out result); + return NativeType.TryParse(s, style, provider, out Unsafe.As(ref result)); + } + + /// Compares this instance to a specified object and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object. + /// An object to compare, or null. + /// + /// A signed number indicating the relative values of this instance and . + /// + /// + /// Return Value + /// Description + /// + /// + /// Less than zero + /// This instance is less than , or this instance is not a number and is a number. + /// + /// + /// Zero + /// This instance is equal to , or both this instance and are not a number. + /// + /// + /// Greater than zero + /// This instance is greater than , or this instance is a number and is not a number or is null. + /// + /// + /// + /// is not a . + public int CompareTo(object? obj) + { + if (obj is NFloat other) + { + if (_value < other._value) return -1; + if (_value > other._value) return 1; + if (_value == other._value) return 0; + + // At least one of the values is NaN. + if (NativeType.IsNaN(_value)) + { + return NativeType.IsNaN(other._value) ? 0 : -1; + } + else + { + return 1; + } + } + else if (obj is null) + { + return 1; + } + + throw new ArgumentException(SR.Arg_MustBeNFloat); + } + + /// Compares this instance to a specified floating-point number and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified floating-point number. + /// A floating-point number to compare. + /// + /// A signed number indicating the relative values of this instance and . + /// + /// + /// Return Value + /// Description + /// + /// + /// Less than zero + /// This instance is less than , or this instance is not a number and is a number. + /// + /// + /// Zero + /// This instance is equal to , or both this instance and are not a number. + /// + /// + /// Greater than zero + /// This instance is greater than , or this instance is a number and is not a number. + /// + /// + /// + public int CompareTo(NFloat other) => _value.CompareTo(other._value); + + /// Returns a value indicating whether this instance is equal to a specified object. + /// An object to compare with this instance. + /// true if is an instance of and equals the value of this instance; otherwise, false. + public override bool Equals([NotNullWhen(true)] object? obj) => (obj is NFloat other) && Equals(other); + + /// Returns a value indicating whether this instance is equal to a specified value. /// An value to compare to this instance. /// true if has the same value as this instance; otherwise, false. public bool Equals(NFloat other) => _value.Equals(other._value); - /// - /// Returns the hash code for this instance. - /// + /// Returns the hash code for this instance. /// A 32-bit signed integer hash code. public override int GetHashCode() => _value.GetHashCode(); - /// - /// Converts the numeric value of this instance to its equivalent string representation. - /// + /// Converts the numeric value of this instance to its equivalent string representation. /// The string representation of the value of this instance. public override string ToString() => _value.ToString(); + + /// Converts the numeric value of this instance to its equivalent string representation using the specified format. + /// A numeric format string. + /// The string representation of the value of this instance as specified by . + /// is invalid. + public string ToString(string? format) => _value.ToString(format); + + /// Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information. + /// An object that supplies culture-specific formatting information. + /// The string representation of the value of this instance as specified by . + public string ToString(IFormatProvider? provider)=> _value.ToString(provider); + + /// Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information. + /// A numeric format string. + /// An object that supplies culture-specific formatting information. + /// The string representation of the value of this instance as specified by and . + /// is invalid. + public string ToString(string? format, IFormatProvider? provider) => _value.ToString(format, provider); + + /// Tries to format the value of the current instance into the provided span of characters. + /// The span in which to write this instance's value formatted as a span of characters. + /// When this method returns, contains the number of characters that were written in . + /// A span containing the characters that represent a standard or custom format string that defines the acceptable format for . + /// An optional object that supplies culture-specific formatting information for . + /// true if the formatting was successful; otherwise, false. + public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format = default, IFormatProvider? provider = null) => _value.TryFormat(destination, out charsWritten, format, provider); } } diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index 6fa5eb10ea0d4f..ef698c334313a2 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -157,13 +157,14 @@ public enum ClassInterfaceType AutoDual = 2, } [System.CLSCompliantAttribute(false)] - public readonly struct CLong : IEquatable + public readonly partial struct CLong : System.IEquatable { - public CLong(int value) { } - public CLong(nint value) { } + private readonly int _dummyPrimitive; + public CLong(int value) { throw null; } + public CLong(nint value) { throw null; } public nint Value { get { throw null; } } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; } - public bool Equals(CLong other) { throw null; } + public bool Equals(System.Runtime.InteropServices.CLong other) { throw null; } public override int GetHashCode() { throw null; } public override string ToString() { throw null; } } @@ -294,13 +295,14 @@ public sealed partial class ComUnregisterFunctionAttribute : System.Attribute public ComUnregisterFunctionAttribute() { } } [System.CLSCompliantAttribute(false)] - public readonly struct CULong : IEquatable + public readonly partial struct CULong : System.IEquatable { - public CULong(uint value) { } - public CULong(nuint value) { } + private readonly int _dummyPrimitive; + public CULong(uint value) { throw null; } + public CULong(nuint value) { throw null; } public nuint Value { get { throw null; } } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; } - public bool Equals(CULong other) { throw null; } + public bool Equals(System.Runtime.InteropServices.CULong other) { throw null; } public override int GetHashCode() { throw null; } public override string ToString() { throw null; } } @@ -782,15 +784,99 @@ public static void Free(void* ptr) { } [System.CLSCompliantAttribute(false)] public static void* Realloc(void* ptr, nuint byteCount) { throw null; } } - public readonly struct NFloat : IEquatable + public readonly partial struct NFloat : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.ISpanFormattable { - public NFloat(float value) { } - public NFloat(double value) { } + private readonly int _dummyPrimitive; + public NFloat(double value) { throw null; } + public NFloat(float value) { throw null; } + public static System.Runtime.InteropServices.NFloat Epsilon { get { throw null; } } + public static System.Runtime.InteropServices.NFloat MaxValue { get { throw null; } } + public static System.Runtime.InteropServices.NFloat MinValue { get { throw null; } } + public static System.Runtime.InteropServices.NFloat NaN { get { throw null; } } + public static System.Runtime.InteropServices.NFloat NegativeInfinity { get { throw null; } } + public static System.Runtime.InteropServices.NFloat PositiveInfinity { get { throw null; } } + public static int Size { get { throw null; } } public double Value { get { throw null; } } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; } - public bool Equals(NFloat other) { throw null; } + public int CompareTo(object? obj) { throw null; } + public int CompareTo(System.Runtime.InteropServices.NFloat other) { throw null; } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public bool Equals(System.Runtime.InteropServices.NFloat other) { throw null; } public override int GetHashCode() { throw null; } + public static bool IsFinite(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsInfinity(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsNaN(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsNegative(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsNegativeInfinity(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsNormal(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsPositiveInfinity(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool IsSubnormal(System.Runtime.InteropServices.NFloat value) { throw null; } + public static System.Runtime.InteropServices.NFloat operator +(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static System.Runtime.InteropServices.NFloat operator --(System.Runtime.InteropServices.NFloat value) { throw null; } + public static System.Runtime.InteropServices.NFloat operator /(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static bool operator ==(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static explicit operator System.Runtime.InteropServices.NFloat (decimal value) { throw null; } + public static explicit operator System.Runtime.InteropServices.NFloat (double value) { throw null; } + public static explicit operator byte (System.Runtime.InteropServices.NFloat value) { throw null; } + public static explicit operator char (System.Runtime.InteropServices.NFloat value) { throw null; } + public static explicit operator decimal (System.Runtime.InteropServices.NFloat value) { throw null; } + public static explicit operator short (System.Runtime.InteropServices.NFloat value) { throw null; } + public static explicit operator int (System.Runtime.InteropServices.NFloat value) { throw null; } + public static explicit operator long (System.Runtime.InteropServices.NFloat value) { throw null; } + public static explicit operator nint (System.Runtime.InteropServices.NFloat value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static explicit operator sbyte (System.Runtime.InteropServices.NFloat value) { throw null; } + public static explicit operator float (System.Runtime.InteropServices.NFloat value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static explicit operator ushort (System.Runtime.InteropServices.NFloat value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static explicit operator uint (System.Runtime.InteropServices.NFloat value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static explicit operator ulong (System.Runtime.InteropServices.NFloat value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static explicit operator nuint (System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool operator >(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static bool operator >=(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static implicit operator System.Runtime.InteropServices.NFloat (byte value) { throw null; } + public static implicit operator System.Runtime.InteropServices.NFloat (char value) { throw null; } + public static implicit operator System.Runtime.InteropServices.NFloat (short value) { throw null; } + public static implicit operator System.Runtime.InteropServices.NFloat (int value) { throw null; } + public static implicit operator System.Runtime.InteropServices.NFloat (long value) { throw null; } + public static implicit operator System.Runtime.InteropServices.NFloat (nint value) { throw null; } + public static implicit operator double (System.Runtime.InteropServices.NFloat value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static implicit operator System.Runtime.InteropServices.NFloat (sbyte value) { throw null; } + public static implicit operator System.Runtime.InteropServices.NFloat (float value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static implicit operator System.Runtime.InteropServices.NFloat (ushort value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static implicit operator System.Runtime.InteropServices.NFloat (uint value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static implicit operator System.Runtime.InteropServices.NFloat (ulong value) { throw null; } + [System.CLSCompliantAttribute(false)] + public static implicit operator System.Runtime.InteropServices.NFloat (nuint value) { throw null; } + public static System.Runtime.InteropServices.NFloat operator ++(System.Runtime.InteropServices.NFloat value) { throw null; } + public static bool operator !=(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static bool operator <(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static bool operator <=(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static System.Runtime.InteropServices.NFloat operator %(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static System.Runtime.InteropServices.NFloat operator *(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static System.Runtime.InteropServices.NFloat operator -(System.Runtime.InteropServices.NFloat left, System.Runtime.InteropServices.NFloat right) { throw null; } + public static System.Runtime.InteropServices.NFloat operator -(System.Runtime.InteropServices.NFloat value) { throw null; } + public static System.Runtime.InteropServices.NFloat operator +(System.Runtime.InteropServices.NFloat value) { throw null; } + public static System.Runtime.InteropServices.NFloat Parse(System.ReadOnlySpan s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowLeadingSign | System.Globalization.NumberStyles.AllowLeadingWhite | System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.AllowTrailingWhite, System.IFormatProvider? provider = null) { throw null; } + public static System.Runtime.InteropServices.NFloat Parse(string s) { throw null; } + public static System.Runtime.InteropServices.NFloat Parse(string s, System.Globalization.NumberStyles style) { throw null; } + public static System.Runtime.InteropServices.NFloat Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider) { throw null; } + public static System.Runtime.InteropServices.NFloat Parse(string s, System.IFormatProvider? provider) { throw null; } public override string ToString() { throw null; } + public string ToString(System.IFormatProvider? provider) { throw null; } + public string ToString(string? format) { throw null; } + public string ToString(string? format, System.IFormatProvider? provider) { throw null; } + public bool TryFormat(System.Span destination, out int charsWritten, System.ReadOnlySpan format = default(System.ReadOnlySpan), System.IFormatProvider? provider = null) { throw null; } + public static bool TryParse(System.ReadOnlySpan s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out System.Runtime.InteropServices.NFloat result) { throw null; } + public static bool TryParse(System.ReadOnlySpan s, out System.Runtime.InteropServices.NFloat result) { throw null; } + public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out System.Runtime.InteropServices.NFloat result) { throw null; } + public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, out System.Runtime.InteropServices.NFloat result) { throw null; } } [System.AttributeUsageAttribute(System.AttributeTargets.Parameter, Inherited=false)] public sealed partial class OptionalAttribute : System.Attribute From 140a35e9701fda136077a65ba1db2d8b6278548d Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Tue, 25 Jan 2022 09:08:56 -0800 Subject: [PATCH 2/9] Apply suggestions from code review Co-authored-by: Rolf Bjarne Kvinge --- .../src/System/Runtime/InteropServices/NFloat.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs index 571e90d3e9f118..62d9a8d30e1a33 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs @@ -199,7 +199,7 @@ public double Value /// The value to compare with . /// true if is less than or equal to ; otherwise, false. [NonVersionable] - public static bool operator <=(NFloat left, NFloat right) => left._value >= right._value; + public static bool operator <=(NFloat left, NFloat right) => left._value <= right._value; /// Compares two values to determine which is greater. /// The value to compare with . @@ -213,7 +213,7 @@ public double Value /// The value to compare with . /// true if is greater than or equal to ; otherwise, false. [NonVersionable] - public static bool operator >=(NFloat left, NFloat right) => left._value <= right._value; + public static bool operator >=(NFloat left, NFloat right) => left._value >= right._value; // // Explicit Convert To NFloat From 2f55868c9d8163eaa1061792b015ec8678c0ac5e Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Wed, 26 Jan 2022 12:30:26 -0800 Subject: [PATCH 3/9] Adding NFloat tests (p1) --- .../Runtime/InteropServices/NFloatTests.cs | 695 +++++++++++++++++- 1 file changed, 674 insertions(+), 21 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs index c2311afae708d1..b6eeadaa217a3d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs @@ -15,36 +15,700 @@ public class NFloatTests [Fact] public void Ctor_Empty() { - NFloat value = new NFloat(); - Assert.Equal(0, value.Value); + NFloat result = new NFloat(); + Assert.Equal(0, result.Value); } [Fact] public void Ctor_Float() { - NFloat value = new NFloat(42.0f); - Assert.Equal(42.0, value.Value); + NFloat result = new NFloat(42.0f); + Assert.Equal(42.0, result.Value); } [Fact] public void Ctor_Double() { - NFloat value = new NFloat(42.0); - Assert.Equal(42.0, value.Value); + NFloat result = new NFloat(42.0); + Assert.Equal(42.0, result.Value); } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.Is32BitProcess))] public void Ctor_Double_OutOfRange() { - NFloat value = new NFloat(double.MaxValue); - Assert.Equal((double)(float)double.MaxValue, value.Value); + NFloat result = new NFloat(double.MaxValue); + Assert.Equal(float.PositiveInfinity, result.Value); } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.Is64BitProcess))] public void Ctor_Double_LargeValue() { - NFloat value = new NFloat(double.MaxValue); - Assert.Equal(double.MaxValue, value.Value); + NFloat result = new NFloat(double.MaxValue); + Assert.Equal(double.MaxValue, result.Value); + } + + [Fact] + public void Epsilon() + { + NFloat result = NFloat.Epsilon; + + if (Environment.Is64BitProcess) + { + Assert.Equal(double.Epsilon, result.Value); + } + else + { + Assert.Equal(float.Epsilon, result.Value); + } + } + + [Fact] + public void MaxValue() + { + NFloat result = NFloat.MaxValue; + + if (Environment.Is64BitProcess) + { + Assert.Equal(double.MaxValue, result.Value); + } + else + { + Assert.Equal(float.MaxValue, result.Value); + } + } + + [Fact] + public void MinValue() + { + NFloat result = NFloat.MinValue; + + if (Environment.Is64BitProcess) + { + Assert.Equal(double.MinValue, result.Value); + } + else + { + Assert.Equal(float.MinValue, result.Value); + } + } + + [Fact] + public void NaN() + { + NFloat result = NFloat.NaN; + Assert.True(double.IsNaN(result.Value)); + } + + [Fact] + public void NegativeInfinity() + { + NFloat result = NFloat.NegativeInfinity; + + if (Environment.Is64BitProcess) + { + Assert.Equal(double.NegativeInfinity, result.Value); + } + else + { + Assert.Equal(float.NegativeInfinity, result.Value); + } + } + + [Fact] + public void PositiveInfinity() + { + NFloat result = NFloat.PositiveInfinity; + + if (Environment.Is64BitProcess) + { + Assert.Equal(double.PositiveInfinity, result.Value); + } + else + { + Assert.Equal(float.PositiveInfinity, result.Value); + } + } + + [Fact] + public unsafe void Size() + { + int size = PlatformDetection.Is32BitProcess ? 4 : 8; +#pragma warning disable xUnit2000 // The value under test here is the sizeof expression + Assert.Equal(size, sizeof(NFloat)); +#pragma warning restore xUnit2000 + Assert.Equal(size, Marshal.SizeOf()); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public static void op_UnaryPlus(float value) + { + NFloat result = +(new NFloat(value)); + Assert.Equal(+value, result.Value); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public static void op_UnaryNegation(float value) + { + NFloat result = -(new NFloat(value)); + Assert.Equal(-value, result.Value); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public static void op_Decrement(float value) + { + NFloat result = new NFloat(value); + --result; + + if (Environment.Is64BitProcess) + { + Assert.Equal((double)value - 1, result.Value); + } + else + { + Assert.Equal(value - 1, result.Value); + } + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public static void op_Increment(float value) + { + NFloat result = new NFloat(value); + ++result; + + if (Environment.Is64BitProcess) + { + Assert.Equal((double)value + 1, result.Value); + } + else + { + Assert.Equal(value + 1, result.Value); + } + } + + [Theory] + [InlineData(-4567.0f, 3.14f)] + [InlineData(-4567.89101f, 3.14569f)] + [InlineData(0.0f, 3.14f)] + [InlineData(4567.0f, -3.14f)] + [InlineData(4567.89101f, -3.14569f)] + public static void op_Addition(float left, float right) + { + NFloat result = new NFloat(left) + new NFloat(right); + + if (Environment.Is64BitProcess) + { + Assert.Equal((double)left + right, result.Value); + } + else + { + Assert.Equal(left + right, result.Value); + } + } + + [Theory] + [InlineData(-4567.0f, 3.14f)] + [InlineData(-4567.89101f, 3.14569f)] + [InlineData(0.0f, 3.14f)] + [InlineData(4567.0f, -3.14f)] + [InlineData(4567.89101f, -3.14569f)] + public static void op_Subtraction(float left, float right) + { + NFloat result = new NFloat(left) - new NFloat(right); + + if (Environment.Is64BitProcess) + { + Assert.Equal((double)left - right, result.Value); + } + else + { + Assert.Equal(left - right, result.Value); + } + } + + [Theory] + [InlineData(-4567.0f, 3.14f)] + [InlineData(-4567.89101f, 3.14569f)] + [InlineData(0.0f, 3.14f)] + [InlineData(4567.0f, -3.14f)] + [InlineData(4567.89101f, -3.14569f)] + public static void op_Multiply(float left, float right) + { + NFloat result = new NFloat(left) * new NFloat(right); + + if (Environment.Is64BitProcess) + { + Assert.Equal((double)left * right, result.Value); + } + else + { + Assert.Equal(left * right, result.Value); + } + } + + [Theory] + [InlineData(-4567.0f, 3.14f)] + [InlineData(-4567.89101f, 3.14569f)] + [InlineData(0.0f, 3.14f)] + [InlineData(4567.0f, -3.14f)] + [InlineData(4567.89101f, -3.14569f)] + public static void op_Division(float left, float right) + { + NFloat result = new NFloat(left) / new NFloat(right); + + if (Environment.Is64BitProcess) + { + Assert.Equal((double)left / right, result.Value); + } + else + { + Assert.Equal(left / right, result.Value); + } + } + + [Theory] + [InlineData(-4567.0f, 3.14f)] + [InlineData(-4567.89101f, 3.14569f)] + [InlineData(0.0f, 3.14f)] + [InlineData(4567.0f, -3.14f)] + [InlineData(4567.89101f, -3.14569f)] + public static void op_Modulus(float left, float right) + { + NFloat result = new NFloat(left) % new NFloat(right); + + if (Environment.Is64BitProcess) + { + Assert.Equal((double)left % right, result.Value); + } + else + { + Assert.Equal(left % right, result.Value); + } + } + + [Theory] + [InlineData(789.0f, 789.0f)] + [InlineData(789.0f, -789.0f)] + [InlineData(789.0f, 0.0f)] + [InlineData(789.0f, 1000.0f)] + public void op_Equality(float left, float right) + { + bool result = new NFloat(left) == new NFloat(right); + Assert.Equal(left == right, result); + } + + [Theory] + [InlineData(789.0f, 789.0f)] + [InlineData(789.0f, -789.0f)] + [InlineData(789.0f, 0.0f)] + [InlineData(789.0f, 1000.0f)] + public void op_Inequality(float left, float right) + { + bool result = new NFloat(left) != new NFloat(right); + Assert.Equal(left != right, result); + } + + [Theory] + [InlineData(789.0f, 789.0f)] + [InlineData(789.0f, -789.0f)] + [InlineData(789.0f, 0.0f)] + [InlineData(789.0f, 1000.0f)] + public void op_GreaterThan(float left, float right) + { + bool result = new NFloat(left) > new NFloat(right); + Assert.Equal(left > right, result); + } + + [Theory] + [InlineData(789.0f, 789.0f)] + [InlineData(789.0f, -789.0f)] + [InlineData(789.0f, 0.0f)] + [InlineData(789.0f, 1000.0f)] + public void op_GreaterThanOrEqual(float left, float right) + { + bool result = new NFloat(left) >= new NFloat(right); + Assert.Equal(left >= right, result); + } + + [Theory] + [InlineData(789.0f, 789.0f)] + [InlineData(789.0f, -789.0f)] + [InlineData(789.0f, 0.0f)] + [InlineData(789.0f, 1000.0f)] + public void op_LessThan(float left, float right) + { + bool result = new NFloat(left) < new NFloat(right); + Assert.Equal(left < right, result); + } + + [Theory] + [InlineData(789.0f, 789.0f)] + [InlineData(789.0f, -789.0f)] + [InlineData(789.0f, 0.0f)] + [InlineData(789.0f, 1000.0f)] + public void op_LessThanOrEqual(float left, float right) + { + bool result = new NFloat(left) <= new NFloat(right); + Assert.Equal(left <= right, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void DoubleToNFloat(float value) + { + NFloat result = (NFloat)(double)value; + + if (Environment.Is64BitProcess) + { + Assert.Equal(value, result.Value); + } + else + { + Assert.Equal((float)value, result.Value); + } + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToByte(float value) + { + byte result = (byte)new NFloat(value); + Assert.Equal((byte)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToChar(float value) + { + char result = (char)new NFloat(value); + Assert.Equal((char)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToDecimal(float value) + { + decimal result = (decimal)new NFloat(value); + + if (Environment.Is64BitProcess) + { + Assert.Equal((decimal)(double)value, result); + } + else + { + Assert.Equal((decimal)value, result); + } + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToInt16(float value) + { + short result = (short)new NFloat(value); + Assert.Equal((short)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToInt32(float value) + { + int result = (int)new NFloat(value); + Assert.Equal((int)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToInt64(float value) + { + long result = (long)new NFloat(value); + Assert.Equal((long)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToIntPtr(float value) + { + nint result = (nint)new NFloat(value); + Assert.Equal((nint)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToSByte(float value) + { + sbyte result = (sbyte)new NFloat(value); + Assert.Equal((sbyte)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToSingle(float value) + { + float result = (float)new NFloat(value); + Assert.Equal(value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToUInt16(float value) + { + ushort result = (ushort)new NFloat(value); + Assert.Equal((ushort)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToUInt32(float value) + { + uint result = (uint)new NFloat(value); + Assert.Equal((uint)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToUInt64(float value) + { + ulong result = (ulong)new NFloat(value); + Assert.Equal((ulong)value, result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToUIntPtr(float value) + { + nuint result = (nuint)new NFloat(value); + Assert.Equal((nuint)value, result); + } + + [Theory] + [InlineData((byte)0)] + [InlineData((byte)5)] + [InlineData((byte)42)] + [InlineData((byte)127)] + [InlineData((byte)255)] + public void ByteToNFloat(byte value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData('A')] + [InlineData('B')] + [InlineData('C')] + [InlineData('D')] + [InlineData('E')] + public void CharToNFloat(char value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData((short)-255)] + [InlineData((short)-127)] + [InlineData((short)0)] + [InlineData((short)127)] + [InlineData((short)255)] + public void Int16ToNFloat(short value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData(-255)] + [InlineData(-127)] + [InlineData(0)] + [InlineData(127)] + [InlineData(255)] + public void Int32ToNFloat(int value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData((long)-255)] + [InlineData((long)-127)] + [InlineData((long)0)] + [InlineData((long)127)] + [InlineData((long)255)] + public void Int64ToNFloat(long value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData((int)-255)] + [InlineData((int)-127)] + [InlineData((int)0)] + [InlineData((int)127)] + [InlineData((int)255)] + public void IntPtrToNFloat(int value) + { + NFloat result = (nint)value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData((sbyte)-127)] + [InlineData((sbyte)-63)] + [InlineData((sbyte)0)] + [InlineData((sbyte)63)] + [InlineData((sbyte)127)] + public void SByteToNFloat(sbyte value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void SingleToNFloat(float value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData((ushort)0)] + [InlineData((ushort)5)] + [InlineData((ushort)42)] + [InlineData((ushort)127)] + [InlineData((ushort)255)] + public void UInt16ToNFloat(ushort value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData((uint)0)] + [InlineData((uint)5)] + [InlineData((uint)42)] + [InlineData((uint)127)] + [InlineData((uint)255)] + public void UInt32ToNFloat(uint value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData((ulong)0)] + [InlineData((ulong)5)] + [InlineData((ulong)42)] + [InlineData((ulong)127)] + [InlineData((ulong)255)] + public void UInt64ToNFloat(ulong value) + { + NFloat result = value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData((uint)0)] + [InlineData((uint)5)] + [InlineData((uint)42)] + [InlineData((uint)127)] + [InlineData((uint)255)] + public void UIntPtrToNFloat(uint value) + { + NFloat result = (nuint)value; + Assert.Equal(value, result.Value); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + public void NFloatToDouble(float value) + { + double result = new NFloat(value); + Assert.Equal(value, result); } public static IEnumerable EqualsData() @@ -83,7 +747,6 @@ public void NaNEqualsTest() [InlineData(0.0f)] [InlineData(4567.0f)] [InlineData(4567.89101f)] - [InlineData(float.NaN)] public static void ToStringTest64(float value) { @@ -106,15 +769,5 @@ public static void ToStringTest32(float value) Assert.Equal(value.ToString(), nfloat.ToString()); } - - [Fact] - public unsafe void Size() - { - int size = PlatformDetection.Is32BitProcess ? 4 : 8; -#pragma warning disable xUnit2000 // The value under test here is the sizeof expression - Assert.Equal(size, sizeof(NFloat)); -#pragma warning restore xUnit2000 - Assert.Equal(size, Marshal.SizeOf()); - } } } From 2e6fccca291b16d406e267cc864b20a20f5db75b Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 27 Jan 2022 10:05:55 -0800 Subject: [PATCH 4/9] Temporarily disable negative conversions involving nfloat->nint --- .../tests/System/Runtime/InteropServices/NFloatTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs index b6eeadaa217a3d..bed6f31b17e9e9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs @@ -472,8 +472,8 @@ public void NFloatToInt64(float value) } [Theory] - [InlineData(-4567.0f)] - [InlineData(-4567.89101f)] + [InlineData(-4567.0f, Skip = "Mono incorrectly handles")] + [InlineData(-4567.89101f, Skip = "Mono incorrectly handles")] [InlineData(0.0f)] [InlineData(4567.0f)] [InlineData(4567.89101f)] From e14c22f579a5f9678dd09fed9d8d984d0c4124e7 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 27 Jan 2022 10:30:41 -0800 Subject: [PATCH 5/9] Adjusting the skip condition for the Mono failures --- .../tests/System/Runtime/InteropServices/NFloatTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs index bed6f31b17e9e9..5c122ad53a0975 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs @@ -472,8 +472,8 @@ public void NFloatToInt64(float value) } [Theory] - [InlineData(-4567.0f, Skip = "Mono incorrectly handles")] - [InlineData(-4567.89101f, Skip = "Mono incorrectly handles")] + [InlineData(-4567.0f, Skip = "https://github.com/dotnet/runtime/issues/64386")] + [InlineData(-4567.89101f, Skip = "https://github.com/dotnet/runtime/issues/64386")] [InlineData(0.0f)] [InlineData(4567.0f)] [InlineData(4567.89101f)] From 985c3149a57f47eecdfa2f99bcf97586e9ee385e Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 27 Jan 2022 10:38:37 -0800 Subject: [PATCH 6/9] Adding additional tests covering the NFloat.Is* APIs --- .../Runtime/InteropServices/NFloatTests.cs | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs index 5c122ad53a0975..c29914383cfe4e 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs @@ -711,6 +711,134 @@ public void NFloatToDouble(float value) Assert.Equal(value, result); } + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.Epsilon)] + [InlineData(float.NegativeInfinity)] + [InlineData(float.PositiveInfinity)] + [InlineData(float.NaN)] + public void IsFinite(float value) + { + bool result = NFloat.IsFinite(value); + Assert.Equal(float.IsFinite(value), result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.Epsilon)] + [InlineData(float.NegativeInfinity)] + [InlineData(float.PositiveInfinity)] + [InlineData(float.NaN)] + public void IsInfinity(float value) + { + bool result = NFloat.IsInfinity(value); + Assert.Equal(float.IsInfinity(value), result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.Epsilon)] + [InlineData(float.NegativeInfinity)] + [InlineData(float.PositiveInfinity)] + [InlineData(float.NaN)] + public void IsNaN(float value) + { + bool result = NFloat.IsNaN(value); + Assert.Equal(float.IsNaN(value), result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.Epsilon)] + [InlineData(float.NegativeInfinity)] + [InlineData(float.PositiveInfinity)] + [InlineData(float.NaN)] + public void IsNegative(float value) + { + bool result = NFloat.IsNegative(value); + Assert.Equal(float.IsNegative(value), result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.Epsilon)] + [InlineData(float.NegativeInfinity)] + [InlineData(float.PositiveInfinity)] + [InlineData(float.NaN)] + public void IsNegativeInfinity(float value) + { + bool result = NFloat.IsNegativeInfinity(value); + Assert.Equal(float.IsNegativeInfinity(value), result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.Epsilon)] + [InlineData(float.NegativeInfinity)] + [InlineData(float.PositiveInfinity)] + [InlineData(float.NaN)] + public void IsNormal(float value) + { + bool result = NFloat.IsNormal(value); + Assert.Equal(float.IsNormal(value), result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.Epsilon)] + [InlineData(float.NegativeInfinity)] + [InlineData(float.PositiveInfinity)] + [InlineData(float.NaN)] + public void IsPositiveInfinity(float value) + { + bool result = NFloat.IsPositiveInfinity(value); + Assert.Equal(float.IsPositiveInfinity(value), result); + } + + [Theory] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.Epsilon)] + [InlineData(float.NegativeInfinity)] + [InlineData(float.PositiveInfinity)] + [InlineData(float.NaN)] + public void IsSubnormal(float value) + { + bool result = NFloat.IsSubnormal(value); + Assert.Equal(float.IsSubnormal(value), result); + } + public static IEnumerable EqualsData() { yield return new object[] { new NFloat(789.0f), new NFloat(789.0f), true }; From a0472e60726dd515dfa329cff3e81209dd7e64cd Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 27 Jan 2022 12:01:20 -0800 Subject: [PATCH 7/9] Fixing the IsNormal and IsSubnormal test to account for 64-bit vs 32-bit --- .../Runtime/InteropServices/NFloatTests.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs index c29914383cfe4e..6f97497fe03c7c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs @@ -804,7 +804,15 @@ public void IsNegativeInfinity(float value) public void IsNormal(float value) { bool result = NFloat.IsNormal(value); - Assert.Equal(float.IsNormal(value), result); + + if (Environment.Is64BitProcess) + { + Assert.Equal(double.IsNormal(value), result); + } + else + { + Assert.Equal(float.IsNormal(value), result); + } } [Theory] @@ -836,7 +844,15 @@ public void IsPositiveInfinity(float value) public void IsSubnormal(float value) { bool result = NFloat.IsSubnormal(value); - Assert.Equal(float.IsSubnormal(value), result); + + if (Environment.Is64BitProcess) + { + Assert.Equal(double.IsSubnormal(value), result); + } + else + { + Assert.Equal(float.IsSubnormal(value), result); + } } public static IEnumerable EqualsData() From 91ebe8c9b2d7cb23495c052ee7e399c85d3195b3 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 31 Jan 2022 18:18:44 -0800 Subject: [PATCH 8/9] Adding a System.Runtime.InteropServices.Experimental package that overrides the built-in ref assembly for System.Runtime.InteropServices --- .../Directory.Build.props | 9 + ...m.Runtime.InteropServices.Experimental.sln | 198 ++++++++++++++++++ ...untime.InteropServices.Experimental.csproj | 43 ++++ ....Runtime.InteropServices.Experimental.proj | 7 + ....InteropServices.Experimental.Tests.csproj | 15 ++ .../ref/System.Runtime.InteropServices.cs | 22 +- .../src/MatchingRefApiCompatBaseline.txt | 78 ++++++- .../Runtime/InteropServices/NFloatTests.cs | 140 +++++++------ 8 files changed, 436 insertions(+), 76 deletions(-) create mode 100644 src/libraries/System.Runtime.InteropServices.Experimental/Directory.Build.props create mode 100644 src/libraries/System.Runtime.InteropServices.Experimental/System.Runtime.InteropServices.Experimental.sln create mode 100644 src/libraries/System.Runtime.InteropServices.Experimental/ref/System.Runtime.InteropServices.Experimental.csproj create mode 100644 src/libraries/System.Runtime.InteropServices.Experimental/src/System.Runtime.InteropServices.Experimental.proj create mode 100644 src/libraries/System.Runtime.InteropServices.Experimental/tests/System.Runtime.InteropServices.Experimental.Tests.csproj diff --git a/src/libraries/System.Runtime.InteropServices.Experimental/Directory.Build.props b/src/libraries/System.Runtime.InteropServices.Experimental/Directory.Build.props new file mode 100644 index 00000000000000..a2b7f43d8786fd --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.Experimental/Directory.Build.props @@ -0,0 +1,9 @@ + + + + + false + Microsoft + true + + diff --git a/src/libraries/System.Runtime.InteropServices.Experimental/System.Runtime.InteropServices.Experimental.sln b/src/libraries/System.Runtime.InteropServices.Experimental/System.Runtime.InteropServices.Experimental.sln new file mode 100644 index 00000000000000..3b7fc0e30b6007 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.Experimental/System.Runtime.InteropServices.Experimental.sln @@ -0,0 +1,198 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Private.CoreLib", "..\..\coreclr\System.Private.CoreLib\System.Private.CoreLib.csproj", "{94B59BA0-491F-4B59-ADFF-A057EC3EC835}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\ref\System.Runtime.CompilerServices.Unsafe.csproj", "{5BB5F99F-1052-4EB4-B12E-7863805661F3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.CompilerServices.Unsafe", "..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj", "{04BA3E3C-6979-4792-B19E-C797AD607F42}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.Experimental", "ref\System.Runtime.InteropServices.Experimental.csproj", "{8671F164-F78C-44FA-93B7-A310F67890FE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.Experimental", "src\System.Runtime.InteropServices.Experimental.csproj", "{4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.ComDisabled.Tests", "tests\ComDisabled\System.Runtime.InteropServices.ComDisabled.Tests.csproj", "{6D2197E6-D3DF-43AE-9BEE-3573018639F9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Runtime.InteropServices.Experimental.Tests", "tests\System.Runtime.InteropServices.Experimental.Tests.csproj", "{E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FB99AC59-1744-4F12-A4B0-0D54FCA048BF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B1678CCD-95C8-4419-B9F9-14A03061BE4B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{D893B9AA-57C5-49E3-97B1-12CC62D84307}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + Checked|Any CPU = Checked|Any CPU + Checked|x64 = Checked|x64 + Checked|x86 = Checked|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|x64.ActiveCfg = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|x64.Build.0 = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|x86.ActiveCfg = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Debug|x86.Build.0 = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|Any CPU.Build.0 = Release|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|x64.ActiveCfg = Release|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|x64.Build.0 = Release|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|x86.ActiveCfg = Release|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Release|x86.Build.0 = Release|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|Any CPU.Build.0 = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|x64.ActiveCfg = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|x64.Build.0 = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|x86.ActiveCfg = Debug|Any CPU + {6D2197E6-D3DF-43AE-9BEE-3573018639F9}.Checked|x86.Build.0 = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Debug|x64.ActiveCfg = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Debug|x64.Build.0 = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Debug|x86.ActiveCfg = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Debug|x86.Build.0 = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Release|Any CPU.Build.0 = Release|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Release|x64.ActiveCfg = Release|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Release|x64.Build.0 = Release|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Release|x86.ActiveCfg = Release|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Release|x86.Build.0 = Release|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|Any CPU.Build.0 = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|x64.ActiveCfg = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|x64.Build.0 = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|x86.ActiveCfg = Debug|Any CPU + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1}.Checked|x86.Build.0 = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|x64.ActiveCfg = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|x64.Build.0 = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|x86.ActiveCfg = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Debug|x86.Build.0 = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Release|Any CPU.Build.0 = Release|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Release|x64.ActiveCfg = Release|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Release|x64.Build.0 = Release|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Release|x86.ActiveCfg = Release|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Release|x86.Build.0 = Release|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Checked|Any CPU.Build.0 = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Checked|x64.ActiveCfg = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Checked|x64.Build.0 = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Checked|x86.ActiveCfg = Debug|Any CPU + {8671F164-F78C-44FA-93B7-A310F67890FE}.Checked|x86.Build.0 = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|x64.ActiveCfg = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|x64.Build.0 = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|x86.ActiveCfg = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Debug|x86.Build.0 = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|Any CPU.Build.0 = Release|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|x64.ActiveCfg = Release|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|x64.Build.0 = Release|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|x86.ActiveCfg = Release|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Release|x86.Build.0 = Release|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|Any CPU.Build.0 = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|x64.ActiveCfg = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|x64.Build.0 = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|x86.ActiveCfg = Debug|Any CPU + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664}.Checked|x86.Build.0 = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Debug|x64.ActiveCfg = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Debug|x64.Build.0 = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Debug|x86.ActiveCfg = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Debug|x86.Build.0 = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Release|Any CPU.Build.0 = Release|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Release|x64.ActiveCfg = Release|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Release|x64.Build.0 = Release|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Release|x86.ActiveCfg = Release|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Release|x86.Build.0 = Release|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Checked|Any CPU.Build.0 = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Checked|x64.ActiveCfg = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Checked|x64.Build.0 = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Checked|x86.ActiveCfg = Debug|Any CPU + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA}.Checked|x86.Build.0 = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Debug|x64.ActiveCfg = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Debug|x64.Build.0 = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Debug|x86.ActiveCfg = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Debug|x86.Build.0 = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Release|Any CPU.Build.0 = Release|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Release|x64.ActiveCfg = Release|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Release|x64.Build.0 = Release|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Release|x86.ActiveCfg = Release|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Release|x86.Build.0 = Release|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|Any CPU.Build.0 = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x64.ActiveCfg = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x64.Build.0 = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x86.ActiveCfg = Debug|Any CPU + {04BA3E3C-6979-4792-B19E-C797AD607F42}.Checked|x86.Build.0 = Debug|Any CPU + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Debug|Any CPU.ActiveCfg = Debug|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Debug|Any CPU.Build.0 = Debug|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Debug|x64.ActiveCfg = Debug|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Debug|x64.Build.0 = Debug|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Debug|x86.ActiveCfg = Debug|x86 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Debug|x86.Build.0 = Debug|x86 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Release|Any CPU.ActiveCfg = Release|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Release|Any CPU.Build.0 = Release|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Release|x64.ActiveCfg = Release|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Release|x64.Build.0 = Release|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Release|x86.ActiveCfg = Release|x86 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Release|x86.Build.0 = Release|x86 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Checked|Any CPU.ActiveCfg = Checked|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Checked|Any CPU.Build.0 = Checked|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Checked|x64.ActiveCfg = Checked|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Checked|x64.Build.0 = Checked|x64 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Checked|x86.ActiveCfg = Checked|x86 + {94B59BA0-491F-4B59-ADFF-A057EC3EC835}.Checked|x86.Build.0 = Checked|x86 + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Debug|x64.ActiveCfg = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Debug|x64.Build.0 = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Debug|x86.ActiveCfg = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Debug|x86.Build.0 = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Release|Any CPU.Build.0 = Release|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Release|x64.ActiveCfg = Release|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Release|x64.Build.0 = Release|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Release|x86.ActiveCfg = Release|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Release|x86.Build.0 = Release|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Checked|Any CPU.ActiveCfg = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Checked|Any CPU.Build.0 = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Checked|x64.ActiveCfg = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Checked|x64.Build.0 = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Checked|x86.ActiveCfg = Debug|Any CPU + {5BB5F99F-1052-4EB4-B12E-7863805661F3}.Checked|x86.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {6D2197E6-D3DF-43AE-9BEE-3573018639F9} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {E249BD6A-85DB-4CE4-BD82-8D67EBAC5664} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {1FF4CC8E-49C3-42A0-A6E0-2E5908455FBA} = {FB99AC59-1744-4F12-A4B0-0D54FCA048BF} + {4FC33B9B-1BCF-4D16-B886-DCA8F2B823C1} = {B1678CCD-95C8-4419-B9F9-14A03061BE4B} + {04BA3E3C-6979-4792-B19E-C797AD607F42} = {B1678CCD-95C8-4419-B9F9-14A03061BE4B} + {94B59BA0-491F-4B59-ADFF-A057EC3EC835} = {B1678CCD-95C8-4419-B9F9-14A03061BE4B} + {8671F164-F78C-44FA-93B7-A310F67890FE} = {D893B9AA-57C5-49E3-97B1-12CC62D84307} + {5BB5F99F-1052-4EB4-B12E-7863805661F3} = {D893B9AA-57C5-49E3-97B1-12CC62D84307} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D4031401-FEB5-4CCF-91C1-38F5646B2BFD} + EndGlobalSection +EndGlobal diff --git a/src/libraries/System.Runtime.InteropServices.Experimental/ref/System.Runtime.InteropServices.Experimental.csproj b/src/libraries/System.Runtime.InteropServices.Experimental/ref/System.Runtime.InteropServices.Experimental.csproj new file mode 100644 index 00000000000000..eea389e59eb400 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.Experimental/ref/System.Runtime.InteropServices.Experimental.csproj @@ -0,0 +1,43 @@ + + + System.Runtime.InteropServices + true + + + $(NoWarn);618;CS8765 + true + $(NetCoreAppCurrent) + enable + + + + ref + $(DefineConstants);FEATURE_NFLOAT + true + 1 + true + Exposes new experimental APIs from System.Runtime.InteropServices + $(MSBuildProjectName) + + true + + + + + + + + + + + + <_FileVersionMaj>$(FileVersion.Split('.')[0]) + <_FileVersionMin>$(FileVersion.Split('.')[1]) + <_FileVersionBld>$(FileVersion.Split('.')[2]) + <_FileVersionRev>$(FileVersion.Split('.')[3]) + $(_FileVersionMaj).$([MSBuild]::Add($(_FileVersionMin), 100)).$(_FileVersionBld).$(_FileVersionRev) + + + diff --git a/src/libraries/System.Runtime.InteropServices.Experimental/src/System.Runtime.InteropServices.Experimental.proj b/src/libraries/System.Runtime.InteropServices.Experimental/src/System.Runtime.InteropServices.Experimental.proj new file mode 100644 index 00000000000000..304633a1911a7f --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.Experimental/src/System.Runtime.InteropServices.Experimental.proj @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/libraries/System.Runtime.InteropServices.Experimental/tests/System.Runtime.InteropServices.Experimental.Tests.csproj b/src/libraries/System.Runtime.InteropServices.Experimental/tests/System.Runtime.InteropServices.Experimental.Tests.csproj new file mode 100644 index 00000000000000..d5206ce5dab7a3 --- /dev/null +++ b/src/libraries/System.Runtime.InteropServices.Experimental/tests/System.Runtime.InteropServices.Experimental.Tests.csproj @@ -0,0 +1,15 @@ + + + true + true + $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser + true + true + + + $(DefineConstants);FEATURE_NFLOAT + + + + + diff --git a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs index ef698c334313a2..e7eb8164ddbdc6 100644 --- a/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs +++ b/src/libraries/System.Runtime.InteropServices/ref/System.Runtime.InteropServices.cs @@ -784,11 +784,25 @@ public static void Free(void* ptr) { } [System.CLSCompliantAttribute(false)] public static void* Realloc(void* ptr, nuint byteCount) { throw null; } } - public readonly partial struct NFloat : System.IComparable, System.IComparable, System.IEquatable, System.IFormattable, System.ISpanFormattable + public readonly partial struct NFloat : System.IEquatable +#if FEATURE_NFLOAT +#pragma warning disable SA1001 + , System.IComparable, + System.IComparable, + System.IFormattable, + System.ISpanFormattable +#pragma warning restore SA1001 +#endif // FEATURE_NFLOAT { private readonly int _dummyPrimitive; public NFloat(double value) { throw null; } public NFloat(float value) { throw null; } + public double Value { get { throw null; } } + public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public bool Equals(System.Runtime.InteropServices.NFloat other) { throw null; } + public override int GetHashCode() { throw null; } + public override string ToString() { throw null; } +#if FEATURE_NFLOAT public static System.Runtime.InteropServices.NFloat Epsilon { get { throw null; } } public static System.Runtime.InteropServices.NFloat MaxValue { get { throw null; } } public static System.Runtime.InteropServices.NFloat MinValue { get { throw null; } } @@ -796,12 +810,8 @@ public static void Free(void* ptr) { } public static System.Runtime.InteropServices.NFloat NegativeInfinity { get { throw null; } } public static System.Runtime.InteropServices.NFloat PositiveInfinity { get { throw null; } } public static int Size { get { throw null; } } - public double Value { get { throw null; } } public int CompareTo(object? obj) { throw null; } public int CompareTo(System.Runtime.InteropServices.NFloat other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals(System.Runtime.InteropServices.NFloat other) { throw null; } - public override int GetHashCode() { throw null; } public static bool IsFinite(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsInfinity(System.Runtime.InteropServices.NFloat value) { throw null; } public static bool IsNaN(System.Runtime.InteropServices.NFloat value) { throw null; } @@ -868,7 +878,6 @@ public static void Free(void* ptr) { } public static System.Runtime.InteropServices.NFloat Parse(string s, System.Globalization.NumberStyles style) { throw null; } public static System.Runtime.InteropServices.NFloat Parse(string s, System.Globalization.NumberStyles style, System.IFormatProvider? provider) { throw null; } public static System.Runtime.InteropServices.NFloat Parse(string s, System.IFormatProvider? provider) { throw null; } - public override string ToString() { throw null; } public string ToString(System.IFormatProvider? provider) { throw null; } public string ToString(string? format) { throw null; } public string ToString(string? format, System.IFormatProvider? provider) { throw null; } @@ -877,6 +886,7 @@ public static void Free(void* ptr) { } public static bool TryParse(System.ReadOnlySpan s, out System.Runtime.InteropServices.NFloat result) { throw null; } public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, System.Globalization.NumberStyles style, System.IFormatProvider? provider, out System.Runtime.InteropServices.NFloat result) { throw null; } public static bool TryParse([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] string? s, out System.Runtime.InteropServices.NFloat result) { throw null; } +#endif // FEATURE_NFLOAT } [System.AttributeUsageAttribute(System.AttributeTargets.Parameter, Inherited=false)] public sealed partial class OptionalAttribute : System.Attribute diff --git a/src/libraries/System.Runtime.InteropServices/src/MatchingRefApiCompatBaseline.txt b/src/libraries/System.Runtime.InteropServices/src/MatchingRefApiCompatBaseline.txt index dd2e06b69c3c29..7f9c02ebeff296 100644 --- a/src/libraries/System.Runtime.InteropServices/src/MatchingRefApiCompatBaseline.txt +++ b/src/libraries/System.Runtime.InteropServices/src/MatchingRefApiCompatBaseline.txt @@ -8,4 +8,80 @@ TypesMustExist : Type 'System.Runtime.InteropServices.RegistrationClassContext' TypesMustExist : Type 'System.Runtime.InteropServices.RegistrationConnectionType' does not exist in the reference but it does exist in the implementation. TypesMustExist : Type 'System.Runtime.InteropServices.SetWin32ContextInIDispatchAttribute' does not exist in the reference but it does exist in the implementation. MembersMustExist : Member 'public void System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute..ctor()' does not exist in the reference but it does exist in the implementation. -Total Issues: 9 +CannotRemoveBaseTypeOrInterface : Type 'System.Runtime.InteropServices.NFloat' does not implement interface 'System.IComparable' in the reference but it does in the implementation. +MembersMustExist : Member 'public System.Int32 System.Runtime.InteropServices.NFloat.CompareTo(System.Object)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Int32 System.Runtime.InteropServices.NFloat.CompareTo(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.Epsilon.get()' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.IsFinite(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.IsInfinity(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.IsNaN(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.IsNegative(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.IsNegativeInfinity(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.IsNormal(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.IsPositiveInfinity(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.IsSubnormal(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.MaxValue.get()' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.MinValue.get()' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.NaN.get()' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.NegativeInfinity.get()' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Addition(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Decrement(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Division(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_Equality(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation.C:\Users\tagoo\.nuget\packages\microsoft.dotnet.apicompat\6.0.0-beta.21614.2\build\Microsoft.DotNet.ApiCompat.targets(145,5): error : MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Explicit(System.Decimal)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Explicit(System.Double)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Byte System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Char System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Decimal System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Int16 System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Int32 System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Int64 System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.IntPtr System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.SByte System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Single System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.UInt16 System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.UInt32 System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.UInt64 System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.UIntPtr System.Runtime.InteropServices.NFloat.op_Explicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_GreaterThan(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_GreaterThanOrEqual(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.Byte)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.Char)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.Int16)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.Int32)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.Int64)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.IntPtr)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Double System.Runtime.InteropServices.NFloat.op_Implicit(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.SByte)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.Single)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.UInt16)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.UInt32)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.UInt64)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Implicit(System.UIntPtr)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Increment(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_Inequality(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_LessThan(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation.C:\Users\tagoo\.nuget\packages\microsoft.dotnet.apicompat\6.0.0-beta.21614.2\build\Microsoft.DotNet.ApiCompat.targets(145,5): error : MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_LessThanOrEqual(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Modulus(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Multiply(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Subtraction(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_UnaryNegation(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_UnaryPlus(System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.Parse(System.ReadOnlySpan, System.Globalization.NumberStyles, System.IFormatProvider)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.Parse(System.String)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.Parse(System.String, System.Globalization.NumberStyles)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.Parse(System.String, System.Globalization.NumberStyles, System.IFormatProvider)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.Parse(System.String, System.IFormatProvider)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.PositiveInfinity.get()' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Int32 System.Runtime.InteropServices.NFloat.Size.get()' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.String System.Runtime.InteropServices.NFloat.ToString(System.IFormatProvider)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.String System.Runtime.InteropServices.NFloat.ToString(System.String)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.String System.Runtime.InteropServices.NFloat.ToString(System.String, System.IFormatProvider)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.TryFormat(System.Span, System.Int32, System.ReadOnlySpan, System.IFormatProvider)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.TryParse(System.ReadOnlySpan, System.Globalization.NumberStyles, System.IFormatProvider, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.TryParse(System.ReadOnlySpan, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.TryParse(System.String, System.Globalization.NumberStyles, System.IFormatProvider, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.TryParse(System.String, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_Equality(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Runtime.InteropServices.NFloat System.Runtime.InteropServices.NFloat.op_Explicit(System.Decimal)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_LessThan(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Runtime.InteropServices.NFloat.op_LessThanOrEqual(System.Runtime.InteropServices.NFloat, System.Runtime.InteropServices.NFloat)' does not exist in the reference but it does exist in the implementation. +Total Issues: 85 diff --git a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs index 6f97497fe03c7c..b56ee77c890039 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs @@ -47,6 +47,76 @@ public void Ctor_Double_LargeValue() Assert.Equal(double.MaxValue, result.Value); } + public static IEnumerable EqualsData() + { + yield return new object[] { new NFloat(789.0f), new NFloat(789.0f), true }; + yield return new object[] { new NFloat(789.0f), new NFloat(-789.0f), false }; + yield return new object[] { new NFloat(789.0f), new NFloat(0.0f), false }; + yield return new object[] { new NFloat(789.0f), 789.0f, false }; + yield return new object[] { new NFloat(789.0f), "789.0", false }; + } + + [Theory] + [MemberData(nameof(EqualsData))] + public void EqualsTest(NFloat f1, object obj, bool expected) + { + if (obj is NFloat f2) + { + Assert.Equal(expected, f1.Equals((object)f2)); + Assert.Equal(expected, f1.Equals(f2)); + Assert.Equal(expected, f1.GetHashCode().Equals(f2.GetHashCode())); + } + Assert.Equal(expected, f1.Equals(obj)); + } + + [Fact] + public void NaNEqualsTest() + { + NFloat f1 = new NFloat(float.NaN); + NFloat f2 = new NFloat(float.NaN); + Assert.Equal(f1.Value.Equals(f2.Value), f1.Equals(f2)); + } + + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.Is64BitProcess))] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + [InlineData(float.NaN)] + public static void ToStringTest64(float value) + { + NFloat nfloat = new NFloat(value); + + Assert.Equal(((double)value).ToString(), nfloat.ToString()); + } + + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.Is32BitProcess))] + [InlineData(-4567.0f)] + [InlineData(-4567.89101f)] + [InlineData(0.0f)] + [InlineData(4567.0f)] + [InlineData(4567.89101f)] + + [InlineData(float.NaN)] + public static void ToStringTest32(float value) + { + NFloat nfloat = new NFloat(value); + + Assert.Equal(value.ToString(), nfloat.ToString()); + } + + [Fact] + public unsafe void Size() + { + int size = PlatformDetection.Is32BitProcess ? 4 : 8; +#pragma warning disable xUnit2000 // The value under test here is the sizeof expression + Assert.Equal(size, sizeof(NFloat)); +#pragma warning restore xUnit2000 + Assert.Equal(size, Marshal.SizeOf()); + } + +#if FEATURE_NFLOAT [Fact] public void Epsilon() { @@ -129,16 +199,6 @@ public void PositiveInfinity() } } - [Fact] - public unsafe void Size() - { - int size = PlatformDetection.Is32BitProcess ? 4 : 8; -#pragma warning disable xUnit2000 // The value under test here is the sizeof expression - Assert.Equal(size, sizeof(NFloat)); -#pragma warning restore xUnit2000 - Assert.Equal(size, Marshal.SizeOf()); - } - [Theory] [InlineData(-4567.0f)] [InlineData(-4567.89101f)] @@ -854,64 +914,6 @@ public void IsSubnormal(float value) Assert.Equal(float.IsSubnormal(value), result); } } - - public static IEnumerable EqualsData() - { - yield return new object[] { new NFloat(789.0f), new NFloat(789.0f), true }; - yield return new object[] { new NFloat(789.0f), new NFloat(-789.0f), false }; - yield return new object[] { new NFloat(789.0f), new NFloat(0.0f), false }; - yield return new object[] { new NFloat(789.0f), 789.0f, false }; - yield return new object[] { new NFloat(789.0f), "789.0", false }; - } - - [Theory] - [MemberData(nameof(EqualsData))] - public void EqualsTest(NFloat f1, object obj, bool expected) - { - if (obj is NFloat f2) - { - Assert.Equal(expected, f1.Equals((object)f2)); - Assert.Equal(expected, f1.Equals(f2)); - Assert.Equal(expected, f1.GetHashCode().Equals(f2.GetHashCode())); - } - Assert.Equal(expected, f1.Equals(obj)); - } - - [Fact] - public void NaNEqualsTest() - { - NFloat f1 = new NFloat(float.NaN); - NFloat f2 = new NFloat(float.NaN); - Assert.Equal(f1.Value.Equals(f2.Value), f1.Equals(f2)); - } - - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.Is64BitProcess))] - [InlineData(-4567.0f)] - [InlineData(-4567.89101f)] - [InlineData(0.0f)] - [InlineData(4567.0f)] - [InlineData(4567.89101f)] - [InlineData(float.NaN)] - public static void ToStringTest64(float value) - { - NFloat nfloat = new NFloat(value); - - Assert.Equal(((double)value).ToString(), nfloat.ToString()); - } - - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.Is32BitProcess))] - [InlineData(-4567.0f)] - [InlineData(-4567.89101f)] - [InlineData(0.0f)] - [InlineData(4567.0f)] - [InlineData(4567.89101f)] - - [InlineData(float.NaN)] - public static void ToStringTest32(float value) - { - NFloat nfloat = new NFloat(value); - - Assert.Equal(value.ToString(), nfloat.ToString()); - } +#endif // FEATURE_NFLOAT } } From 1bbb3403ad1a869cfd6765d454017714a571ad62 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 4 Feb 2022 11:15:02 -0800 Subject: [PATCH 9/9] Ensure the test project is using the right path --- .../System.Runtime.InteropServices.Experimental.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime.InteropServices.Experimental/tests/System.Runtime.InteropServices.Experimental.Tests.csproj b/src/libraries/System.Runtime.InteropServices.Experimental/tests/System.Runtime.InteropServices.Experimental.Tests.csproj index d5206ce5dab7a3..4ba1eb05337439 100644 --- a/src/libraries/System.Runtime.InteropServices.Experimental/tests/System.Runtime.InteropServices.Experimental.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices.Experimental/tests/System.Runtime.InteropServices.Experimental.Tests.csproj @@ -10,6 +10,6 @@ $(DefineConstants);FEATURE_NFLOAT - +