From 8b3f75431ff88393c8bbbefc4659026e645e5f9f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 29 Aug 2022 00:08:06 +0200 Subject: [PATCH] Properly sort using directives in HLSL vector types --- .../Primitives/Double/Double2.g.cs | 2 +- .../Primitives/Double/Double3.g.cs | 2 +- .../Primitives/Double/Double4.g.cs | 2 +- .../Primitives/Float/Float2.g.cs | 2 +- .../Primitives/Float/Float3.g.cs | 2 +- .../Primitives/Float/Float4.g.cs | 2 +- .../Primitives/Int/Int2.g.cs | 2 +- .../Primitives/Int/Int3.g.cs | 4 ++-- .../Primitives/Int/Int4.g.cs | 2 +- .../Primitives/UInt/UInt2.g.cs | 2 +- .../Primitives/UInt/UInt3.g.cs | 2 +- .../Primitives/UInt/UInt4.g.cs | 2 +- .../Primitives/VectorType.ttinclude | 19 ++++++++++++++----- 13 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs index 12607921..131c1b32 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double2.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER diff --git a/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs index 8c2364db..d21af61e 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double3.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER diff --git a/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs b/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs index ca9d1cd4..9f5f2f49 100644 --- a/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Double/Double4.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER diff --git a/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs index 2e19503d..0e5be499 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float2.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Core.Intrinsics.Attributes; diff --git a/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs index 2411f5cb..e86e54ab 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float3.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Core.Intrinsics.Attributes; diff --git a/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs b/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs index 8319aa2e..847e24ee 100644 --- a/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Float/Float4.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Core.Intrinsics.Attributes; diff --git a/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs index c9b8caed..c8e1ea58 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int2.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Core.Intrinsics.Attributes; diff --git a/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs index 93b19e50..3385e8f7 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int3.g.cs @@ -1,9 +1,9 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Globalization; -using ComputeSharp.Core.Intrinsics.Attributes; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Diagnostics.CodeAnalysis; +using ComputeSharp.Core.Intrinsics.Attributes; #if !NET6_0_OR_GREATER using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers; #endif diff --git a/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs b/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs index c52b8518..24ddf313 100644 --- a/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs +++ b/src/ComputeSharp.Core/Primitives/Int/Int4.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using ComputeSharp.Core.Intrinsics.Attributes; diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs index 7f96a4dd..29125e97 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt2.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs index 628c62ca..ff57fbb8 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt3.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER diff --git a/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs b/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs index 1f741878..31e4c0c5 100644 --- a/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs +++ b/src/ComputeSharp.Core/Primitives/UInt/UInt4.g.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER diff --git a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude index 367770a6..54fe23af 100644 --- a/src/ComputeSharp.Core/Primitives/VectorType.ttinclude +++ b/src/ComputeSharp.Core/Primitives/VectorType.ttinclude @@ -53,10 +53,22 @@ void GenerateVectorProperties(string typeName, int elementSize) int i = int.Parse(Regex.Match(typeName, @"\d+$").Value); string formattable = elementTypeName == "Bool" ? "" : "ISpanFormattable"; + List namespaces = new List + { + "System.Diagnostics.CodeAnalysis", + "System.Runtime.CompilerServices", + "System.Runtime.InteropServices" + }; + if (elementTypeName != "Bool") { - WriteLine("using System;"); - WriteLine("using System.Globalization;"); + namespaces.Add("System"); + namespaces.Add("System.Globalization"); + } + + foreach (string name in namespaces.OrderBy(name => name)) + { + WriteLine($"using {name};"); } if (elementTypeName == "Float" || elementTypeName == "Int") @@ -64,9 +76,6 @@ void GenerateVectorProperties(string typeName, int elementSize) WriteLine("using ComputeSharp.Core.Intrinsics.Attributes;"); } #> -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; #if !NET6_0_OR_GREATER using RuntimeHelpers = ComputeSharp.Core.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers; #endif