Move all generated types into private namespace
このコミットが含まれているのは:
1 親
3439d3ec05
コミット
4917d67d7d
10ファイル変更
+189
-56
検索条件に一致するファイルはありません
@@ -21,6 +21,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)helpers\DynamicCache{TKey,TValue}.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\EquatableArray{T}.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\HashCode.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ImmutableHashSetBuilder{T}.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ImmutableArrayBuilder{T}.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\IndentedTextWriter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Helpers\ObjectPool{T}.cs" />
|
||||
|
||||
@@ -18,11 +18,34 @@ internal static class IndentedTextWriterExtensions
|
||||
/// </summary>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
/// <param name="generatorType">The type of the running generator.</param>
|
||||
public static void WriteGeneratedAttributes(this IndentedTextWriter writer, Type generatorType)
|
||||
/// <param name="useFullyQualifiedTypeNames">Whether to use fully qualified type names or not.</param>
|
||||
public static void WriteGeneratedAttributes(this IndentedTextWriter writer, Type generatorType, bool useFullyQualifiedTypeNames = true)
|
||||
{
|
||||
writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{generatorType.FullName}}", "{{generatorType.Assembly.GetName().Version}}")]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
|
||||
if (useFullyQualifiedTypeNames)
|
||||
{
|
||||
writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{generatorType.FullName}}", "{{generatorType.Assembly.GetName().Version}}")]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($$"""[GeneratedCode("{{generatorType.FullName}}", "{{generatorType.Assembly.GetName().Version}}")]""");
|
||||
writer.WriteLine($$"""[DebuggerNonUserCode]""");
|
||||
writer.WriteLine($$"""[ExcludeFromCodeCoverage]""");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a new line into the target writer depending on an input condition.
|
||||
/// </summary>
|
||||
/// <param name="writer">The <see cref="IndentedTextWriter"/> instance to write into.</param>
|
||||
/// <param name="condition">The condition to use to decide whether or not to write a new line.</param>
|
||||
public static void WriteLineIf(this IndentedTextWriter writer, bool condition)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -56,11 +56,12 @@ internal sealed partial record HierarchyInfo(string FullyQualifiedMetadataName,
|
||||
writer.WriteLine("#pragma warning disable");
|
||||
writer.WriteLine();
|
||||
|
||||
// Declare the file scoped namespace, if needed
|
||||
// Declare the namespace, if needed
|
||||
if (Namespace.Length > 0)
|
||||
{
|
||||
writer.WriteLine($"namespace {Namespace};");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"namespace {Namespace}");
|
||||
writer.WriteLine("{");
|
||||
writer.IncreaseIndent();
|
||||
}
|
||||
|
||||
// Declare all the opening types until the inner-most one
|
||||
@@ -81,6 +82,13 @@ internal sealed partial record HierarchyInfo(string FullyQualifiedMetadataName,
|
||||
writer.DecreaseIndent();
|
||||
writer.WriteLine("}");
|
||||
}
|
||||
|
||||
// Close the namespace scope as well, if needed
|
||||
if (Namespace.Length > 0)
|
||||
{
|
||||
writer.DecreaseIndent();
|
||||
writer.WriteLine("}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする