Skip to content

Commit eb5796c

Browse files
committed
feat: add auto generate tag
1 parent c320d0d commit eb5796c

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

Supernova.Enum.Generators/EnumSourceGenerator.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public void Execute(GeneratorExecutionContext context)
2424
// Debugger.Launch();
2525
// }
2626
//#endif
27-
context.AddSource($"{SourceGeneratorHelper.AttributeName}Attribute.g.cs", SourceText.From($@"
27+
context.AddSource($"{SourceGeneratorHelper.AttributeName}Attribute.g.cs", SourceText.From(
28+
$@"// <auto-generated />
2829
using System;
2930
using System.CodeDom.Compiler;
3031
namespace {SourceGeneratorHelper.NameSpace}
@@ -107,14 +108,18 @@ public sealed class {SourceGeneratorHelper.AttributeName}Attribute : Attribute
107108
}
108109
}
109110

110-
var sourceBuilder = new StringBuilder($@"using System;
111+
112+
var sourceBuilder = new StringBuilder($@"// <auto-generated />
113+
using System;
114+
using System.CodeDom.Compiler;
111115
using System.Collections.Generic;
112116
using System.Collections.Immutable;
113117
namespace {SourceGeneratorHelper.NameSpace}
114118
{{
115119
/// <summary>
116120
/// Provides extension methods for operations related to the <see cref=""global::{symbol.FullName()}"" /> enumeration.
117-
/// </summary>
121+
/// </summary>
122+
[GeneratedCodeAttribute(""Supernova.Enum.Generators"", null)]
118123
{symbol.DeclaredAccessibility.ToString("G").ToLower()} static class {symbol.Name}EnumExtensions
119124
{{");
120125

@@ -147,8 +152,8 @@ namespace {SourceGeneratorHelper.NameSpace}
147152

148153
//GetLength
149154
GetLengthFast(sourceBuilder, symbol, e);
150-
151-
155+
156+
152157
//TryParse
153158
TryParseFast(sourceBuilder, e, symbol);
154159

@@ -399,7 +404,7 @@ private static void GetLengthFast(StringBuilder sourceBuilder, ISymbol symbol, E
399404
}
400405
");
401406
}
402-
407+
403408
private static void TryParseFast(StringBuilder sourceBuilder, EnumDeclarationSyntax e, ISymbol symbol)
404409
{
405410
sourceBuilder.Append($@"

Supernova.Enum.Generators/Extensions/SymbolExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System;
2-
using Microsoft.CodeAnalysis;
1+
using Microsoft.CodeAnalysis;
2+
using System;
33

44
namespace Supernova.Enum.Generators.Extensions;
55

@@ -18,7 +18,7 @@ public static string FullName(this ISymbol symbol)
1818
// TODO: Use NamespaceSymbolExtensions.FullName after Merge of #70
1919
return $"{symbol.ContainingNamespace.FullNamespace()}.{symbol.Name}";
2020
}
21-
21+
2222
/// <summary>
2323
/// Gets the full name of the namespace, including parent namespaces.
2424
/// </summary>

0 commit comments

Comments
 (0)