diff --git a/samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs b/samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs
index 677b70ad..f978d35c 100644
--- a/samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs
+++ b/samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs
@@ -84,8 +84,8 @@ public sealed partial class MainViewModel : ObservableObject
///
/// Gets the collection of available compute shader.
///
- public IReadOnlyList ComputeShaderOptions { get; } = new ShaderRunnerViewModel[]
- {
+ public IReadOnlyList ComputeShaderOptions { get; } =
+ [
new(
nameof(ColorfulInfinity),
new ShaderRunner(static time => new((float)time.TotalSeconds)),
@@ -123,7 +123,7 @@ public sealed partial class MainViewModel : ObservableObject
nameof(TerracedHills),
new ShaderRunner(static time => new((float)time.TotalSeconds)),
new PixelShaderEffect.For(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
- };
+ ];
///
/// Checks whether the resolution scale can currently be expliclty set.
diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs
index 2fb5b77a..93264977 100644
--- a/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Interop/Effects/PixelShaderEffect.Globals{T}.cs
@@ -26,21 +26,13 @@ internal unsafe partial struct PixelShaderEffect
///
/// A base type with global values for pixel shader effects.
///
- public abstract class Globals
+ /// The wrapper for the shader factory.
+ public abstract class Globals(FactoryDelegate effectFactory)
{
///
/// Gets the wrapper for the shader factory.
///
- private readonly FactoryDelegate effectFactory;
-
- ///
- /// Creates a new instance with the specified parameters.
- ///
- /// The wrapper for the shader factory.
- protected Globals(FactoryDelegate effectFactory)
- {
- this.effectFactory = effectFactory;
- }
+ private readonly FactoryDelegate effectFactory = effectFactory;
///
public abstract ref readonly Guid EffectId { get; }
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
index 66655aa9..a1ce59a5 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/HlslSourceRewriter.cs
@@ -20,67 +20,54 @@ namespace ComputeSharp.SourceGeneration.SyntaxRewriters;
/// A base type that processes C# source to convert to HLSL compliant code.
/// This class contains only the shared logic for all derived HLSL source rewriters.
///
-internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
+/// The instance for the target syntax tree.
+/// The set of discovered custom types.
+/// The collection of discovered constant definitions.
+/// The collection of discovered static field definitions.
+/// The collection of produced instances.
+/// The value for the current operation.
+internal abstract partial class HlslSourceRewriter(
+ SemanticModelProvider semanticModel,
+ ICollection discoveredTypes,
+ IDictionary constantDefinitions,
+ IDictionary staticFieldDefinitions,
+ ImmutableArrayBuilder diagnostics,
+ CancellationToken token) : CSharpSyntaxRewriter
{
///
/// An array with the '.' and 'E' characters.
///
private static readonly char[] FloatLiteralSpecialCharacters = ['.', 'E'];
- ///
- /// Creates a new instance with the specified parameters.
- ///
- /// The instance for the target syntax tree.
- /// The set of discovered custom types.
- /// The collection of discovered constant definitions.
- /// The collection of discovered static field definitions.
- /// The collection of produced instances.
- /// The value for the current operation.
- protected HlslSourceRewriter(
- SemanticModelProvider semanticModel,
- ICollection discoveredTypes,
- IDictionary constantDefinitions,
- IDictionary staticFieldDefinitions,
- ImmutableArrayBuilder diagnostics,
- CancellationToken token)
- {
- SemanticModel = semanticModel;
- DiscoveredTypes = discoveredTypes;
- ConstantDefinitions = constantDefinitions;
- StaticFieldDefinitions = staticFieldDefinitions;
- Diagnostics = diagnostics;
- CancellationToken = token;
- }
-
///
/// Gets the instance with semantic info on the target syntax tree.
///
- protected SemanticModelProvider SemanticModel { get; }
+ protected SemanticModelProvider SemanticModel { get; } = semanticModel;
///
/// Gets the collection of discovered custom types.
///
- protected ICollection DiscoveredTypes { get; }
+ protected ICollection DiscoveredTypes { get; } = discoveredTypes;
///
/// Gets the collection of discovered constant definitions.
///
- protected IDictionary ConstantDefinitions { get; }
+ protected IDictionary ConstantDefinitions { get; } = constantDefinitions;
///
/// Gets the collection of discovered static field definitions.
///
- protected IDictionary StaticFieldDefinitions { get; }
+ protected IDictionary StaticFieldDefinitions { get; } = staticFieldDefinitions;
///
/// Gets the collection of produced instances.
///
- protected ImmutableArrayBuilder Diagnostics { get; }
+ protected ImmutableArrayBuilder Diagnostics { get; } = diagnostics;
///
/// Gets the value for the current operation.
///
- protected CancellationToken CancellationToken { get; }
+ protected CancellationToken CancellationToken { get; } = token;
///
public sealed override SyntaxNode VisitCastExpression(CastExpressionSyntax node)
diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs
index 33e0dc62..8fea6fea 100644
--- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs
+++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs
@@ -16,6 +16,8 @@ using Microsoft.CodeAnalysis.Operations;
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
+#pragma warning disable IDE0051, IDE0052
+
namespace ComputeSharp.SourceGeneration.SyntaxRewriters;
///
diff --git a/src/ComputeSharp.SourceGeneration/Helpers/EquatableArray{T}.cs b/src/ComputeSharp.SourceGeneration/Helpers/EquatableArray{T}.cs
index 1f1088de..13c94114 100644
--- a/src/ComputeSharp.SourceGeneration/Helpers/EquatableArray{T}.cs
+++ b/src/ComputeSharp.SourceGeneration/Helpers/EquatableArray{T}.cs
@@ -190,19 +190,13 @@ internal readonly struct EquatableArray(ImmutableArray array) : IEquatable
/// Implicitly converts an to .
///
/// An instance from a given .
- public static implicit operator EquatableArray(ImmutableArray array)
- {
- return FromImmutableArray(array);
- }
+ public static implicit operator EquatableArray(ImmutableArray array) => FromImmutableArray(array);
///
/// Implicitly converts an to .
///
/// An instance from a given .
- public static implicit operator ImmutableArray(EquatableArray array)
- {
- return array.AsImmutableArray();
- }
+ public static implicit operator ImmutableArray(EquatableArray array) => array.AsImmutableArray();
///
/// Checks whether two values are the same.
@@ -210,10 +204,7 @@ internal readonly struct EquatableArray(ImmutableArray array) : IEquatable
/// The first value.
/// The second value.
/// Whether and are equal.
- public static bool operator ==(EquatableArray left, EquatableArray right)
- {
- return left.Equals(right);
- }
+ public static bool operator ==(EquatableArray left, EquatableArray right) => left.Equals(right);
///
/// Checks whether two values are not the same.
@@ -221,8 +212,5 @@ internal readonly struct EquatableArray(ImmutableArray array) : IEquatable
/// The first value.
/// The second value.
/// Whether and are not equal.
- public static bool operator !=(EquatableArray left, EquatableArray right)
- {
- return !left.Equals(right);
- }
+ public static bool operator !=(EquatableArray left, EquatableArray right) => !left.Equals(right);
}
\ No newline at end of file
diff --git a/src/ComputeSharp.SourceGeneration/Helpers/ImmutableHashSetBuilder{T}.cs b/src/ComputeSharp.SourceGeneration/Helpers/ImmutableHashSetBuilder{T}.cs
index 21209d6e..069c9184 100644
--- a/src/ComputeSharp.SourceGeneration/Helpers/ImmutableHashSetBuilder{T}.cs
+++ b/src/ComputeSharp.SourceGeneration/Helpers/ImmutableHashSetBuilder{T}.cs
@@ -18,7 +18,7 @@ internal struct ImmutableHashSetBuilder : IDisposable
///
/// The shared instance to share objects.
///
- private static readonly ObjectPool> SharedObjectPool = new(static () => new HashSet());
+ private static readonly ObjectPool> SharedObjectPool = new(static () => []);
///
/// The rented instance to use.
diff --git a/src/ComputeSharp/Graphics/Luid.cs b/src/ComputeSharp/Graphics/Luid.cs
index 4c0d369c..c7aadbf4 100644
--- a/src/ComputeSharp/Graphics/Luid.cs
+++ b/src/ComputeSharp/Graphics/Luid.cs
@@ -79,10 +79,7 @@ public readonly struct Luid : IEquatable, ISpanFormattable
/// The second value to compare.
/// Whether and are the same.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator ==(Luid a, Luid b)
- {
- return a.Equals(b);
- }
+ public static bool operator ==(Luid a, Luid b) => a.Equals(b);
///
/// Check whether two values are different.
@@ -91,8 +88,5 @@ public readonly struct Luid : IEquatable, ISpanFormattable
/// The second value to compare.
/// Whether and are different.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator !=(Luid a, Luid b)
- {
- return !a.Equals(b);
- }
+ public static bool operator !=(Luid a, Luid b) => !a.Equals(b);
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Graphics/Resources/Views/TextureView2D{T}.cs b/src/ComputeSharp/Graphics/Resources/Views/TextureView2D{T}.cs
index dacdb730..92818bcd 100644
--- a/src/ComputeSharp/Graphics/Resources/Views/TextureView2D{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Views/TextureView2D{T}.cs
@@ -361,10 +361,7 @@ public readonly unsafe ref struct TextureView2D
/// The first instance to compare.
/// The second instance to compare.
/// Whether or not and are equal.
- public static bool operator ==(TextureView2D left, TextureView2D right)
- {
- return left.pointer == right.pointer;
- }
+ public static bool operator ==(TextureView2D left, TextureView2D right) => left.pointer == right.pointer;
///
/// Checks whether two instances are not equal.
@@ -372,8 +369,5 @@ public readonly unsafe ref struct TextureView2D
/// The first instance to compare.
/// The second instance to compare.
/// Whether or not and are not equal.
- public static bool operator !=(TextureView2D left, TextureView2D right)
- {
- return !(left == right);
- }
+ public static bool operator !=(TextureView2D left, TextureView2D right) => !(left == right);
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Graphics/Resources/Views/TextureView3D{T}.cs b/src/ComputeSharp/Graphics/Resources/Views/TextureView3D{T}.cs
index de271ed9..2f8ae465 100644
--- a/src/ComputeSharp/Graphics/Resources/Views/TextureView3D{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Views/TextureView3D{T}.cs
@@ -418,10 +418,7 @@ public readonly unsafe ref struct TextureView3D
/// The first instance to compare.
/// The second instance to compare.
/// Whether or not and are equal.
- public static bool operator ==(TextureView3D left, TextureView3D right)
- {
- return left.pointer == right.pointer;
- }
+ public static bool operator ==(TextureView3D left, TextureView3D right) => left.pointer == right.pointer;
///
/// Checks whether two instances are not equal.
@@ -429,8 +426,5 @@ public readonly unsafe ref struct TextureView3D
/// The first instance to compare.
/// The second instance to compare.
/// Whether or not and are not equal.
- public static bool operator !=(TextureView3D left, TextureView3D right)
- {
- return !(left == right);
- }
+ public static bool operator !=(TextureView3D left, TextureView3D right) => !(left == right);
}
\ No newline at end of file