Add and adopt WriteSortedUsingDirectives extension
このコミットが含まれているのは:
1 親
fd47d242bb
コミット
e909262a97
2ファイル変更
+28
-18
検索条件に一致するファイルはありません
@@ -249,24 +249,8 @@ public sealed partial class D2DPixelShaderDescriptorGenerator : IIncrementalGene
|
||||
|
||||
using (writer.WriteBlock())
|
||||
{
|
||||
// Add the System directives first, in the correct order
|
||||
foreach (string usingDirective in usingDirectives.AsEnumerable().Where(static name => name.StartsWith("global::System")).OrderBy(static name => name))
|
||||
{
|
||||
writer.WriteLine($"using {usingDirective};");
|
||||
}
|
||||
|
||||
// Add the other directives, also sorted in the correct order
|
||||
foreach (string usingDirective in usingDirectives.AsEnumerable().Where(static name => !name.StartsWith("global::System")).OrderBy(static name => name))
|
||||
{
|
||||
writer.WriteLine($"using {usingDirective};");
|
||||
}
|
||||
|
||||
foreach (IndentedTextWriter.Callback<D2D1ShaderInfo> callback in additionalTypes.WrittenSpan)
|
||||
{
|
||||
writer.WriteLine();
|
||||
|
||||
callback(item, writer);
|
||||
}
|
||||
writer.WriteSortedUsingDirectives(usingDirectives.AsEnumerable());
|
||||
writer.WriteLineSeparatedMembers(additionalTypes.WrittenSpan, (callback, writer) => callback(item, writer));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
@@ -40,6 +42,30 @@ internal static class IndentedTextWriterExtensions
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a sequence of using directives, sorted correctly.
|
||||
/// </summary>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
/// <param name="usingDirectives">The sequence of using directives to write.</param>
|
||||
public static void WriteSortedUsingDirectives(this IndentedTextWriter writer, IEnumerable<string> usingDirectives)
|
||||
{
|
||||
// Add the System directives first, in the correct order
|
||||
foreach (string usingDirective in usingDirectives.Where(static name => name.StartsWith("global::System")).OrderBy(static name => name))
|
||||
{
|
||||
writer.WriteLine($"using {usingDirective};");
|
||||
}
|
||||
|
||||
// Add the other directives, also sorted in the correct order
|
||||
foreach (string usingDirective in usingDirectives.Where(static name => !name.StartsWith("global::System")).OrderBy(static name => name))
|
||||
{
|
||||
writer.WriteLine($"using {usingDirective};");
|
||||
}
|
||||
|
||||
// Leave a trailing blank line if at least one using directive has been written.
|
||||
// This is so that any members will correctly have a leading blank line before.
|
||||
writer.WriteLineIf(usingDirectives.Any());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a new line into the target writer depending on an input condition.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする