Use collection expressions in more places

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-08 12:54:21 +01:00
1 親 95a1ecd5c4
コミット 058db06971
13ファイル変更
+33 -33

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

+1 -1
ファイルの表示
@@ -79,7 +79,7 @@ public sealed partial class MainViewModel : ObservableObject
/// <summary>
/// Gets the available resolution scaling options (as percentage values).
/// </summary>
public IList<int> ResolutionScaleOptions { get; } = new[] { 25, 50, 75, 100 };
public IList<int> ResolutionScaleOptions { get; } = [25, 50, 75, 100];
/// <summary>
/// Gets the collection of available compute shader.
+3 -3
ファイルの表示
@@ -16,8 +16,8 @@ class Program
static void Main()
{
// Prepare the mapping of available samples to choose from
(string ShaderName, Win32Application Application)[] samples = new[]
{
(string ShaderName, Win32Application Application)[] samples =
[
(nameof(HelloWorld), Win32ApplicationFactory<HelloWorld>.Create(static time => new((float)time.TotalSeconds))),
(nameof(FourColorGradient), Win32ApplicationFactory<FourColorGradient>.Create(static time => new((float)time.TotalSeconds))),
(nameof(ColorfulInfinity), Win32ApplicationFactory<ColorfulInfinity>.Create(static time => new((float)time.TotalSeconds))),
@@ -31,7 +31,7 @@ class Program
(nameof(TriangleGridContouring), Win32ApplicationFactory<TriangleGridContouring>.Create(static time => new((float)time.TotalSeconds))),
(nameof(ContouredLayers), Win32ApplicationFactory<ContouredLayers>.Create(static time => new((float)time.TotalSeconds, RustyMetal.Value))),
(nameof(TerracedHills), Win32ApplicationFactory<TerracedHills>.Create(static time => new((float)time.TotalSeconds))),
};
];
int index;
+1 -1
ファイルの表示
@@ -246,7 +246,7 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene
item.Hierarchy.WriteSyntax(
state: item,
writer: writer,
baseTypes: new[] { $"global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{item.Hierarchy.Hierarchy[0].QualifiedName}>" },
baseTypes: [$"global::ComputeSharp.D2D1.Descriptors.ID2D1PixelShaderDescriptor<{item.Hierarchy.Hierarchy[0].QualifiedName}>"],
memberCallbacks: declaredMembers.WrittenSpan);
// If any generated types are needed, they go into a separate namespace
+1 -1
ファイルの表示
@@ -94,7 +94,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
state: item,
writer: writer,
baseTypes: [],
memberCallbacks: new IndentedTextWriter.Callback<D2D1PixelShaderSourceInfo>[] { Execute.WriteSyntax });
memberCallbacks: [Execute.WriteSyntax]);
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{item.MethodName}.g.cs", writer.ToString());
});
@@ -26,13 +26,13 @@ public sealed class InvalidEffectMetadataValueAnalyzer : DiagnosticAnalyzer
/// <summary>
/// The mapping of diagnostics to their attribute type names.
/// </summary>
private static readonly ImmutableDictionary<string, DiagnosticDescriptor> AttributeTypeNameToDiagnosticMapping = ImmutableDictionary.CreateRange(new[]
{
private static readonly ImmutableDictionary<string, DiagnosticDescriptor> AttributeTypeNameToDiagnosticMapping = ImmutableDictionary.CreateRange(
[
new KeyValuePair<string, DiagnosticDescriptor>("D2DEffectDisplayNameAttribute", InvalidD2DEffectDisplayNameAttributeValue),
new KeyValuePair<string, DiagnosticDescriptor>("D2DEffectDescriptionAttribute", InvalidD2DEffectDescriptionAttributeValue),
new KeyValuePair<string, DiagnosticDescriptor>("D2DEffectCategoryAttribute", InvalidD2DEffectCategoryAttributeValue),
new KeyValuePair<string, DiagnosticDescriptor>("D2DEffectAuthorAttribute", InvalidD2DEffectAuthorAttributeValue)
});
]);
/// <inheritdoc/>
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(
+7 -7
ファイルの表示
@@ -7,7 +7,7 @@ using System.Text.RegularExpressions;
using ComputeSharp.SourceGeneration.Extensions;
using Microsoft.CodeAnalysis;
#pragma warning disable RS1024
#pragma warning disable IDE0055, RS1024
namespace ComputeSharp.SourceGeneration.Mappings;
@@ -19,20 +19,20 @@ internal static partial class HlslKnownTypes
/// <summary>
/// Gets the set of HLSL vector types.
/// </summary>
public static IReadOnlyCollection<Type> KnownVectorTypes { get; } = new[]
{
public static IReadOnlyCollection<Type> KnownVectorTypes { get; } =
[
typeof(Bool2), typeof(Bool3), typeof(Bool4),
typeof(Int2), typeof(Int3), typeof(Int4),
typeof(UInt2), typeof(UInt3), typeof(UInt4),
typeof(Float2), typeof(Float3), typeof(Float4),
typeof(Double2), typeof(Double3), typeof(Double4)
};
];
/// <summary>
/// Gets the set of HLSL matrix types.
/// </summary>
public static IReadOnlyCollection<Type> KnownMatrixTypes { get; } = new[]
{
public static IReadOnlyCollection<Type> KnownMatrixTypes { get; } =
[
typeof(Bool1x1), typeof(Bool1x2), typeof(Bool1x3), typeof(Bool1x4),
typeof(Bool2x1), typeof(Bool2x2), typeof(Bool2x3), typeof(Bool2x4),
typeof(Bool3x1), typeof(Bool3x2), typeof(Bool3x3), typeof(Bool3x4),
@@ -53,7 +53,7 @@ internal static partial class HlslKnownTypes
typeof(Double2x1), typeof(Double2x2), typeof(Double2x3), typeof(Double2x4),
typeof(Double3x1), typeof(Double3x2), typeof(Double3x3), typeof(Double3x4),
typeof(Double4x1), typeof(Double4x2), typeof(Double4x3), typeof(Double4x4)
};
];
/// <summary>
/// The mapping of supported known types to HLSL types.
+1 -1
ファイルの表示
@@ -183,7 +183,7 @@ public sealed partial class ComputeShaderDescriptorGenerator : IIncrementalGener
item.Hierarchy.WriteSyntax(
state: item,
writer: writer,
baseTypes: new[] { $"global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{item.Hierarchy.Hierarchy[0].QualifiedName}>" },
baseTypes: [$"global::ComputeSharp.Descriptors.IComputeShaderDescriptor<{item.Hierarchy.Hierarchy[0].QualifiedName}>"],
memberCallbacks: declaredMembers.WrittenSpan);
// Append any additional types as well
+3 -3
ファイルの表示
@@ -12,12 +12,12 @@ partial class HlslKnownTypes
/// <summary>
/// Gets the known HLSL dispatch types.
/// </summary>
public static IReadOnlyCollection<Type> HlslDispatchTypes { get; } = new[]
{
public static IReadOnlyCollection<Type> HlslDispatchTypes { get; } =
[
typeof(ThreadIds),
typeof(GroupIds),
typeof(GridIds)
};
];
/// <summary>
/// Checks whether or not a given type name matches a constant buffer type.
+1 -1
ファイルの表示
@@ -1830,7 +1830,7 @@ public class Test_D2DPixelShaderSourceGenerator
// Create the original compilation
CSharpCompilation compilation = CSharpCompilation.Create(
"original",
new SyntaxTree[] { sourceTree },
[sourceTree],
metadataReferences,
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true));
+8 -8
ファイルの表示
@@ -101,14 +101,14 @@ namespace ComputeSharp.D2D1.Tests
{
CollectionAssert.AreEqual(new[]
{
D2D1PixelShaderInputType.Simple,
D2D1PixelShaderInputType.Complex,
D2D1PixelShaderInputType.Simple,
D2D1PixelShaderInputType.Complex,
D2D1PixelShaderInputType.Complex,
D2D1PixelShaderInputType.Complex,
D2D1PixelShaderInputType.Simple
}, D2D1PixelShader.GetInputTypes<ShaderWithMultipleInputs>().ToArray());
D2D1PixelShaderInputType.Simple,
D2D1PixelShaderInputType.Complex,
D2D1PixelShaderInputType.Simple,
D2D1PixelShaderInputType.Complex,
D2D1PixelShaderInputType.Complex,
D2D1PixelShaderInputType.Complex,
D2D1PixelShaderInputType.Simple
}, D2D1PixelShader.GetInputTypes<ShaderWithMultipleInputs>().ToArray());
}
[TestMethod]
+1 -1
ファイルの表示
@@ -1574,7 +1574,7 @@ public class DiagnosticsTests
// Create the original compilation
CSharpCompilation compilation = CSharpCompilation.Create(
"original",
new SyntaxTree[] { sourceTree },
[sourceTree],
metadataReferences,
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true));
+1 -1
ファイルの表示
@@ -920,7 +920,7 @@ public class Test_ComputeShaderDescriptorGenerator
// Create the original compilation
CSharpCompilation compilation = CSharpCompilation.Create(
"original",
new SyntaxTree[] { sourceTree },
[sourceTree],
metadataReferences,
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true));
+2 -2
ファイルの表示
@@ -180,7 +180,7 @@ public class ShadersTests
Action<ReadWriteTexture2D<Rgba32, float4>> action = new(RunComputeShader<SwapChain.Shaders.Compute.ColorfulInfinity>);
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, [texture]);
}
else
{
@@ -196,7 +196,7 @@ public class ShadersTests
Action<ReadWriteTexture2D<Rgba32, float4>> action = new(RunPixelShader<ColorfulInfinity>);
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
_ = action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, [texture]);
}
_ = image.DangerousTryGetSinglePixelMemory(out Memory<ImageSharpRgba32> memory);