diff --git a/src/ComputeSharp.Core/Exceptions/InvalidExecutionContextException.cs b/src/ComputeSharp.Core/Exceptions/InvalidExecutionContextException.cs index 269e1c65..c1783fe5 100644 --- a/src/ComputeSharp.Core/Exceptions/InvalidExecutionContextException.cs +++ b/src/ComputeSharp.Core/Exceptions/InvalidExecutionContextException.cs @@ -1,6 +1,6 @@ using System; -namespace ComputeSharp.Exceptions; +namespace ComputeSharp; /// /// A custom that indicates when an HLSL-only API is called from C#. @@ -10,9 +10,9 @@ public sealed class InvalidExecutionContextException : InvalidOperationException /// /// Creates a new instance. /// - /// The member name of the caller API. + /// The member name of the invoked API. internal InvalidExecutionContextException(string memberName) - : base($"The API {memberName} can only be used from within an HLSL shader.") + : base("The invoked API can only be used from within an HLSL shader.") { MemberName = memberName; } diff --git a/src/ComputeSharp.Core/Helpers/FormatInterpolatedStringHandler.cs b/src/ComputeSharp.Core/Helpers/FormatInterpolatedStringHandler.cs deleted file mode 100644 index 1edcaf7e..00000000 --- a/src/ComputeSharp.Core/Helpers/FormatInterpolatedStringHandler.cs +++ /dev/null @@ -1,319 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Buffers; -using System.Globalization; -using System.Runtime.InteropServices; - -namespace System.Runtime.CompilerServices; - -/// -/// Provides a handler used by the language compiler to process interpolated strings into instances. -/// -[InterpolatedStringHandler] -internal ref struct FormatInterpolatedStringHandler -{ - /// - /// Minimum size array to rent from the pool. - /// - private const int MinimumArrayPoolLength = 256; - - /// - /// The format to use to print individual values to the target buffer. - /// - private readonly string? format; - - /// - /// Optional provider to pass to calls. - /// - private readonly IFormatProvider? formatProvider; - - /// - /// Array rented from the array pool and used to back . - /// - private char[]? arrayToReturnToPool; - - /// - /// The span to write into. - /// - private Span characters; - - /// - /// Position at which to write the next character. - /// - private int position; - - /// - /// Whether provides an . - /// - private readonly bool hasCustomFormatter; - - /// - /// Creates a handler used to translate an interpolated string into a . - /// - /// The number of constant characters outside of interpolation expressions in the interpolated string. - /// The number of interpolation expressions in the interpolated string. - /// The format to use, if available. - /// An object that supplies culture-specific formatting information. - /// A buffer temporarily transferred to the handler for use as part of its formatting. Contents may be overwritten. - /// This is intended to be called only by compiler-generated code. Arguments are not validated as they'd otherwise be for members intended to be used directly. - public FormatInterpolatedStringHandler(int literalLength, int formattedCount, string? format, IFormatProvider? formatProvider, Span initialBuffer) - { - this.format = format; - this.formatProvider = formatProvider; - this.characters = initialBuffer; - this.arrayToReturnToPool = null; - this.position = 0; - this.hasCustomFormatter = formatProvider is not null && HasCustomFormatter(formatProvider); - } - - /// - /// Creates a new with the specified arguments. - /// - /// The format to use, if available. - /// An object that supplies culture-specific formatting information. - /// A buffer temporarily transferred to the handler for use as part of its formatting. Contents may be overwritten. - /// The input instance responsible for formatting the resulting . - /// The resulting formatted instance. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static string Create( - string? format, - IFormatProvider? formatProvider, - Span initialBuffer, - [InterpolatedStringHandlerArgument("format", "formatProvider", "initialBuffer")] ref FormatInterpolatedStringHandler handler) - { - return handler.ToStringAndClear(); - } - - /// Gets the built and clears the handler. - /// The built string. - /// - /// This releases any resources used by the handler. The method should be invoked only - /// once and as the last thing performed on the handler. Subsequent use is erroneous, ill-defined, - /// and may destabilize the process, as may using any other copies of the handler after ToStringAndClear - /// is called on any one of them. - /// - public string ToStringAndClear() - { -#if NET6_0_OR_GREATER - string result = new(this.characters.Slice(0, this.position)); -#else - string result = this.characters.Slice(0, this.position).ToString(); -#endif - char[]? toReturn = this.arrayToReturnToPool; - - this = default; - - if (toReturn is not null) - { - ArrayPool.Shared.Return(toReturn); - } - - return result; - } - - /// - /// Writes the specified string to the handler. - /// - /// The string to write. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AppendLiteral(string value) - { - if (value.Length == 1) - { - Span chars = this.characters; - int pos = this.position; - - if ((uint)pos < (uint)chars.Length) - { - chars[pos] = value[0]; - - this.position = pos + 1; - } - else - { - GrowThenCopyString(value); - } - - return; - } - - if (value.Length == 2) - { - Span chars = this.characters; - int pos = this.position; - - if ((uint)pos < chars.Length - 1) - { - Unsafe.WriteUnaligned( - ref Unsafe.As(ref Unsafe.Add(ref MemoryMarshal.GetReference(chars), pos)), -#if NET6_0_OR_GREATER - Unsafe.ReadUnaligned(ref Unsafe.As(ref Unsafe.AsRef(in value.GetPinnableReference())))); -#else - Unsafe.ReadUnaligned(ref Unsafe.As(ref MemoryMarshal.GetReference(value.AsSpan())))); -#endif - - this.position = pos + 2; - } - else - { - GrowThenCopyString(value); - } - - return; - } - - AppendStringDirect(value); - } - - /// - /// Writes the specified string to the handler. - /// - /// The string to write. - private void AppendStringDirect(string value) - { -#if NET6_0_OR_GREATER - if (value.TryCopyTo(this.characters.Slice(this.position))) -#else - if (value.AsSpan().TryCopyTo(this.characters.Slice(this.position))) -#endif - { - this.position += value.Length; - } - else - { - GrowThenCopyString(value); - } - } - - /// - /// Writes the specified value to the handler. - /// - /// The value to write. - public void AppendFormatted(string value) - { - AppendLiteral(value); - } - - /// - /// Writes the specified value to the handler. - /// - /// The value to write. - public void AppendFormatted(T value) -#if NET6_0_OR_GREATER - where T : ISpanFormattable -#else - where T : IFormattable -#endif - { - if (this.hasCustomFormatter) - { - AppendCustomFormatter(value, this.format); - return; - } - -#if NET6_0_OR_GREATER - int charsWritten; - - while (!value.TryFormat(this.characters.Slice(this.position), out charsWritten, this.format, this.formatProvider)) - { - Grow(); - } - - this.position += charsWritten; -#else - AppendStringDirect(value.ToString(this.format, this.formatProvider)); -#endif - } - - /// - /// Gets whether the provider provides a custom formatter. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static bool HasCustomFormatter(IFormatProvider provider) - { - return - provider.GetType() != typeof(CultureInfo) && - provider.GetFormat(typeof(ICustomFormatter)) != null; - } - - /// - /// Formats the value using the custom formatter from the provider. - /// - /// The value to write. - /// The format string. - [MethodImpl(MethodImplOptions.NoInlining)] - private void AppendCustomFormatter(T value, string? format) - { - ICustomFormatter? formatter = (ICustomFormatter?)this.formatProvider?.GetFormat(typeof(ICustomFormatter)); - - if (formatter is not null && formatter.Format(format, value, this.formatProvider) is string customFormatted) - { - AppendStringDirect(customFormatted); - } - } - - /// - /// Fallback for fast path in when there's not enough space in the destination. - /// - /// The string to write. - [MethodImpl(MethodImplOptions.NoInlining)] - private void GrowThenCopyString(string value) - { - Grow(value.Length); - -#if NET6_0_OR_GREATER - value.CopyTo(this.characters.Slice(this.position)); -#else - value.AsSpan().CopyTo(this.characters.Slice(this.position)); -#endif - - this.position += value.Length; - } - - /// - /// Grows to have the capacity to store at least beyond . - /// - [MethodImpl(MethodImplOptions.NoInlining)] - private void Grow(int additionalChars) - { - GrowCore((uint)this.position + (uint)additionalChars); - } - -#if NET6_0_OR_GREATER - /// - /// Grows the size of . - /// - [MethodImpl(MethodImplOptions.NoInlining)] - private void Grow() - { - GrowCore((uint)this.characters.Length + 1); - } -#endif - - /// - /// Grow the size of to at least the specified . - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void GrowCore(uint requiredMinCapacity) - { - uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)this.characters.Length * 2, 0x3FFFFFDF)); -#if NET6_0_OR_GREATER - int arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue); -#else - int arraySize = (int)Math.Min(Math.Max(newCapacity, MinimumArrayPoolLength), int.MaxValue); -#endif - char[] newArray = ArrayPool.Shared.Rent(arraySize); - - this.characters.Slice(0, this.position).CopyTo(newArray); - - char[]? toReturn = this.arrayToReturnToPool; - - this.characters = this.arrayToReturnToPool = newArray; - - if (toReturn is not null) - { - ArrayPool.Shared.Return(toReturn); - } - } -} \ No newline at end of file diff --git a/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs b/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs deleted file mode 100644 index 0aec4d5b..00000000 --- a/src/ComputeSharp.Core/Helpers/TryWriteFormatInterpolatedStringHandler.cs +++ /dev/null @@ -1,256 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -namespace System.Runtime.CompilerServices; - -/// -/// Provides a handler used by the language compiler to format interpolated strings into character spans. -/// -[InterpolatedStringHandler] -internal ref struct TryWriteFormatInterpolatedStringHandler -{ - /// - /// The destination buffer. - /// - private readonly Span destination; - - /// - /// The format to use to print individual values to the target buffer. - /// - private readonly ReadOnlySpan format; - - /// - /// The value of , as a . - /// - private string? formatAsString; - - /// - /// Optional provider to pass to calls. - /// - private readonly IFormatProvider? formatProvider; - - /// - /// The number of characters written to . - /// - private int position; - - /// - /// Indicates whether all formatting operations have succeeded. - /// - private bool success; - - /// - /// Whether provides an . - /// - private readonly bool hasCustomFormatter; - - /// - /// Creates a handler used to write an interpolated string into a . - /// - /// The number of constant characters outside of interpolation expressions in the interpolated string. - /// The number of interpolation expressions in the interpolated string. - /// The destination buffer. - /// The format to use, if available. - /// An object that supplies culture-specific formatting information. - /// Upon return, true if the destination may be long enough to support the formatting, or false if it won't be. - /// This is intended to be called only by compiler-generated code. Arguments are not validated as they'd otherwise be for members intended to be used directly. - public TryWriteFormatInterpolatedStringHandler(int literalLength, int formattedCount, Span destination, ReadOnlySpan format, IFormatProvider? formatProvider, out bool shouldAppend) - { - this.destination = destination; - this.format = format; - this.formatAsString = null; - this.formatProvider = formatProvider; - this.position = 0; - this.success = shouldAppend = destination.Length >= literalLength; - this.hasCustomFormatter = formatProvider is not null && FormatInterpolatedStringHandler.HasCustomFormatter(formatProvider); - } - - /// - /// Writes the specified interpolated string to the character span. - /// - /// The span to which the interpolated string should be formatted. - /// The format to use, if available. - /// An object that supplies culture-specific formatting information. - /// The interpolated string. - /// The number of characters written to the span. - /// true if the entire interpolated string could be formatted successfully; otherwise, false. - public static bool TryWrite( - Span destination, - ReadOnlySpan format, - IFormatProvider? formatProvider, - [InterpolatedStringHandlerArgument("destination", "format", "formatProvider")] ref TryWriteFormatInterpolatedStringHandler handler, - out int charsWritten) - { - if (handler.success) - { - charsWritten = handler.position; - - return true; - } - - charsWritten = 0; - - return false; - } - - /// - /// Writes the specified to the handler. - /// - /// The to write. - /// Whether the value could be formatted to the span. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool AppendLiteral(string value) - { - if (value.Length == 1) - { - Span destination = this.destination; - int pos = this.position; - - if ((uint)pos < (uint)destination.Length) - { - destination[pos] = value[0]; - - this.position = pos + 1; - - return true; - } - - return Fail(); - } - - if (value.Length == 2) - { - Span destination = this.destination; - int pos = this.position; - - if ((uint)pos < destination.Length - 1) - { - Unsafe.WriteUnaligned( - ref Unsafe.As(ref Unsafe.Add(ref MemoryMarshal.GetReference(destination), pos)), -#if NET6_0_OR_GREATER - Unsafe.ReadUnaligned(ref Unsafe.As(ref Unsafe.AsRef(in value.GetPinnableReference())))); -#else - Unsafe.ReadUnaligned(ref Unsafe.As(ref MemoryMarshal.GetReference(value.AsSpan())))); -#endif - - this.position = pos + 2; - - return true; - } - - return Fail(); - } - - return AppendStringDirect(value); - } - - /// - /// Writes the specified string to the handler. - /// - /// The string to write. - /// Whether the value could be appended to the span. - private bool AppendStringDirect(string value) - { -#if NET6_0_OR_GREATER - if (value.TryCopyTo(this.destination.Slice(this.position))) -#else - if (value.AsSpan().TryCopyTo(this.destination.Slice(this.position))) -#endif - { - this.position += value.Length; - return true; - } - - return Fail(); - } - - /// - /// Writes the specified value to the handler. - /// - /// The value to write. - public bool AppendFormatted(T value) -#if NET6_0_OR_GREATER - where T : ISpanFormattable -#else - where T : IFormattable -#endif - { - if (this.hasCustomFormatter) - { - return AppendCustomFormatter(value, this.formatAsString ??= this.format.ToString()); - } - -#if NET6_0_OR_GREATER - if (value.TryFormat(this.destination.Slice(this.position), out int charsWritten, this.format, this.formatProvider)) - { - this.position += charsWritten; - - return true; - } - - return Fail(); -#else - return AppendStringDirect(value.ToString(this.formatAsString ??= this.format.ToString(), this.formatProvider)); -#endif - } - - /// - /// Writes the specified value to the handler. - /// - /// The value to write. - public bool AppendFormatted(string? value) - { - if (this.hasCustomFormatter) - { - return AppendCustomFormatter(value, format: null); - } - - if (value is null) - { - return true; - } - -#if NET6_0_OR_GREATER - if (value.TryCopyTo(this.destination.Slice(this.position))) -#else - if (value.AsSpan().TryCopyTo(this.destination.Slice(this.position))) -#endif - { - this.position += value.Length; - - return true; - } - - return Fail(); - } - - /// - /// Formats the value using the custom formatter from the provider. - /// - /// The value to write. - /// The format string. - [MethodImpl(MethodImplOptions.NoInlining)] - private bool AppendCustomFormatter(T value, string? format) - { - ICustomFormatter? formatter = (ICustomFormatter?)this.formatProvider?.GetFormat(typeof(ICustomFormatter)); - - if (formatter is not null && formatter.Format(format, value, this.formatProvider) is string customFormatted) - { - return AppendStringDirect(customFormatted); - } - - return true; - } - - /// - /// Marks formatting as having failed and returns false. - /// - private bool Fail() - { - this.success = false; - - return false; - } -} \ No newline at end of file diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.g.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.g.cs index 98ba9e5a..a3352f9b 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.g.cs +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.g.cs @@ -1,5 +1,4 @@ -using ComputeSharp.Core.Intrinsics.Attributes; -using ComputeSharp.Exceptions; +using ComputeSharp.Core.Intrinsics.Attributes; #pragma warning disable IDE0022 diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.tt b/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.tt index fccd4923..3d0fac53 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.tt +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.Void.tt @@ -1,6 +1,5 @@ -<#@include file="Hlsl.Void.ttinclude" #> +<#@include file="Hlsl.Void.ttinclude" #> using ComputeSharp.Core.Intrinsics.Attributes; -using ComputeSharp.Exceptions; #pragma warning disable IDE0022 diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.cs index 57e56054..80a48e29 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.cs +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.cs @@ -1,5 +1,4 @@ using ComputeSharp.Core.Intrinsics.Attributes; -using ComputeSharp.Exceptions; #pragma warning disable IDE0022 diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs index e5456939..06f99d2e 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.g.cs @@ -1,5 +1,4 @@ -using ComputeSharp.Core.Intrinsics.Attributes; -using ComputeSharp.Exceptions; +using ComputeSharp.Core.Intrinsics.Attributes; #pragma warning disable IDE0022 diff --git a/src/ComputeSharp.Core/Intrinsics/Hlsl.tt b/src/ComputeSharp.Core/Intrinsics/Hlsl.tt index 4dc9bc8d..b3724b44 100644 --- a/src/ComputeSharp.Core/Intrinsics/Hlsl.tt +++ b/src/ComputeSharp.Core/Intrinsics/Hlsl.tt @@ -1,6 +1,5 @@ <#@include file="Hlsl.ttinclude" #> using ComputeSharp.Core.Intrinsics.Attributes; -using ComputeSharp.Exceptions; #pragma warning disable IDE0022 diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs index b2393b2e..14e687d7 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool2.g.cs @@ -474,11 +474,7 @@ public unsafe partial struct Bool2 /// public override readonly string ToString() { -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}>"); -#else return $"<{this.x != 0}, {this.y != 0}>"; -#endif } #endif diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs index f118c8e0..11f81f83 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool3.g.cs @@ -1740,11 +1740,7 @@ public unsafe partial struct Bool3 /// public override readonly string ToString() { -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}, {this.z != 0}>"); -#else return $"<{this.x != 0}, {this.y != 0}, {this.z != 0}>"; -#endif } #endif diff --git a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs index 51b833a2..8829f59c 100644 --- a/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Bool/Bool4.g.cs @@ -4826,11 +4826,7 @@ public unsafe partial struct Bool4 /// public override readonly string ToString() { -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[32], $"<{this.x != 0}, {this.y != 0}, {this.z != 0}, {this.w != 0}>"); -#else return $"<{this.x != 0}, {this.y != 0}, {this.z != 0}, {this.w != 0}>"; -#endif } #endif diff --git a/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs index 7712ce9e..7ca7c16a 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs @@ -15,9 +15,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 8)] public unsafe partial struct Double2 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -481,36 +478,7 @@ public unsafe partial struct Double2 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>"); -#else return $"<{this.x}{separator} {this.y}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs index 3fb62e96..53b8e311 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs @@ -15,9 +15,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 24, Pack = 8)] public unsafe partial struct Double3 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -1747,36 +1744,7 @@ public unsafe partial struct Double3 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>"); -#else return $"<{this.x}{separator} {this.y}{separator} {this.z}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}{separator} {this.z}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}{separator} {this.z}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs index 138da11f..40575dfb 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs @@ -15,9 +15,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 32, Pack = 8)] public unsafe partial struct Double4 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -4833,36 +4830,7 @@ public unsafe partial struct Double4 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"); -#else return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs index 51a3919d..137578c0 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs @@ -16,9 +16,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)] public unsafe partial struct Float2 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -482,36 +479,7 @@ public unsafe partial struct Float2 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>"); -#else return $"<{this.x}{separator} {this.y}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs index 76368312..05ed5679 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs @@ -16,9 +16,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)] public unsafe partial struct Float3 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -1748,36 +1745,7 @@ public unsafe partial struct Float3 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>"); -#else return $"<{this.x}{separator} {this.y}{separator} {this.z}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}{separator} {this.z}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}{separator} {this.z}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs index aa1205fd..adb432ed 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs @@ -16,9 +16,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)] public unsafe partial struct Float4 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -4834,36 +4831,7 @@ public unsafe partial struct Float4 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"); -#else return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs index b8fc1714..77773ce2 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs @@ -16,9 +16,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)] public unsafe partial struct Int2 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -482,36 +479,7 @@ public unsafe partial struct Int2 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>"); -#else return $"<{this.x}{separator} {this.y}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs index d158b264..431f4b38 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs @@ -16,9 +16,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)] public unsafe partial struct Int3 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -1748,36 +1745,7 @@ public unsafe partial struct Int3 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>"); -#else return $"<{this.x}{separator} {this.y}{separator} {this.z}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}{separator} {this.z}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}{separator} {this.z}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs index faaf3357..7edef8f7 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs @@ -16,9 +16,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)] public unsafe partial struct Int4 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -4834,36 +4831,7 @@ public unsafe partial struct Int4 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"); -#else return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs index fa64a737..2c251318 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs @@ -15,9 +15,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 4)] public unsafe partial struct UInt2 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -481,36 +478,7 @@ public unsafe partial struct UInt2 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}>"); -#else return $"<{this.x}{separator} {this.y}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs index 26353ec6..3114bde1 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs @@ -15,9 +15,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 12, Pack = 4)] public unsafe partial struct UInt3 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -1747,36 +1744,7 @@ public unsafe partial struct UInt3 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}>"); -#else return $"<{this.x}{separator} {this.y}{separator} {this.z}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}{separator} {this.z}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}{separator} {this.z}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs index 15977e8a..77e37b45 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs @@ -15,9 +15,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = 16, Pack = 4)] public unsafe partial struct UInt4 -#if NET6_0_OR_GREATER - : ISpanFormattable -#endif { /// /// A private buffer to which the undefined properties will point to. @@ -4833,36 +4830,7 @@ public unsafe partial struct UInt4 { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"); -#else return $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<{this.x}{separator} {this.y}{separator} {this.z}{separator} {this.w}>", - out charsWritten); } #endif diff --git a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude index 186df432..c6711b8b 100644 --- a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude @@ -51,7 +51,6 @@ void GenerateVectorProperties(string typeName, int elementSize) bool isBoolType = hlslElementTypeName == "bool"; string fieldElementTypeName = isBoolType ? "int" : hlslElementTypeName; int i = int.Parse(Regex.Match(typeName, @"\d+$").Value); - string formattable = elementTypeName == "Bool" ? "" : "ISpanFormattable"; List namespaces = new List { @@ -88,16 +87,6 @@ namespace ComputeSharp; /// [StructLayout(LayoutKind.Explicit, Size = <#=(elementSize * i)#>, Pack = <#=elementSize#>)] public unsafe partial struct <#=typeName#> -<# - if (formattable != "") - { -#> -#if NET6_0_OR_GREATER - : <#=formattable#> -#endif -<# - } -#> { /// /// A private buffer to which the undefined properties will point to. @@ -258,11 +247,7 @@ public unsafe partial struct <#=typeName#> /// public override readonly string ToString() { -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[32], $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c} != 0}}"))#>>"); -#else return $"<<#=string.Join(", ", "xyzw".Take(i).Select(c => $"{{this.{c} != 0}}"))#>>"; -#endif } <# } @@ -274,36 +259,7 @@ public unsafe partial struct <#=typeName#> { string separator = NumberFormatInfo.CurrentInfo.NumberGroupSeparator; -#if NET6_0_OR_GREATER - return string.Create(null, stackalloc char[64], $"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>"); -#else return $"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>"; -#endif - } - - /// - public readonly string ToString(string? format, IFormatProvider? formatProvider) - { - string separator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; - - return FormatInterpolatedStringHandler.Create( - format, - formatProvider, - stackalloc char[64], - $"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>"); - } - - /// - public readonly bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider? provider) - { - string separator = NumberFormatInfo.GetInstance(provider).NumberGroupSeparator; - - return TryWriteFormatInterpolatedStringHandler.TryWrite( - destination, - format, - provider, - $"<<#=string.Join("{separator} ", "xyzw".Take(i).Select(c => $"{{this.{c}}}"))#>>", - out charsWritten); } <# } diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslBytecode.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslBytecode.cs index 7289f859..087ef987 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslBytecode.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderDescriptorGenerator.HlslBytecode.cs @@ -4,7 +4,6 @@ using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Threading; -using ComputeSharp.D2D1.Exceptions; using ComputeSharp.D2D1.Shaders.Translation; using ComputeSharp.D2D1.SourceGenerators.Models; using ComputeSharp.SourceGeneration.Extensions; diff --git a/src/ComputeSharp.D2D1/Intrinsics/D2D.cs b/src/ComputeSharp.D2D1/Intrinsics/D2D.cs index 7ed4e452..a42f395c 100644 --- a/src/ComputeSharp.D2D1/Intrinsics/D2D.cs +++ b/src/ComputeSharp.D2D1/Intrinsics/D2D.cs @@ -1,5 +1,4 @@ using ComputeSharp.Core.Intrinsics.Attributes; -using ComputeSharp.Exceptions; #pragma warning disable IDE0022 diff --git a/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture1D{T}.cs b/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture1D{T}.cs index 777bf3ec..e9fdc34d 100644 --- a/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture1D{T}.cs +++ b/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture1D{T}.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - #pragma warning disable IDE0022 namespace ComputeSharp.D2D1; diff --git a/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture2D{T}.cs b/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture2D{T}.cs index e17e35a6..2df57a16 100644 --- a/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture2D{T}.cs +++ b/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture2D{T}.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - #pragma warning disable IDE0022 namespace ComputeSharp.D2D1; diff --git a/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture3D{T}.cs b/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture3D{T}.cs index cfcdb768..b953356d 100644 --- a/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture3D{T}.cs +++ b/src/ComputeSharp.D2D1/Resources/D2D1ResourceTexture3D{T}.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - #pragma warning disable IDE0022 namespace ComputeSharp.D2D1; diff --git a/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs b/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs index c7b2b7f3..39b1aa50 100644 --- a/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs +++ b/src/ComputeSharp.D2D1/Shaders/Exceptions/FxcCompilationException.cs @@ -1,7 +1,6 @@ using System; -using System.Text; -namespace ComputeSharp.D2D1.Exceptions; +namespace ComputeSharp.D2D1; /// /// A custom type that indicates when a shader compilation with the FXC compiler has failed. @@ -24,15 +23,15 @@ public sealed class FxcCompilationException : Exception /// A formatted error message for a new instance. private static string GetExceptionMessage(string error) { - StringBuilder builder = new(512); +#if NET6_0_OR_GREATER + ReadOnlySpan message = error.AsSpan().Trim(); +#else + string message = error.Trim(); +#endif - _ = builder.AppendLine("The FXC compiler encountered one or more errors while trying to compile the shader:"); - _ = builder.AppendLine(); - _ = builder.AppendLine(error.Trim()); - _ = builder.AppendLine(); - _ = builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp."); - _ = builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message."); - - return builder.ToString(); + return + $"""The FXC compiler encountered one or more errors while trying to compile the shader: "{message}". """ + + $"""Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp. """ + + $"""If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message."""; } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs index da2188c1..7b3fe080 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs @@ -1,7 +1,6 @@ using System; using System.Buffers; using System.Text; -using ComputeSharp.D2D1.Exceptions; using ComputeSharp.D2D1.Shaders.Translation; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/D2D1EffectXmlFactory.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/D2D1EffectXmlFactory.cs index a879b4d9..1e322f48 100644 --- a/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/D2D1EffectXmlFactory.cs +++ b/src/ComputeSharp.D2D1/Shaders/Interop/Helpers/D2D1EffectXmlFactory.cs @@ -25,6 +25,14 @@ internal static unsafe class D2D1EffectXmlFactory public static EffectXml GetXmlBuffer() where T : unmanaged, ID2D1PixelShader, ID2D1PixelShaderDescriptor { + // Compute all necessary values first, outside of the lock + string? displayName = D2D1PixelShaderEffect.GetEffectDisplayName(); + string? description = D2D1PixelShaderEffect.GetEffectDescription(); + string? category = D2D1PixelShaderEffect.GetEffectCategory(); + string? author = D2D1PixelShaderEffect.GetEffectAuthor(); + int inputCount = D2D1PixelShader.GetInputCount(); + int resourceTextureCount = D2D1PixelShader.GetResourceTextureCount(); + StringBuilder builder = XmlBuilder; // We use a simple caching schema here with a single StringBuilder instance shared across all threads. @@ -39,15 +47,15 @@ internal static unsafe class D2D1EffectXmlFactory _ = builder.Append($""" - - - - + + + + """); // Add the input nodes, if any - for (int i = 0; i < D2D1PixelShader.GetInputCount(); i++) + for (int i = 0; i < inputCount; i++) { _ = builder.Append('\n'); _ = builder.Append($" "); @@ -66,7 +74,7 @@ internal static unsafe class D2D1EffectXmlFactory """); // Add the resource texture manager nodes, if any - for (int i = 0; i < D2D1PixelShader.GetResourceTextureCount(); i++) + for (int i = 0; i < resourceTextureCount; i++) { _ = builder.Append('\n'); _ = builder.Append($""" diff --git a/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs b/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs index 26f5fe00..f1317887 100644 --- a/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs +++ b/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs @@ -4,7 +4,6 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; -using ComputeSharp.D2D1.Exceptions; using ComputeSharp.D2D1.Extensions; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; diff --git a/src/ComputeSharp.Dynamic/Shaders/Exceptions/DxcCompilationException.cs b/src/ComputeSharp.Dynamic/Shaders/Exceptions/DxcCompilationException.cs index 634b84dd..7aa7ee72 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Exceptions/DxcCompilationException.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Exceptions/DxcCompilationException.cs @@ -1,7 +1,6 @@ using System; -using System.Text; -namespace ComputeSharp.Exceptions; +namespace ComputeSharp; /// /// A custom type that indicates when a shader compilation with the DXC compiler has failed. @@ -24,15 +23,15 @@ public sealed class DxcCompilationException : Exception /// A formatted error message for a new instance. private static string GetExceptionMessage(string error) { - StringBuilder builder = new(512); +#if NET6_0_OR_GREATER + ReadOnlySpan message = error.AsSpan().Trim(); +#else + string message = error.Trim(); +#endif - _ = builder.AppendLine("The DXC compiler encountered one or more errors while trying to compile the shader:"); - _ = builder.AppendLine(); - _ = builder.AppendLine(error.Trim()); - _ = builder.AppendLine(); - _ = builder.AppendLine("Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp."); - _ = builder.Append("If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message."); - - return builder.ToString(); + return + $"""The DXC compiler encountered one or more errors while trying to compile the shader: "{message}". """ + + $"""Make sure to only be using supported features by checking the README file in the ComputeSharp repository: https://github.com/Sergio0694/ComputeSharp. """ + + $"""If you're sure that your C# shader code is valid, please open an issue an include a working repro and this error message."""; } } \ No newline at end of file diff --git a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs index b93f9323..146c9e4f 100644 --- a/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs +++ b/src/ComputeSharp.Dynamic/Shaders/Translation/ShaderCompiler.cs @@ -2,7 +2,6 @@ using System; using System.Runtime.CompilerServices; using System.Text.RegularExpressions; using ComputeSharp.Core.Extensions; -using ComputeSharp.Exceptions; using TerraFX.Interop.DirectX; using TerraFX.Interop.Windows; #if !NET6_0_OR_GREATER diff --git a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs index 8d988930..18489595 100644 --- a/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs +++ b/src/ComputeSharp.SourceGenerators/IShaderGenerator.CreateLoadBytecodeMethod.cs @@ -8,7 +8,6 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading; -using ComputeSharp.Exceptions; using ComputeSharp.Shaders.Translation; using ComputeSharp.SourceGeneration.Extensions; using ComputeSharp.SourceGeneration.Helpers; diff --git a/src/ComputeSharp/Core/Dispatch/DispatchSize.cs b/src/ComputeSharp/Core/Dispatch/DispatchSize.cs index 60b05ba9..20220b0e 100644 --- a/src/ComputeSharp/Core/Dispatch/DispatchSize.cs +++ b/src/ComputeSharp/Core/Dispatch/DispatchSize.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - namespace ComputeSharp; /// diff --git a/src/ComputeSharp/Core/Dispatch/GridIds.cs b/src/ComputeSharp/Core/Dispatch/GridIds.cs index 48c37a80..29f8d66b 100644 --- a/src/ComputeSharp/Core/Dispatch/GridIds.cs +++ b/src/ComputeSharp/Core/Dispatch/GridIds.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - namespace ComputeSharp; /// diff --git a/src/ComputeSharp/Core/Dispatch/GroupIds.cs b/src/ComputeSharp/Core/Dispatch/GroupIds.cs index bd97efac..7d7241d3 100644 --- a/src/ComputeSharp/Core/Dispatch/GroupIds.cs +++ b/src/ComputeSharp/Core/Dispatch/GroupIds.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - namespace ComputeSharp; /// diff --git a/src/ComputeSharp/Core/Dispatch/GroupSize.cs b/src/ComputeSharp/Core/Dispatch/GroupSize.cs index 84a7791d..17c56094 100644 --- a/src/ComputeSharp/Core/Dispatch/GroupSize.cs +++ b/src/ComputeSharp/Core/Dispatch/GroupSize.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - namespace ComputeSharp; /// diff --git a/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs b/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs index df03886c..71313ca7 100644 --- a/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs +++ b/src/ComputeSharp/Core/Dispatch/ThreadIds.Normalized.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - namespace ComputeSharp; /// diff --git a/src/ComputeSharp/Core/Dispatch/ThreadIds.cs b/src/ComputeSharp/Core/Dispatch/ThreadIds.cs index f931a086..c818f15b 100644 --- a/src/ComputeSharp/Core/Dispatch/ThreadIds.cs +++ b/src/ComputeSharp/Core/Dispatch/ThreadIds.cs @@ -1,5 +1,3 @@ -using ComputeSharp.Exceptions; - namespace ComputeSharp; /// diff --git a/src/ComputeSharp/Graphics/Exceptions/GraphicsDeviceMismatchException.cs b/src/ComputeSharp/Graphics/Exceptions/GraphicsDeviceMismatchException.cs index 34c3fcde..b4d7e9dc 100644 --- a/src/ComputeSharp/Graphics/Exceptions/GraphicsDeviceMismatchException.cs +++ b/src/ComputeSharp/Graphics/Exceptions/GraphicsDeviceMismatchException.cs @@ -1,9 +1,8 @@ using System; -using System.Text; using ComputeSharp.Interop; using ComputeSharp.Resources; -namespace ComputeSharp.Exceptions; +namespace ComputeSharp; /// /// A custom that indicates when mismatched devices are being used. @@ -32,15 +31,13 @@ public sealed class GraphicsDeviceMismatchException : InvalidOperationException /// private static GraphicsDeviceMismatchException Create(IReferenceTrackedObject resource, GraphicsDevice sourceDevice, GraphicsDevice destinationDevice) { - StringBuilder builder = new(512); + string message = + $"""Invalid pairing of graphics devices used to run a compute shader and allocate memory buffers. """ + + $"""The target device to run the compute shader is "{destinationDevice}". """ + + $"""The buffer of type {resource.GetType()} was allocated on device "{sourceDevice}". """ + + $"""Make sure to always allocate buffers on the same device used to actually run the code that accesses them."""; - _ = builder.AppendLine("Invalid pairing of graphics devices used to run a compute shader and allocate memory buffers."); - _ = builder.AppendLine($"The target device to run the compute shader is \"{destinationDevice}\"."); - _ = builder.AppendLine($"The buffer of type {resource.GetType()} was allocated on device \"{sourceDevice}\"."); - _ = builder.Append("Make sure to always allocate buffers on the same device used to actually run the code that accesses them."); - _ = builder.ToString(); - - return new(builder.ToString()); + return new(message); } /// diff --git a/src/ComputeSharp/Graphics/Exceptions/UnsupportedDoubleOperationsException.cs b/src/ComputeSharp/Graphics/Exceptions/UnsupportedDoubleOperationsException.cs index 0c4b8fdb..06bf7093 100644 --- a/src/ComputeSharp/Graphics/Exceptions/UnsupportedDoubleOperationsException.cs +++ b/src/ComputeSharp/Graphics/Exceptions/UnsupportedDoubleOperationsException.cs @@ -1,7 +1,6 @@ using System; -using System.Text; -namespace ComputeSharp.Exceptions; +namespace ComputeSharp; /// /// A custom that indicates when a resource was attempted to be created with an unsupported type. @@ -24,14 +23,12 @@ public sealed class UnsupportedDoubleOperationException : NotSupportedException /// A new instance with a formatted error message. private static UnsupportedDoubleOperationException Create(Type type) { - StringBuilder builder = new(256); + string message = + $"The device in use does not support creating resources of type {type}, as it does not support using double precision floating point numbers. " + + $"As a possible workaround, consider replacing usage of the double type with single precision floating point numbers. " + + $"Note that double precision operations are only partially supported on GPU devices, and are far slower than single precision ones."; - _ = builder.AppendLine($"The device in use does not support creating resources of type {type}, as it does not support using double precision floating point numbers."); - _ = builder.AppendLine("As a possible workaround, consider replacing usage of the double type with single precision floating point numbers."); - _ = builder.AppendLine("Note that double precision operations are only partially supported on GPU devices, and are far slower than single precision ones."); - _ = builder.ToString(); - - return new(builder.ToString()); + return new(message); } /// diff --git a/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs b/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs index 25ab893d..c695be05 100644 --- a/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs +++ b/src/ComputeSharp/Graphics/Exceptions/UnsupportedTextureTypeException.cs @@ -1,7 +1,6 @@ using System; -using System.Text; -namespace ComputeSharp.Exceptions; +namespace ComputeSharp; /// /// A custom that indicates when a texture was attempted to be created with an unsupported type. @@ -25,22 +24,20 @@ public sealed class UnsupportedTextureTypeException : NotSupportedException /// A new instance with a formatted error message. private static UnsupportedTextureTypeException Create(int rank, Type type) { - StringBuilder builder = new(256); - - _ = builder.AppendLine($"The device in use does not support creating {rank}D textures of type {type}."); - _ = builder.Append($"Make sure to check the support at runtime by using {nameof(GraphicsDevice)}."); - - _ = builder.AppendLine(rank switch + string suggestedMethods = rank switch { - 1 => $"{nameof(GraphicsDevice.IsReadOnlyTexture1DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture1DSupportedForType)}().", - 2 => $"{nameof(GraphicsDevice.IsReadOnlyTexture2DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture2DSupportedForType)}().", - 3 => $"{nameof(GraphicsDevice.IsReadOnlyTexture3DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture3DSupportedForType)}().", + 1 => $"{nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadOnlyTexture1DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture1DSupportedForType)}()", + 2 => $"{nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadOnlyTexture2DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture2DSupportedForType)}()", + 3 => $"{nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadOnlyTexture3DSupportedForType)}() or {nameof(GraphicsDevice)}.{nameof(GraphicsDevice.IsReadWriteTexture3DSupportedForType)}()", _ => default(ArgumentException).Throw(nameof(rank)) - }); + }; - _ = builder.Append("As a possible workaround on older devices, consider using a texture type of lower rank, or a linear buffer."); + string message = + $"The device in use does not support creating {rank}D textures of type {type}. " + + $"Make sure to check the support at runtime by using {suggestedMethods}. " + + $"As a possible workaround on older devices, consider using a texture type of lower rank, or a linear buffer."; - return new(builder.ToString()); + return new(message); } /// diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs index 481e58a5..55006d31 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs @@ -3,7 +3,6 @@ using System.Buffers; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using ComputeSharp.Core.Helpers; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs index a527c406..ac6372e2 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture1D{T}.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs index 6d27d4c3..5aa0b7ac 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture2D{T}.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs index 62e819ca..03692f34 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/Texture3D{T}.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs index 8fcbe06f..fb1f8d02 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferBuffer{T}.cs @@ -2,7 +2,6 @@ using System; using System.Buffers; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Interop; diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs index b1ba8b0b..1a41b43a 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture1D{T}.cs @@ -1,7 +1,6 @@ using System; using System.Buffers; using System.Runtime.CompilerServices; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Interop; diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs index 164ac349..790b4515 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture2D{T}.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.CompilerServices; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Interop; diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs index 62db3795..26caf240 100644 --- a/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/Abstract/TransferTexture3D{T}.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.CompilerServices; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Interop; diff --git a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs index eab1d9e7..2adfdd24 100644 --- a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using ComputeSharp.Core.Helpers; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; using ComputeSharp.Graphics.Resources.Interop; diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyBuffer{T}.cs index 7febe5f1..26e9d856 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyBuffer{T}.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture1D{T,TPixel}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture1D{T,TPixel}.cs index f529a648..92c52de6 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture1D{T,TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture1D{T,TPixel}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture1D{T}.cs index aa0493c5..ff28ccd3 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture1D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture1D{T}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T,TPixel}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T,TPixel}.cs index 93bee080..2d53d7c7 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T,TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T,TPixel}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T}.cs index a1261e6d..0baa2264 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture2D{T}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T,TPixel}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T,TPixel}.cs index 0beb680c..c56195c5 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T,TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T,TPixel}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T}.cs index 60121dc3..c89ff20b 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadOnlyTexture3D{T}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteBuffer{T}.cs index 944beb97..49be64fd 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteBuffer{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteBuffer{T}.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.ReadOnly.cs index cfbe215d..a510e30f 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.ReadOnly.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.cs index 43ba6251..75df64bc 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T,TPixel}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.ReadOnly.cs index 6f36d5d9..00221eae 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.ReadOnly.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.cs index 57b061c3..113df905 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture1D{T}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs index 4d713772..993de87a 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.ReadOnly.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.cs index ba59c270..6a6f67e0 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T,TPixel}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.ReadOnly.cs index a8273992..428d9b90 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.ReadOnly.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.cs index 42c2c5f2..6f785d4b 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture2D{T}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs index 8434af6f..abe8e1c3 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.ReadOnly.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.cs index afd6c66a..7a207adc 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T,TPixel}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.ReadOnly.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.ReadOnly.cs index 15151184..7ea10fae 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.ReadOnly.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.ReadOnly.cs @@ -1,7 +1,6 @@ using System; using System.Runtime.CompilerServices; using ComputeSharp.__Internals; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Commands.Interop; using ComputeSharp.Graphics.Extensions; using ComputeSharp.Graphics.Helpers; diff --git a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.cs b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.cs index 1f00f3cf..88d07421 100644 --- a/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.cs +++ b/src/ComputeSharp/Graphics/Resources/ReadWriteTexture3D{T}.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using ComputeSharp.Exceptions; using ComputeSharp.Graphics.Resources.Enums; using ComputeSharp.Resources; using ComputeSharp.Resources.Debug; diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs index 271a5e8f..7867b6f3 100644 --- a/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs +++ b/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs @@ -1,5 +1,4 @@ using System; -using ComputeSharp.D2D1.Exceptions; using ComputeSharp.D2D1.Interop; using Microsoft.VisualStudio.TestTools.UnitTesting; diff --git a/tests/ComputeSharp.D2D1.Uwp.Tests/Properties/AssemblyInfo.cs b/tests/ComputeSharp.D2D1.Uwp.Tests/Properties/AssemblyInfo.cs index 8fb8814e..b5d4d1be 100644 --- a/tests/ComputeSharp.D2D1.Uwp.Tests/Properties/AssemblyInfo.cs +++ b/tests/ComputeSharp.D2D1.Uwp.Tests/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("ComputeSharp.D2D1.Uwp.Tests")] @@ -10,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyMetadata("TargetPlatform","UAP")] +[assembly: AssemblyMetadata("TargetPlatform", "UAP")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: ComVisible(false)] \ No newline at end of file diff --git a/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs b/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs index 9afe217a..ff01970d 100644 --- a/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs +++ b/tests/ComputeSharp.Tests.Internals/ShaderCompilerTests.cs @@ -1,5 +1,4 @@ using System; -using ComputeSharp.Exceptions; using ComputeSharp.Shaders.Translation; using Microsoft.VisualStudio.TestTools.UnitTesting; using TerraFX.Interop.DirectX; diff --git a/tests/ComputeSharp.Tests/BufferTests.cs b/tests/ComputeSharp.Tests/BufferTests.cs index 8f223ecf..7de26fd0 100644 --- a/tests/ComputeSharp.Tests/BufferTests.cs +++ b/tests/ComputeSharp.Tests/BufferTests.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using ComputeSharp.Exceptions; using ComputeSharp.Resources; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions;