Target TerraFX.Interop.Windows to .NET Standard 2.0

このコミットが含まれているのは:
Sergio Pedri committed 2021-11-16 14:05:59 +01:00
1 親 22a12e0e5d
コミット 9c6826dbda
190ファイル変更
+4588 -4374

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

+23
ファイルの表示
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>a5997814-d8d2-4541-87ac-c3e53caa67c0</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>ComputeSharp.NetStandard</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)System\IntPtrExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\FormatExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\MemoryMarshal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\RuntimeHelpers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\OSPlatformAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Versioning\SupportedOSVersionAttribute.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\" />
<Folder Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\" />
</ItemGroup>
</Project>
+13
ファイルの表示
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>a5997814-d8d2-4541-87ac-c3e53caa67c0</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="ComputeSharp.NetStandard.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
+23
ファイルの表示
@@ -0,0 +1,23 @@
using System.Runtime.CompilerServices;
namespace System;
/// <summary>
/// A polyfill type with additional formatting extensions.
/// </summary>
internal static class FormatExtensions
{
/// <inheritdoc cref="IFormattable.ToString(string?, IFormatProvider?)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToString<T>(this T value, string? format)
{
throw new NotSupportedException("This API is not supported on this target.");
}
/// <inheritdoc cref="IFormattable.ToString(string?, IFormatProvider?)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToString<T>(this T value, string? format, IFormatProvider? formatProvider)
{
throw new NotSupportedException("This API is not supported on this target.");
}
}
+23
ファイルの表示
@@ -0,0 +1,23 @@
using System.Runtime.CompilerServices;
namespace System;
/// <summary>
/// A polyfill type with extensions for <see cref="nint"/> and <see cref="nuint"/>.
/// </summary>
internal static class IntPtrExtensions
{
/// <inheritdoc cref="IComparable{T}.CompareTo(T?)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CompareTo(this nint left, nint right)
{
return left.CompareTo(right);
}
/// <inheritdoc cref="IComparable{T}.CompareTo(T?)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int CompareTo(this nuint left, nuint right)
{
return left.CompareTo(right);
}
}
+18
ファイルの表示
@@ -0,0 +1,18 @@
using System;
using System.Runtime.InteropServices;
namespace ComputeSharp.NetStandard.System.Runtime.CompilerServices;
/// <summary>
/// A polyfill type that mirrors some methods from <see cref="RuntimeHelpers"/> on .NET 5.
/// </summary>
internal static class RuntimeHelpers
{
/// <summary>
/// Allocates some memory tied to the lifetime of a specific type.
/// </summary>
/// <param name="type">The type to associate the memory to.</param>
/// <param name="size">The size in byte of the memory to allocate.</param>
/// <returns>A pointer to the allocated memory.</returns>
public static IntPtr AllocateTypeAssociatedMemory(Type type, int size) => Marshal.AllocHGlobal(size);
}
+36
ファイルの表示
@@ -0,0 +1,36 @@
using System;
using System.Runtime.CompilerServices;
namespace ComputeSharp.NetStandard.System.Runtime.InteropServices;
/// <summary>
/// A polyfill type that mirrors some methods from <see cref="MemoryMarshal"/> on .NET 6.
/// </summary>
internal static class MemoryMarshal
{
/// <inheritdoc cref="global::System.Runtime.InteropServices.MemoryMarshal.GetReference{T}(Span{T})"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetReference<T>(Span<T> span)
{
return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
}
/// <inheritdoc cref="global::System.Runtime.InteropServices.MemoryMarshal.GetReference{T}(ReadOnlySpan{T})"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetReference<T>(ReadOnlySpan<T> span)
{
return ref global::System.Runtime.InteropServices.MemoryMarshal.GetReference(span);
}
/// <summary>
/// Creates a new <see cref="Span{T}"/> from a given reference.
/// </summary>
/// <typeparam name="T">The type of reference to wrap.</typeparam>
/// <param name="value">The target reference.</param>
/// <param name="length">The length of the <see cref="Span{T}"/> to create.</param>
/// <returns>A new <see cref="Span{T}"/> wrapping <paramref name="value"/>.</returns>
public static unsafe Span<T> CreateSpan<T>(ref T value, int length)
{
return new(Unsafe.AsPointer(ref value), length);
}
}
+15
ファイルの表示
@@ -0,0 +1,15 @@
namespace System.Runtime.Versioning;
/// <summary>
/// Base type for all platform-specific API attributes.
/// </summary>
internal abstract class OSPlatformAttribute : Attribute
{
private protected OSPlatformAttribute(string platformName)
{
PlatformName = platformName;
}
public string PlatformName { get; }
}
@@ -0,0 +1,32 @@
namespace System.Runtime.Versioning;
/// <summary>
/// Records the operating system (and minimum version) that supports an API. Multiple
/// attributes can be applied to indicate support on multiple operating systems.
/// </summary>
/// <remarks>
/// Callers can apply a <see cref="SupportedOSPlatformAttribute " />
/// or use guards to prevent calls to APIs on unsupported operating systems.
/// A given platform should only be specified once.
/// </remarks>
[AttributeUsage(AttributeTargets.Assembly |
AttributeTargets.Class |
AttributeTargets.Constructor |
AttributeTargets.Enum |
AttributeTargets.Event |
AttributeTargets.Field |
AttributeTargets.Interface |
AttributeTargets.Method |
AttributeTargets.Module |
AttributeTargets.Property |
AttributeTargets.Struct,
AllowMultiple = true,
Inherited = false)]
internal sealed class SupportedOSPlatformAttribute : OSPlatformAttribute
{
public SupportedOSPlatformAttribute(string platformName)
: base(platformName)
{
}
}