Use primary constructors in published projects

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-20 23:06:21 +01:00
1 親 531e3c3b35
コミット 46a6b25756
54ファイル変更
+210 -564

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

+3 -11
ファイルの表示
@@ -24,20 +24,12 @@ namespace ComputeSharp.D2D1;
/// This attribute can also be added to a whole assembly, and will be used by default if not overridden by a shader type.
/// </para>
/// </summary>
/// <param name="options">The compiler options to use to compile the shader.</param>
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = false)]
public sealed class D2DCompileOptionsAttribute : Attribute
public sealed class D2DCompileOptionsAttribute(D2D1CompileOptions options) : Attribute
{
/// <summary>
/// Creates a new <see cref="D2DCompileOptionsAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="options">The compiler options to use to compile the shader.</param>
public D2DCompileOptionsAttribute(D2D1CompileOptions options)
{
Options = options;
}
/// <summary>
/// Gets the number of threads in each thread group for the X axis
/// </summary>
public D2D1CompileOptions Options { get; }
public D2D1CompileOptions Options => options;
}
+3 -11
ファイルの表示
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
/// <remarks>
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
/// </remarks>
/// <param name="value">The value for the author.</param>
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = false)]
public sealed class D2DEffectAuthorAttribute : Attribute
public sealed class D2DEffectAuthorAttribute(string value) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DEffectAuthorAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="value">The value for the author.</param>
public D2DEffectAuthorAttribute(string value)
{
Value = value;
}
/// <summary>
/// Gets the author value.
/// </summary>
public string Value { get; }
public string Value => value;
}
+3 -11
ファイルの表示
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
/// <remarks>
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
/// </remarks>
/// <param name="value">The value for the category.</param>
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = false)]
public sealed class D2DEffectCategoryAttribute : Attribute
public sealed class D2DEffectCategoryAttribute(string value) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DEffectCategoryAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="value">The value for the category.</param>
public D2DEffectCategoryAttribute(string value)
{
Value = value;
}
/// <summary>
/// Gets the category value.
/// </summary>
public string Value { get; }
public string Value => value;
}
+3 -11
ファイルの表示
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
/// <remarks>
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
/// </remarks>
/// <param name="value">The value for the description.</param>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class D2DEffectDescriptionAttribute : Attribute
public sealed class D2DEffectDescriptionAttribute(string value) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DEffectDescriptionAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="value">The value for the description.</param>
public D2DEffectDescriptionAttribute(string value)
{
Value = value;
}
/// <summary>
/// Gets the description value.
/// </summary>
public string Value { get; }
public string Value => value;
}
+3 -11
ファイルの表示
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
/// <remarks>
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
/// </remarks>
/// <param name="value">The value for the display name.</param>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class D2DEffectDisplayNameAttribute : Attribute
public sealed class D2DEffectDisplayNameAttribute(string value) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DEffectDisplayNameAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="value">The value for the display name.</param>
public D2DEffectDisplayNameAttribute(string value)
{
Value = value;
}
/// <summary>
/// Gets the display name value.
/// </summary>
public string Value { get; }
public string Value => value;
}
+3 -11
ファイルの表示
@@ -8,20 +8,12 @@ namespace ComputeSharp.D2D1;
/// <remarks>
/// This only applies to effects created from <see cref="Interop.D2D1PixelShaderEffect"/>.
/// </remarks>
/// <param name="value">The value for the effect id.</param>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class D2DEffectIdAttribute : Attribute
public sealed class D2DEffectIdAttribute(string value) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DEffectIdAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="value">The value for the effect id.</param>
public D2DEffectIdAttribute(string value)
{
Value = Guid.Parse(value);
}
/// <summary>
/// Gets the effect id value.
/// </summary>
public Guid Value { get; }
public Guid Value { get; } = Guid.Parse(value);
}
+3 -11
ファイルの表示
@@ -10,20 +10,12 @@ namespace ComputeSharp.D2D1;
/// <para>This attribute directly maps to <c>#define D2D_INPUT&lt;N&gt;_COMPLEX</c>.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/en-us/windows/win32/direct2d/hlsl-helpers"/>.</para>
/// </remarks>
/// <param name="index">The index of the resource to declare as using complex sampling.</param>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = true)]
public sealed class D2DInputComplexAttribute : Attribute
public sealed class D2DInputComplexAttribute(int index) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DInputComplexAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="index">The index of the resource to declare as using complex sampling.</param>
public D2DInputComplexAttribute(int index)
{
Index = index;
}
/// <summary>
/// Gets the index of the resource declared as using complex sampling.
/// </summary>
public int Index { get; }
public int Index => index;
}
+3 -11
ファイルの表示
@@ -10,20 +10,12 @@ namespace ComputeSharp.D2D1;
/// <para>This attribute directly maps to <c>#define D2D_INPUT_COUNT &lt;N&gt;</c>.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/en-us/windows/win32/direct2d/hlsl-helpers"/>.</para>
/// </remarks>
/// <param name="count">The number of texture inputs for the shader.</param>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class D2DInputCountAttribute : Attribute
public sealed class D2DInputCountAttribute(int count) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DInputCountAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="count">The number of texture inputs for the shader.</param>
public D2DInputCountAttribute(int count)
{
Count = count;
}
/// <summary>
/// Gets the number of texture inputs for the shader.
/// </summary>
public int Count { get; }
public int Count => count;
}
+5 -14
ファイルの表示
@@ -10,29 +10,20 @@ namespace ComputeSharp.D2D1;
/// <para>This attribute exposes the options that can be set via <c>D2D1_INPUT_DESCRIPTION</c>.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/ns-d2d1effectauthor-d2d1_input_description"/>.</para>
/// </remarks>
/// <param name="index">The index of the resource to declare the description for.</param>
/// <param name="filter">The type of filter to apply to the input texture.</param>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = true)]
public sealed class D2DInputDescriptionAttribute : Attribute
public sealed class D2DInputDescriptionAttribute(int index, D2D1Filter filter) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DInputDescriptionAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="index">The index of the resource to declare the description for.</param>
/// <param name="filter">The type of filter to apply to the input texture.</param>
public D2DInputDescriptionAttribute(int index, D2D1Filter filter)
{
Index = index;
Filter = filter;
}
/// <summary>
/// Gets the index of the resource to declare the description for.
/// </summary>
public int Index { get; }
public int Index => index;
/// <summary>
/// Gets the type of filter to apply to the input texture.
/// </summary>
public D2D1Filter Filter { get; }
public D2D1Filter Filter => filter;
/// <summary>
/// Gets the mip level to retrieve from the upstream transform, if specified.
+3 -11
ファイルの表示
@@ -10,20 +10,12 @@ namespace ComputeSharp.D2D1;
/// <para>This attribute directly maps to <c>#define D2D_INPUT&lt;N&gt;_SIMPLE</c>.</para>
/// <para>For more info, see <see href="https://docs.microsoft.com/en-us/windows/win32/direct2d/hlsl-helpers"/>.</para>
/// </remarks>
/// <param name="index">The index of the resource to declare as using simple sampling.</param>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = true)]
public sealed class D2DInputSimpleAttribute : Attribute
public sealed class D2DInputSimpleAttribute(int index) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DInputSimpleAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="index">The index of the resource to declare as using simple sampling.</param>
public D2DInputSimpleAttribute(int index)
{
Index = index;
}
/// <summary>
/// Gets the index of the resource declared as using simple sampling.
/// </summary>
public int Index { get; }
public int Index => index;
}
+3 -11
ファイルの表示
@@ -9,20 +9,12 @@ namespace ComputeSharp.D2D1;
/// <remarks>
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/ne-d2d1effectauthor-d2d1_pixel_options"/>.
/// </remarks>
/// <param name="options">The options to specify for the shader.</param>
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class D2DPixelOptionsAttribute : Attribute
public sealed class D2DPixelOptionsAttribute(D2D1PixelOptions options) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DPixelOptionsAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="options">The options to specify for the shader.</param>
public D2DPixelOptionsAttribute(D2D1PixelOptions options)
{
Options = options;
}
/// <summary>
/// Gets the options to specify for the shader.
/// </summary>
public D2D1PixelOptions Options { get; }
public D2D1PixelOptions Options => options;
}
+3 -11
ファイルの表示
@@ -32,20 +32,12 @@ namespace ComputeSharp.D2D1;
/// to further customize the shader profile to use when compiling the HLSL source, and the compile options to use.
/// </para>
/// </summary>
/// <param name="hlslSource">The number of texture inputs for the shader.</param>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class D2DPixelShaderSourceAttribute : Attribute
public sealed class D2DPixelShaderSourceAttribute([StringSyntax("Hlsl")] string hlslSource) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DPixelShaderSourceAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="hlslSource">The number of texture inputs for the shader.</param>
public D2DPixelShaderSourceAttribute([StringSyntax("Hlsl")] string hlslSource)
{
HlslSource = hlslSource;
}
/// <summary>
/// Gets the number of texture inputs for the shader.
/// </summary>
public string HlslSource { get; }
public string HlslSource => hlslSource;
}
+3 -11
ファイルの表示
@@ -9,20 +9,12 @@ namespace ComputeSharp.D2D1;
/// <remarks>
/// <para>For more info, see <see href="https://docs.microsoft.com/windows/win32/api/d2d1effectauthor/nf-d2d1effectauthor-id2d1drawinfo-setresourcetexture"/>.</para>
/// </remarks>
/// <param name="index">The index of the annotated resource field.</param>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public sealed class D2DResourceTextureIndexAttribute : Attribute
public sealed class D2DResourceTextureIndexAttribute(int index) : Attribute
{
/// <summary>
/// Creates a new instance of the <see cref="D2DResourceTextureIndexAttribute"/> type with the specified arguments.
/// </summary>
/// <param name="index">The index of the annotated resource field.</param>
public D2DResourceTextureIndexAttribute(int index)
{
Index = index;
}
/// <summary>
/// Gets the index of the annotated resource field.
/// </summary>
public int Index { get; }
public int Index => index;
}
+3 -11
ファイルの表示
@@ -24,20 +24,12 @@ namespace ComputeSharp.D2D1;
/// This attribute can also be added to a whole assembly, and will be used by default if not overridden by a shader type.
/// </para>
/// </summary>
/// <param name="shaderProfile">The target shader profile to use to compile the shader.</param>
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Method, AllowMultiple = false)]
public sealed class D2DShaderProfileAttribute : Attribute
public sealed class D2DShaderProfileAttribute(D2D1ShaderProfile shaderProfile) : Attribute
{
/// <summary>
/// Creates a new <see cref="D2DShaderProfileAttribute"/> instance with the specified parameters.
/// </summary>
/// <param name="shaderProfile">The target shader profile to use to compile the shader.</param>
public D2DShaderProfileAttribute(D2D1ShaderProfile shaderProfile)
{
ShaderProfile = shaderProfile;
}
/// <summary>
/// The shader profile used to compile the annotated D2D1 pixel shader.
/// </summary>
public D2D1ShaderProfile ShaderProfile { get; }
public D2D1ShaderProfile ShaderProfile => shaderProfile;
}
+4 -12
ファイルの表示
@@ -10,7 +10,8 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Buffers;
/// <summary>
/// Represents a heap-based, array-backed output sink into which binary data can be written.
/// </summary>
internal ref struct ArrayPoolBinaryWriter
/// <param name="capacity">The initial capacity of the writer object.</param>
internal ref struct ArrayPoolBinaryWriter(int capacity)
{
/// <summary>
/// The default buffer size to use to expand empty arrays.
@@ -20,21 +21,12 @@ internal ref struct ArrayPoolBinaryWriter
/// <summary>
/// The underlying <see cref="byte"/> array.
/// </summary>
private byte[]? array;
private byte[]? array = ArrayPool<byte>.Shared.Rent(capacity);
/// <summary>
/// The starting offset within <see cref="array"/>.
/// </summary>
private int index;
/// <summary>
/// Initializes a new instance of the <see cref="ArrayPoolBinaryWriter"/> type.
/// </summary>
public ArrayPoolBinaryWriter(int capacity)
{
this.array = ArrayPool<byte>.Shared.Rent(capacity);
this.index = 0;
}
private int index = 0;
/// <summary>
/// Gets the data written to the underlying buffer so far, as a <see cref="ReadOnlySpan{T}"/>.
+2
ファイルの表示
@@ -1,5 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE0290
namespace ComputeSharp.D2D1.Interop;
/// <summary>
+2
ファイルの表示
@@ -1,5 +1,7 @@
using System.Runtime.InteropServices;
#pragma warning disable IDE0290
namespace ComputeSharp.D2D1.Interop;
/// <summary>
+7 -26
ファイルの表示
@@ -8,36 +8,17 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Helpers;
/// <summary>
/// A 64-bit version of the <see cref="Point"/> type.
/// </summary>
internal readonly struct Point64
/// <param name="x">The horizontal coordinate of the point.</param>
/// <param name="y">The vertical coordinate of the point.</param>
internal readonly struct Point64(long x, long y)
{
/// <summary>
/// The left coordinate of the current point.
/// </summary>
private readonly long x;
/// <summary>
/// The top coordinate of the current point.
/// </summary>
private readonly long y;
/// <summary>
/// Creates a new <see cref="Point64"/> instance with the specified parameters.
/// </summary>
/// <param name="x">The horizontal coordinate of the point.</param>
/// <param name="y">The vertical coordinate of the point.</param>
public Point64(long x, long y)
{
this.x = x;
this.y = y;
}
/// <summary>
/// Gets the horizontal coordinate of the current point.
/// </summary>
public readonly long X
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.x;
get => x;
}
/// <summary>
@@ -46,7 +27,7 @@ internal readonly struct Point64
public readonly long Y
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.y;
get => y;
}
/// <summary>
@@ -77,7 +58,7 @@ internal readonly struct Point64
// [ M21, M22 ]
// [ x, y] [ M31, M32 ] = [ x * M11 + y * M21 + M31, x * M12 + y * M22 + m32]
return (
Math.Round(((double)this.x * matrix.M11) + ((double)this.y * matrix.M21) + matrix.M31),
Math.Round(((double)this.x * matrix.M12) + ((double)this.y * matrix.M22) + matrix.M32));
Math.Round(((double)x * matrix.M11) + ((double)y * matrix.M21) + matrix.M31),
Math.Round(((double)x * matrix.M12) + ((double)y * matrix.M22) + matrix.M32));
}
}
+19 -37
ファイルの表示
@@ -7,42 +7,21 @@ namespace ComputeSharp.D2D1.Shaders.Interop.Helpers;
/// <summary>
/// A 64-bit version of the <see cref="Rectangle"/> type.
/// </summary>
internal struct Rectangle64
/// <param name="x">The left coordinate of the rectangle.</param>
/// <param name="y">The top coordinate of the rectangle.</param>
/// <param name="width">The width of the rectangle.</param>
/// <param name="height">The height of the rectangle.</param>
internal struct Rectangle64(long x, long y, long width, long height)
{
/// <summary>
/// The left coordinate of the current rectangle.
/// </summary>
private long x;
private long x = x;
/// <summary>
/// The top coordinate of the current rectangle.
/// </summary>
private long y;
/// <summary>
/// The width of the current rectangle.
/// </summary>
private long width;
/// <summary>
/// The height of the current rectangle.
/// </summary>
private long height;
/// <summary>
/// Creates a new <see cref="Rectangle64"/> instance with the specified parameters.
/// </summary>
/// <param name="x">The left coordinate of the rectangle.</param>
/// <param name="y">The top coordinate of the rectangle.</param>
/// <param name="width">The width of the rectangle.</param>
/// <param name="height">The height of the rectangle.</param>
public Rectangle64(long x, long y, long width, long height)
{
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
private long y = y;
/// <summary>
/// Gets the left coordinate of the current rectangle.
@@ -68,7 +47,7 @@ internal struct Rectangle64
public readonly long Right
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.x + this.width;
get => this.x + width;
}
/// <summary>
@@ -77,7 +56,7 @@ internal struct Rectangle64
public readonly long Bottom
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this.y + this.height;
get => this.y + height;
}
/// <summary>
@@ -102,8 +81,9 @@ internal struct Rectangle64
this.x = left;
this.y = top;
this.width = right - left;
this.height = bottom - top;
width = right - left;
height = bottom - top;
}
/// <summary>
@@ -119,8 +99,9 @@ internal struct Rectangle64
this.x = left;
this.y = top;
this.width = Math.Max(right - left, 0);
this.height = Math.Max(bottom - top, 0);
width = Math.Max(right - left, 0);
height = Math.Max(bottom - top, 0);
}
/// <summary>
@@ -134,8 +115,9 @@ internal struct Rectangle64
{
this.x -= left;
this.y -= top;
this.width += left + right;
this.height += top + bottom;
width += left + right;
height += top + bottom;
}
/// <summary>
@@ -146,7 +128,7 @@ internal struct Rectangle64
{
Intersect(new Rectangle64(int.MinValue / 2, int.MinValue / 2, int.MaxValue, int.MaxValue));
return new((int)this.x, (int)this.y, (int)this.width, (int)this.height);
return new((int)this.x, (int)this.y, (int)width, (int)height);
}
/// <summary>