From a855f3a26417a4e71f54fc818dc0ef7d69c0fc50 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 29 Jan 2021 16:20:59 +0100 Subject: [PATCH] =?UTF-8?q?Removed=20.NET=20Standard=202.0=20target=20(?= =?UTF-8?q?=F0=9F=98=A2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComputeSharp.Core.csproj | 8 +- .../ID3D12DescriptorHandleAllocator.cs | 3 - .../ComputeSharp.Graphics.csproj | 2 +- .../Properties/Polyfills.cs | 119 ------------------ .../Resources/Abstract/Buffer{T}.cs | 6 +- .../Resources/Views/BufferDebugView{T}.cs | 8 +- .../ComputeSharp.Shaders.csproj | 2 +- .../Properties/Polyfills.cs | 37 ------ .../ShaderLoader{T}.DispatchData.cs | 6 +- src/ComputeSharp/ComputeSharp.csproj | 2 +- .../Extensions/Buffers/BufferExtensions.cs | 5 - .../ComputeSharp.Tests.Internals.csproj | 2 +- .../ComputeSharp.Tests.csproj | 2 +- 13 files changed, 10 insertions(+), 192 deletions(-) delete mode 100644 src/ComputeSharp.Graphics/Properties/Polyfills.cs delete mode 100644 src/ComputeSharp.Shaders/Properties/Polyfills.cs diff --git a/src/ComputeSharp.Core/ComputeSharp.Core.csproj b/src/ComputeSharp.Core/ComputeSharp.Core.csproj index 4df5b272..40f1ef7d 100644 --- a/src/ComputeSharp.Core/ComputeSharp.Core.csproj +++ b/src/ComputeSharp.Core/ComputeSharp.Core.csproj @@ -1,15 +1,9 @@  - netstandard2.0;net5.0 + net5.0 bin\Release ComputeSharp.Core.xml - - - - - - diff --git a/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs b/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs index 5b869e48..e0b0c05b 100644 --- a/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs +++ b/src/ComputeSharp.Graphics/Commands/Interop/ID3D12DescriptorHandleAllocator.cs @@ -3,9 +3,6 @@ using ComputeSharp.Graphics.Extensions; using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using static TerraFX.Interop.D3D12_DESCRIPTOR_HEAP_TYPE; -#if NETSTANDARD2_0 -using GC = Polyfills.GC; -#endif namespace ComputeSharp.Graphics.Commands.Interop { diff --git a/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj b/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj index 96c738d6..c0bde5ee 100644 --- a/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj +++ b/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net5.0 + net5.0 bin\Release ComputeSharp.Graphics.xml diff --git a/src/ComputeSharp.Graphics/Properties/Polyfills.cs b/src/ComputeSharp.Graphics/Properties/Polyfills.cs deleted file mode 100644 index cfd91f55..00000000 --- a/src/ComputeSharp.Graphics/Properties/Polyfills.cs +++ /dev/null @@ -1,119 +0,0 @@ -#if NETSTANDARD2_0 - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace Polyfills -{ - /// - /// A polyfill class for the type. - /// - internal static class GC - { - /// - /// Allocates an array while skipping zero-initialization, if possible. - /// - /// Specifies the type of the array element. - /// Specifies the length of the array. - /// Specifies whether the allocated array must be pinned. - /// An array object with uninitialized memory, if possible. - public static T[] AllocateUninitializedArray(int length, bool pinned = false) - { - return new T[length]; - } - } - - /// - /// A polyfill class for the type. - /// - internal static class MemoryMarshal - { - /// - /// Returns a reference to the 0th element of array. If the array is empty, returns - /// a reference to where the 0th element would have been stored. Such a reference - /// may be used for pinning but must never be dereferenced. - /// - /// The type of the array elements. - /// The array to analyze. - /// Reference to the 0th element in array. - public static ref T GetArrayDataReference(T[] array) - { - IntPtr offset = TypeInfo.ArrayDataByteOffset; - RawObjectData rawObject = Unsafe.As(array)!; - ref byte r0 = ref rawObject.Data; - ref byte r1 = ref Unsafe.AddByteOffset(ref r0, offset); - ref T r2 = ref Unsafe.As(ref r1); - - return ref r2; - } - - /// - /// A private generic class to preload type info for arbitrary runtime types. - /// - /// The type to load info for. - private static class TypeInfo - { - /// - /// The byte offset to the first element in a SZ array. - /// - public static readonly IntPtr ArrayDataByteOffset = MeasureArrayDataByteOffset(); - - /// - /// Computes the value for . - /// - /// The value of for the current runtime. - private static IntPtr MeasureArrayDataByteOffset() - { - T[] array = new T[1]; - RawObjectData rawObject = Unsafe.As(array)!; - ref byte r0 = ref rawObject.Data; - ref byte r1 = ref Unsafe.As(ref array[0]); - - return Unsafe.ByteOffset(ref r0, ref r1); - } - } - - /// - /// Mapping type for a raw object. - /// - [StructLayout(LayoutKind.Explicit)] - private sealed class RawObjectData - { - [FieldOffset(0)] - public byte Data; - } - } -} - -namespace System.Collections.Generic -{ - /// - /// Extensions for the type. - /// - internal static class QueueExtensions - { - /// - /// Removes the object at the beginning of the instance and copies it to the result parameter. - /// - /// The type of values in the input . - /// The input . - /// The removed object. - /// Whether or not the object was successfully removed. - public static bool TryDequeue(this Queue queue, out T? result) - { - if (queue.Count > 0) - { - result = queue.Dequeue(); - - return true; - } - - result = default; - - return false; - } - } -} - -#endif diff --git a/src/ComputeSharp.Graphics/Resources/Abstract/Buffer{T}.cs b/src/ComputeSharp.Graphics/Resources/Abstract/Buffer{T}.cs index e75240ac..744e26ed 100644 --- a/src/ComputeSharp.Graphics/Resources/Abstract/Buffer{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Abstract/Buffer{T}.cs @@ -1,5 +1,6 @@ using System.Buffers; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Resources.Enums; @@ -7,11 +8,6 @@ using ComputeSharp.Interop; using Microsoft.Toolkit.Diagnostics; using TerraFX.Interop; using FX = TerraFX.Interop.Windows; -#if NET5_0 -using MemoryMarshal = System.Runtime.InteropServices.MemoryMarshal; -#else -using MemoryMarshal = Polyfills.MemoryMarshal; -#endif namespace ComputeSharp.Resources { diff --git a/src/ComputeSharp.Graphics/Resources/Views/BufferDebugView{T}.cs b/src/ComputeSharp.Graphics/Resources/Views/BufferDebugView{T}.cs index bd78980e..2df6d818 100644 --- a/src/ComputeSharp.Graphics/Resources/Views/BufferDebugView{T}.cs +++ b/src/ComputeSharp.Graphics/Resources/Views/BufferDebugView{T}.cs @@ -1,9 +1,5 @@ -using System.Diagnostics; -#if NET5_0 -using GC = System.GC; -#else -using GC = Polyfills.GC; -#endif +using System; +using System.Diagnostics; namespace ComputeSharp.Resources.Views { diff --git a/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj index a0ee85cf..fbf12c54 100644 --- a/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj +++ b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net5.0 + net5.0 bin\Release ComputeSharp.Shaders.xml diff --git a/src/ComputeSharp.Shaders/Properties/Polyfills.cs b/src/ComputeSharp.Shaders/Properties/Polyfills.cs deleted file mode 100644 index 227d8a84..00000000 --- a/src/ComputeSharp.Shaders/Properties/Polyfills.cs +++ /dev/null @@ -1,37 +0,0 @@ -#if NETSTANDARD2_0 - -using System.ComponentModel; - -namespace System.Runtime.CompilerServices -{ - /// - /// Reserved to be used by the compiler for tracking metadata. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - internal static class IsExternalInit - { - } -} - -namespace System.Reflection -{ - /// - /// Extensions for the type. - /// - internal static class MethodInfoExtensions - { - /// - /// Creates a delegate of type T from a given method. - /// - /// The type of delegate to create. - /// The input . - /// The delegate for this method. - public static T CreateDelegate(this MethodInfo method) - where T : Delegate - { - return (T)method.CreateDelegate(typeof(T)); - } - } -} - -#endif diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.DispatchData.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.DispatchData.cs index faddec59..2922a85f 100644 --- a/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.DispatchData.cs +++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader{T}.DispatchData.cs @@ -4,14 +4,10 @@ using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Reflection; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using ComputeSharp.__Internals; using ComputeSharp.Shaders.Translation.Models; using TerraFX.Interop; -#if NET5_0 -using MemoryMarshal = System.Runtime.InteropServices.MemoryMarshal; -#else -using MemoryMarshal = Polyfills.MemoryMarshal; -#endif #pragma warning disable CS0618 diff --git a/src/ComputeSharp/ComputeSharp.csproj b/src/ComputeSharp/ComputeSharp.csproj index 8f1cc533..c9ab3f20 100644 --- a/src/ComputeSharp/ComputeSharp.csproj +++ b/src/ComputeSharp/ComputeSharp.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net5.0 + net5.0 bin\Release ComputeSharp.xml diff --git a/src/ComputeSharp/Extensions/Buffers/BufferExtensions.cs b/src/ComputeSharp/Extensions/Buffers/BufferExtensions.cs index 256c57a2..5fe675bc 100644 --- a/src/ComputeSharp/Extensions/Buffers/BufferExtensions.cs +++ b/src/ComputeSharp/Extensions/Buffers/BufferExtensions.cs @@ -3,11 +3,6 @@ using System.Diagnostics.Contracts; using System.Runtime.InteropServices; using ComputeSharp.Resources; using Microsoft.Toolkit.Diagnostics; -#if NET5_0 -using GC = System.GC; -#else -using GC = Polyfills.GC; -#endif namespace ComputeSharp { diff --git a/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj b/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj index 80cda974..0f9fc9f1 100644 --- a/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj +++ b/tests/ComputeSharp.Tests.Internals/ComputeSharp.Tests.Internals.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;net5.0 + net5.0 false 9.0 diff --git a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj index ee76bc48..dcb51fa4 100644 --- a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj +++ b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1;net5.0 + net5.0 false 9.0