Add .NET Standard 2.0 target to ComputeSharp.D2D1Interop

このコミットが含まれているのは:
Sergio Pedri committed 2022-04-24 21:03:14 +02:00
1 親 365066cb23
コミット cc298770ca
8ファイル変更
+73 -17

検索条件に一致するファイルはありません

@@ -9,6 +9,9 @@
<Import_RootNamespace>ComputeSharp.D2D1Interop.NetStandard</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\System.Runtime.CompilerServices\RuntimeHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics.CodeAnalysis\DoesNotReturnAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime.CompilerServices\RuntimeHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)..\ComputeSharp.NetStandard\System\Runtime\CompilerServices\IsExternalInit.cs" Link="System\Runtime.CompilerServices\IsExternalInit.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Text\EncodingExtensions.cs" />
</ItemGroup>
</Project>
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Diagnostics.CodeAnalysis;
/// <summary>
/// Applied to a method that will never return under any circumstance.
/// </summary>
/// <remarks>Internal copy from the BCL attribute.</remarks>
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
internal sealed class DoesNotReturnAttribute : Attribute
{
}
+27
ファイルの表示
@@ -0,0 +1,27 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace ComputeSharp.D2D1Interop.NetStandard.System.Text;
/// <summary>
/// A polyfill type that mirrors some methods from <see cref="Encoding"/> on .NET 5.
/// </summary>
internal static class EncodingExtensions
{
/// <summary>
/// Encodes into a span of bytes a set of characters from the specified read-only span.
/// </summary>
/// <param name="encoding">The input <see cref="Encoding"/> instance to use.</param>
/// <param name="chars">The span containing the set of characters to encode.</param>
/// <param name="bytes">The byte span to hold the encoded bytes.</param>
/// <returns>The number of encoded bytes.</returns>
public static unsafe int GetBytes(this Encoding encoding, ReadOnlySpan<char> chars, Span<byte> bytes)
{
fixed (char* charsPtr = &MemoryMarshal.GetReference(chars))
fixed (byte* bytesPtr = &MemoryMarshal.GetReference(bytes))
{
return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length);
}
}
}
+12 -3
ファイルの表示
@@ -1,19 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<OutputPath>bin\Release</OutputPath>
<DocumentationFile>ComputeSharp.D2D1Interop.xml</DocumentationFile>
<Platforms>AnyCPU;x64;ARM64</Platforms>
</PropertyGroup>
<!-- .NET Standard 2.0 polyfill packages -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
</ItemGroup>
<!-- Enable trimming support on .NET 6 -->
<PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<IsTrimmable>true</IsTrimmable>
<!-- Workaround for .NET 6.0.x regression (see https://github.com/dotnet/linker/issues/2642), enable again when fixed in SDK -->
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
</PropertyGroup>
<!-- Shared project with the trimmed down fork of TerraFX.Interop.Windows with just the D3D bindings -->
<Import Project="..\TerraFX.Interop.Windows.D2D1Interop\TerraFX.Interop.Windows.D2D1Interop.projitems" Label="Shared" />
<Import Project="..\ComputeSharp.D2D1Interop.NetStandard\ComputeSharp.D2D1Interop.NetStandard.projitems" Label="Shared" />
<!-- Shared project with .NET Standard 2.0 polyfills -->
<Import Condition="'$(TargetFramework)' == 'netstandard2.0'" Project="..\ComputeSharp.D2D1Interop.NetStandard\ComputeSharp.D2D1Interop.NetStandard.projitems" Label="Shared" />
</Project>
+3
ファイルの表示
@@ -6,6 +6,9 @@ using System.Runtime.InteropServices;
using System.Text;
using ComputeSharp.D2D1Interop.Exceptions;
using ComputeSharp.D2D1Interop.Extensions;
#if !NET6_0_OR_GREATER
using ComputeSharp.D2D1Interop.NetStandard.System.Text;
#endif
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
+1 -1
ファイルの表示
@@ -23,7 +23,7 @@ namespace TerraFX.Interop.DirectX
[VtblIndex(7)]
public HRESULT SetPixelShaderConstantBuffer([NativeTypeName("const BYTE *")] byte* buffer, [NativeTypeName("UINT32")] uint bufferCount)
{
return ((delegate* unmanaged<ID2D1DrawInfo*, byte*, uint, int>)(lpVtbl[7]))((ID2D1DrawInfo*)Unsafe.AsPointer(ref this), buffer, bufferCount);
return ((delegate* unmanaged[Stdcall]<ID2D1DrawInfo*, byte*, uint, int>)(lpVtbl[7]))((ID2D1DrawInfo*)Unsafe.AsPointer(ref this), buffer, bufferCount);
}
}
}
+12 -12
ファイルの表示
@@ -24,7 +24,7 @@ namespace TerraFX.Interop.DirectX
[VtblIndex(0)]
public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, Guid*, void**, int>)(lpVtbl[0]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), riid, ppvObject);
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, Guid*, void**, int>)(lpVtbl[0]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), riid, ppvObject);
}
/// <inheritdoc cref="IUnknown.AddRef" />
@@ -33,7 +33,7 @@ namespace TerraFX.Interop.DirectX
[return: NativeTypeName("ULONG")]
public uint AddRef()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, uint>)(lpVtbl[1]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, uint>)(lpVtbl[1]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
/// <inheritdoc cref="IUnknown.Release" />
@@ -42,63 +42,63 @@ namespace TerraFX.Interop.DirectX
[return: NativeTypeName("ULONG")]
public uint Release()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, uint>)(lpVtbl[2]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, uint>)(lpVtbl[2]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(3)]
public HRESULT GetDesc(D3D11_SHADER_DESC* pDesc)
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, D3D11_SHADER_DESC*, int>)(lpVtbl[3]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), pDesc);
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, D3D11_SHADER_DESC*, int>)(lpVtbl[3]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), pDesc);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(12)]
public uint GetMovInstructionCount()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, uint>)(lpVtbl[12]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, uint>)(lpVtbl[12]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(13)]
public uint GetMovcInstructionCount()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, uint>)(lpVtbl[13]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, uint>)(lpVtbl[13]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(14)]
public uint GetConversionInstructionCount()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, uint>)(lpVtbl[14]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, uint>)(lpVtbl[14]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(15)]
public uint GetBitwiseInstructionCount()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, uint>)(lpVtbl[15]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, uint>)(lpVtbl[15]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(16)]
public D3D_PRIMITIVE GetGSInputPrimitive()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, D3D_PRIMITIVE>)(lpVtbl[16]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, D3D_PRIMITIVE>)(lpVtbl[16]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(18)]
public uint GetNumInterfaceSlots()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, uint>)(lpVtbl[18]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, uint>)(lpVtbl[18]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(20)]
public uint GetThreadGroupSize(uint* pSizeX, uint* pSizeY, uint* pSizeZ)
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, uint*, uint*, uint*, uint>)(lpVtbl[20]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), pSizeX, pSizeY, pSizeZ);
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, uint*, uint*, uint*, uint>)(lpVtbl[20]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), pSizeX, pSizeY, pSizeZ);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -106,7 +106,7 @@ namespace TerraFX.Interop.DirectX
[return: NativeTypeName("UINT64")]
public ulong GetRequiresFlags()
{
return ((delegate* unmanaged<ID3D11ShaderReflection*, ulong>)(lpVtbl[21]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
return ((delegate* unmanaged[Stdcall]<ID3D11ShaderReflection*, ulong>)(lpVtbl[21]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this));
}
}
}