-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
MarkerClassBuilder.cs
41 lines (36 loc) · 1.08 KB
/
MarkerClassBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Text;
using Havit.SourceGenerators.StrongApiStringLocalizers;
namespace LocalizerGenerator;
internal class MarkerClassBuilder
{
public string Name { get; set; }
public string Namespace { get; set; }
public string BuildSource()
{
var builder = new StringBuilder();
BuildUsings(builder);
BuildNamespace(builder);
return builder.ToString();
}
private void BuildUsings(StringBuilder builder)
{
builder.AppendLine("using System.CodeDom.Compiler;");
builder.AppendLine("using System.ComponentModel;");
}
private void BuildNamespace(StringBuilder builder)
{
builder.Append("namespace ").Append(Namespace).AppendLine();
builder.AppendLine("{");
BuildMarkerClass(builder);
builder.AppendLine("}");
}
private void BuildMarkerClass(StringBuilder builder)
{
builder.AppendGeneratedCodeAttribute().AppendLine();
builder.Append("[Browsable(false)]").AppendLine();
builder.Append("[EditorBrowsable(EditorBrowsableState.Never)]").AppendLine();
builder.Append("public class ").Append(Name).AppendLine();
builder.AppendLine("{");
builder.AppendLine("}");
}
}