Update 'WriteGeneratedAttributes' with more options
このコミットが含まれているのは:
1 親
63bf3d98e7
コミット
18839f5bd2
1ファイル変更
+18
-5
@@ -21,7 +21,12 @@ internal static class IndentedTextWriterExtensions
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
/// <param name="generatorName">The name of the generator.</param>
|
||||
/// <param name="useFullyQualifiedTypeNames">Whether to use fully qualified type names or not.</param>
|
||||
public static void WriteGeneratedAttributes(this IndentedTextWriter writer, string generatorName, bool useFullyQualifiedTypeNames = true)
|
||||
/// <param name="includeNonUserCodeAttributes">Whether to also include the attribute for non-user code.</param>
|
||||
public static void WriteGeneratedAttributes(
|
||||
this IndentedTextWriter writer,
|
||||
string generatorName,
|
||||
bool useFullyQualifiedTypeNames = true,
|
||||
bool includeNonUserCodeAttributes = true)
|
||||
{
|
||||
// We can use this class to get the assembly, as all files for generators are just included
|
||||
// via shared projects. As such, the assembly will be the same as the generator type itself.
|
||||
@@ -30,14 +35,22 @@ internal static class IndentedTextWriterExtensions
|
||||
if (useFullyQualifiedTypeNames)
|
||||
{
|
||||
writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{generatorName}}", "{{assemblyVersion}}")]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
|
||||
|
||||
if (includeNonUserCodeAttributes)
|
||||
{
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($$"""[GeneratedCode("{{generatorName}}", "{{assemblyVersion}}")]""");
|
||||
writer.WriteLine($$"""[DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[ExcludeFromCodeCoverage]""");
|
||||
|
||||
if (includeNonUserCodeAttributes)
|
||||
{
|
||||
writer.WriteLine($$"""[DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[ExcludeFromCodeCoverage]""");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする