diff --git a/src/ComputeSharp.Core/Extensions/VectorExtensions.cs b/src/ComputeSharp.Core/Extensions/VectorExtensions.cs deleted file mode 100644 index 1c4532ed..00000000 --- a/src/ComputeSharp.Core/Extensions/VectorExtensions.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Diagnostics.Contracts; -using System.Numerics; -using System.Runtime.InteropServices; - -namespace ComputeSharp -{ - /// - /// A that contains extension methods for the , and types - /// - public static class VectorExtensions - { - /// - /// Converts a array into a with items of type - /// - /// The input array - /// A with items of type , mapping the original array - [Pure] - public static Span AsFloat2Span(this Vector2[] array) => MemoryMarshal.Cast(array); - - /// - /// Converts a into a with items of type - /// - /// The input - /// A with items of type , mapping the original - [Pure] - public static Span AsFloat2Span(this Span span) => MemoryMarshal.Cast(span); - - /// - /// Converts a array into a with items of type - /// - /// The input array - /// A with items of type , mapping the original array - [Pure] - public static Span AsFloat3Span(this Vector3[] array) => MemoryMarshal.Cast(array); - - /// - /// Converts a into a with items of type - /// - /// The input - /// A with items of type , mapping the original - [Pure] - public static Span AsFloat3Span(this Span span) => MemoryMarshal.Cast(span); - - /// - /// Converts a array into a with items of type - /// - /// The input array - /// A with items of type , mapping the original array - [Pure] - public static Span AsFloat4Span(this Vector4[] array) => MemoryMarshal.Cast(array); - - /// - /// Converts a into a with items of type - /// - /// The input - /// A with items of type , mapping the original - [Pure] - public static Span AsFloat4Span(this Span span) => MemoryMarshal.Cast(span); - } -} diff --git a/src/ComputeSharp/Extensions/System.Numerics/VectorExtensions.cs b/src/ComputeSharp/Extensions/System.Numerics/VectorExtensions.cs new file mode 100644 index 00000000..2e4352bc --- /dev/null +++ b/src/ComputeSharp/Extensions/System.Numerics/VectorExtensions.cs @@ -0,0 +1,84 @@ +using System.Diagnostics.Contracts; +using ComputeSharp; +using static System.Runtime.InteropServices.MemoryMarshal; + +namespace System.Numerics +{ + /// + /// A that contains extension methods for the , and types. + /// + public static class VectorExtensions + { + /// + /// Converts a array into a with items of type . + /// + /// The input array. + /// A with items of type , mapping the original array. + [Pure] + public static Span AsFloat2Span(this Vector2[] array) => Cast(array); + + /// + /// Converts a into a with items of type + /// + /// The input . + /// A with items of type , mapping the original . + [Pure] + public static ReadOnlySpan AsFloat2Span(this ReadOnlySpan span) => Cast(span); + + /// + /// Converts a into a with items of type . + /// + /// The input . + /// A with items of type , mapping the original . + [Pure] + public static Span AsFloat2Span(this Span span) => Cast(span); + + /// + /// Converts a array into a with items of type . + /// + /// The input array. + /// A with items of type , mapping the original array. + [Pure] + public static Span AsFloat3Span(this Vector3[] array) => Cast(array); + + /// + /// Converts a into a with items of type . + /// + /// The input . + /// A with items of type , mapping the original . + [Pure] + public static ReadOnlySpan AsFloat3Span(this ReadOnlySpan span) => Cast(span); + + /// + /// Converts a into a with items of type . + /// + /// The input . + /// A with items of type , mapping the original . + [Pure] + public static Span AsFloat3Span(this Span span) => Cast(span); + + /// + /// Converts a array into a with items of type . + /// + /// The input array. + /// A with items of type , mapping the original array. + [Pure] + public static Span AsFloat4Span(this Vector4[] array) => Cast(array); + + /// + /// Converts a into a with items of type . + /// + /// The input . + /// A with items of type , mapping the original . + [Pure] + public static ReadOnlySpan AsFloat4Span(this ReadOnlySpan span) => Cast(span); + + /// + /// Converts a into a with items of type . + /// + /// The input . + /// A with items of type , mapping the original . + [Pure] + public static Span AsFloat4Span(this Span span) => Cast(span); + } +} diff --git a/src/ComputeSharp/Extensions/Windows.Foundation/PointExtensions.cs b/src/ComputeSharp/Extensions/Windows.Foundation/PointExtensions.cs index f5be5e01..003a8fbe 100644 --- a/src/ComputeSharp/Extensions/Windows.Foundation/PointExtensions.cs +++ b/src/ComputeSharp/Extensions/Windows.Foundation/PointExtensions.cs @@ -16,7 +16,7 @@ namespace Windows.Foundation /// A value representing the input [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 ToVector2(this in Point value) => new Vector2((float)value.X, (float)value.Y); + public static Vector2 ToVector2(this Point value) => new((float)value.X, (float)value.Y); /// /// Converts a value to a @@ -25,6 +25,6 @@ namespace Windows.Foundation /// A value representing the input [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Point ToPoint(this in Vector2 value) => new Point(value.X, value.Y); + public static Point ToPoint(this Vector2 value) => new(value.X, value.Y); } } diff --git a/src/ComputeSharp/Extensions/Windows.Foundation/RectExtensions.cs b/src/ComputeSharp/Extensions/Windows.Foundation/RectExtensions.cs index 6a46c4d0..3c331463 100644 --- a/src/ComputeSharp/Extensions/Windows.Foundation/RectExtensions.cs +++ b/src/ComputeSharp/Extensions/Windows.Foundation/RectExtensions.cs @@ -17,7 +17,7 @@ namespace Windows.Foundation /// The input is read in the following order: , , , [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector4 ToVector2(this in Rect value) => new Vector4((float)value.Left, (float)value.Top, (float)value.Right, (float)value.Bottom); + public static Vector4 ToVector2(this Rect value) => new((float)value.Left, (float)value.Top, (float)value.Right, (float)value.Bottom); /// /// Converts a value to a @@ -27,6 +27,6 @@ namespace Windows.Foundation /// The input is assigned in the following order: , , , [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Rect ToPoint(this in Vector4 value) => new Rect(value.X, value.Y, value.Z, value.W); + public static Rect ToPoint(this Vector4 value) => new(value.X, value.Y, value.Z, value.W); } } \ No newline at end of file diff --git a/src/ComputeSharp/Extensions/Windows.Foundation/SizeExtensions.cs b/src/ComputeSharp/Extensions/Windows.Foundation/SizeExtensions.cs index 360ef02c..6f3ecdd9 100644 --- a/src/ComputeSharp/Extensions/Windows.Foundation/SizeExtensions.cs +++ b/src/ComputeSharp/Extensions/Windows.Foundation/SizeExtensions.cs @@ -17,7 +17,7 @@ namespace Windows.Foundation /// The input is read in the following order: , [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 ToVector2(this in Size value) => new Vector2((float)value.Width, (float)value.Height); + public static Vector2 ToVector2(this Size value) => new((float)value.Width, (float)value.Height); /// /// Converts a value to a @@ -27,6 +27,6 @@ namespace Windows.Foundation /// The input is assigned in the following order: , [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Size ToPoint(this in Vector2 value) => new Size(value.X, value.Y); + public static Size ToPoint(this Vector2 value) => new(value.X, value.Y); } } \ No newline at end of file