Move primitives to ComputeSharp.Core
このコミットが含まれているのは:
1 親
cc298770ca
コミット
e48949cd48
78ファイル変更
+369
-245
検索条件に一致するファイルはありません
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
<HasSharedItems>true</HasSharedItems>
|
||||
<SharedGUID>3acacf03-6b20-40ba-b8ec-11ac1624d2c9</SharedGUID>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<Import_RootNamespace>ComputeSharp.Core.NetStandard</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\InteropServices\MemoryMarshal.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime.CompilerServices\InterpolatedStringHandlerArgumentAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime.CompilerServices\InterpolatedStringHandlerAttribute.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime.CompilerServices\RuntimeHelpers.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -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>3acacf03-6b20-40ba-b8ec-11ac1624d2c9</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.Core.NetStandard.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ComputeSharp.Core.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);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates which arguments to a method involving an interpolated string handler should be passed to that handler.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InterpolatedStringHandlerArgumentAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="argument">The name of the argument that should be passed to the handler.</param>
|
||||
/// <remarks><see langword="null"/> may be used as the name of the receiver in an instance method.</remarks>
|
||||
public InterpolatedStringHandlerArgumentAttribute(string argument) => Arguments = new string[] { argument };
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="InterpolatedStringHandlerArgumentAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="arguments">The names of the arguments that should be passed to the handler.</param>
|
||||
/// <remarks><see langword="null"/> may be used as the name of the receiver in an instance method.</remarks>
|
||||
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) => Arguments = arguments;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the names of the arguments that should be passed to the handler.
|
||||
/// </summary>
|
||||
/// <remarks><see langword="null"/> may be used as the name of the receiver in an instance method.</remarks>
|
||||
public string[] Arguments { get; }
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
namespace System.Runtime.CompilerServices;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the attributed type is to be used as an interpolated string handler.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class InterpolatedStringHandlerAttribute : Attribute
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ComputeSharp.Core.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);
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする