From 74ccc5e09f63a28aef0524b26e0e564d9298e7f1 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Thu, 9 Nov 2023 10:12:45 +0100 Subject: [PATCH] Use collection expressions in D2D shader source generator --- .../D2DPixelShaderSourceGenerator.Execute.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs index cdf09651..78ed7ef1 100644 --- a/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs +++ b/src/ComputeSharp.D2D1.SourceGenerators/D2DPixelShaderSourceGenerator.Execute.cs @@ -25,13 +25,13 @@ partial class D2DPixelShaderSourceGenerator /// The HLSL source to compile, if present. public static string? GetInvalidReturnType(ImmutableArrayBuilder diagnostics, IMethodSymbol methodSymbol) { - if (!(methodSymbol.ReturnType is INamedTypeSymbol + if (methodSymbol.ReturnType is not INamedTypeSymbol { Name: "ReadOnlySpan", ContainingNamespace.Name: "System", IsGenericType: true, - TypeParameters.Length: 1 - } returnType && returnType.TypeArguments[0].SpecialType == SpecialType.System_Byte)) + TypeArguments: [{ SpecialType: SpecialType.System_Byte }] + }) { diagnostics.Add( InvalidD2DPixelShaderSourceMethodReturnType, @@ -191,11 +191,11 @@ partial class D2DPixelShaderSourceGenerator { if (info.HlslInfo is HlslBytecodeInfo.Success success) { - writer.Write("return new byte[] { "); + writer.Write("return ["); SyntaxFormattingHelper.WriteByteArrayInitializationExpressions(success.Bytecode.AsSpan(), writer); - writer.WriteLine(" };"); + writer.WriteLine("];"); } else {