diff --git a/build/Directory.Build.props b/build/Directory.Build.props index 3d4fc91d..0d227034 100644 --- a/build/Directory.Build.props +++ b/build/Directory.Build.props @@ -46,7 +46,7 @@ This is used eg. to replace Unsafe.SizeOf() calls with just sizeof(T). The warning is not necessary since in order to use these APIs the caller already has to be in an unsafe context. --> - $(NoWarn);CS8500;IDE0028;IDE0300;IDE0301;IDE0302 + $(NoWarn);CS8500;IDE0300;IDE0301;IDE0302 diff --git a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs index 009ab8eb..a0c93a4d 100644 --- a/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs +++ b/samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs @@ -16,7 +16,7 @@ public sealed partial class MainWindow : Window /// /// The mapping of currently alive shader panels. /// - private readonly ConditionalWeakTable shaderPanels = new(); + private readonly ConditionalWeakTable shaderPanels = []; public MainWindow() { diff --git a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs index b138a98d..e08c903b 100644 --- a/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs +++ b/src/ComputeSharp.D2D1.WinUI/CanvasEffect.cs @@ -17,7 +17,7 @@ public abstract partial class CanvasEffect : ICanvasImage, ICanvasImageInterop.I /// /// When not empty (ie. when an effect graph has been built), this will always also include . /// - private readonly Dictionary transformNodes = new(); + private readonly Dictionary transformNodes = []; /// /// The current cached result for , if available. diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Helpers/SemanticModelProvider.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Helpers/SemanticModelProvider.cs index cce26153..95a019a3 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Helpers/SemanticModelProvider.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Helpers/SemanticModelProvider.cs @@ -12,7 +12,7 @@ internal sealed class SemanticModelProvider(Compilation compilation) /// /// The map of loaded instances. /// - private readonly Dictionary semanticModelsMap = new(); + private readonly Dictionary semanticModelsMap = []; /// /// Gets a instance with info on a given . diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs index 38ff6e74..c47faa54 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownMethods.cs @@ -166,7 +166,7 @@ internal static partial class HlslKnownMethods { ILookup methodsLookup = typeof(Hlsl).GetMethods(BindingFlags.Public | BindingFlags.Static).ToLookup(static method => method.Name); - Dictionary knownMethods = new(); + Dictionary knownMethods = []; // Go through the previously discovered methods to find the ones requiring parameters mapping foreach (KeyValuePair pair in KnownMethods) diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs index 826fd3c2..08c22239 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/Mappings/HlslKnownOperators.cs @@ -21,7 +21,7 @@ internal static partial class HlslKnownOperators /// private static IReadOnlyDictionary BuildKnownOperatorsMap() { - Dictionary knownOperators = new(); + Dictionary knownOperators = []; // Programmatically load mappings for the intrinsic operators on each HLSL primitive type foreach ((Type Type, MethodInfo Operator, string IntrinsicName, bool RequiresParametersMatching) item in diff --git a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs index 6889951c..af5faf55 100644 --- a/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGeneration.Hlsl/SyntaxRewriters/ShaderSourceRewriter.cs @@ -87,8 +87,8 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter this.shaderType = shaderType; this.staticMethods = staticMethods; this.instanceMethods = instanceMethods; - this.localFunctions = new(); - this.implicitVariables = new(); + this.localFunctions = []; + this.implicitVariables = []; this.isEntryPoint = isEntryPoint; } @@ -112,8 +112,8 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter { this.staticMethods = staticMethods; this.instanceMethods = instanceMethods; - this.implicitVariables = new(); - this.localFunctions = new(); + this.implicitVariables = []; + this.localFunctions = []; } /// diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.cs b/src/ComputeSharp/Graphics/GraphicsDevice.cs index 0b9c4dd4..aec8a836 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.cs @@ -170,7 +170,7 @@ public sealed unsafe partial class GraphicsDevice : IReferenceTrackedObject IsCacheCoherentUMA = d3D12Architecture1Data.CacheCoherentUMA != 0; this.deviceRemovedReason = S.S_OK; - this.cachedPipelineData = new List(); + this.cachedPipelineData = []; RegisterDeviceLostCallback(this, out this.deviceHandle, out this.deviceRemovedEvent, out this.deviceRemovedWaitHandle); } diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs index 1bfc44d7..57e889e1 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.Factory.cs @@ -14,12 +14,12 @@ unsafe partial class DeviceHelper /// /// The local cache of instances that are currently usable. /// - internal static readonly Dictionary DevicesCache = new(); + internal static readonly Dictionary DevicesCache = []; /// /// The local map of instances for the existing devices. /// - private static readonly Dictionary> D3D12InfoQueueMap = new(); + private static readonly Dictionary> D3D12InfoQueueMap = []; /// /// The cached default instance, if any. diff --git a/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs b/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs index 72438276..ff559581 100644 --- a/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs +++ b/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs @@ -19,7 +19,7 @@ internal static unsafe class PipelineDataLoader /// /// The map of cached instances for each GPU in use. /// - private static readonly ConditionalWeakTable CachedPipelines = new(); + private static readonly ConditionalWeakTable CachedPipelines = []; /// /// Gets the instance for a given shader. diff --git a/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/CanvasEffectTests.cs b/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/CanvasEffectTests.cs index 25e1e08c..2c853e65 100644 --- a/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/CanvasEffectTests.cs +++ b/tests/ComputeSharp.D2D1.WinUI.Tests/Tests/CanvasEffectTests.cs @@ -644,9 +644,9 @@ public partial class CanvasEffectTests private static readonly EffectNode EffectNode1 = new(); private static readonly EffectNode EffectNode2 = new(); private static readonly EffectNode EffectNode3 = new(); - public readonly List Effects1 = new(); - public readonly List Effects2 = new(); - public readonly List Effects3 = new(); + public readonly List Effects1 = []; + public readonly List Effects2 = []; + public readonly List Effects3 = []; public void InvalidateCreation() { diff --git a/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs b/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs index 5a59f3f7..6c471952 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/DeviceLostTests.cs @@ -24,7 +24,7 @@ public class DeviceLostTests { GraphicsDeviceHelper.GetD3D12Device(graphicsDevice, in d3D12Device); - List<(object? Sender, DeviceLostEventArgs Args)> args = new(); + List<(object? Sender, DeviceLostEventArgs Args)> args = []; // Register the device lost callback graphicsDevice.DeviceLost += (s, e) => args.Add((s, e)); diff --git a/tests/ComputeSharp.Tests.Internals/Helpers/DebugDispatchDataLoader.cs b/tests/ComputeSharp.Tests.Internals/Helpers/DebugDispatchDataLoader.cs index 57d537d3..a7d0ebac 100644 --- a/tests/ComputeSharp.Tests.Internals/Helpers/DebugDispatchDataLoader.cs +++ b/tests/ComputeSharp.Tests.Internals/Helpers/DebugDispatchDataLoader.cs @@ -17,7 +17,7 @@ internal struct DebugDispatchDataLoader : IConstantBufferLoader, IGraphicsResour /// /// The list of loaded resources. /// - private readonly List<(IGraphicsResource Resource, uint Index)> graphicsResources = new(); + private readonly List<(IGraphicsResource Resource, uint Index)> graphicsResources = []; /// /// Creates a new instance.