Skip to content

Commit 1428fff

Browse files
committed
Remove unused source generator post initialization
1 parent b9bcd4c commit 1428fff

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

src/DocoptNet/CodeGeneration/SourceGenerator.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,8 @@ public sealed class SourceGenerator : ISourceGenerator
3636
DiagnosticSeverity.Error,
3737
isEnabledByDefault: true);
3838

39-
public void Initialize(GeneratorInitializationContext context)
40-
{
39+
public void Initialize(GeneratorInitializationContext context) =>
4140
context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
42-
context.RegisterForPostInitialization(context =>
43-
{
44-
foreach (var (fn, source) in GetEmbeddedCSharpSources(fn => DoesFileNameEndIn(fn, "Attribute")))
45-
context.AddSource(fn, source);
46-
});
47-
}
4841

4942
sealed class SyntaxReceiver : ISyntaxContextReceiver
5043
{
@@ -200,24 +193,6 @@ public void Execute(GeneratorExecutionContext context)
200193
static readonly SourceText EmptySourceText = SourceText.From(string.Empty);
201194
static readonly Encoding Utf8BomlessEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
202195

203-
IEnumerable<(string, SourceText)> GetEmbeddedCSharpSources(Func<string, bool> predicate)
204-
{
205-
const string resourceNamespace = nameof(DocoptNet) + "." + nameof(CodeGeneration);
206-
var assembly = GetType().Assembly;
207-
foreach (var (rn, fn) in from rn in assembly.GetManifestResourceNames()
208-
where rn.StartsWith(resourceNamespace) && rn.EndsWith(".cs")
209-
select (ResourceName: rn, FileName: rn.Substring(resourceNamespace.Length)) into e
210-
where predicate(e.FileName)
211-
select e)
212-
{
213-
using var stream = assembly.GetManifestResourceStream(rn)!;
214-
yield return (fn, SourceText.From(stream, canBeEmbedded: true));
215-
}
216-
}
217-
218-
static bool DoesFileNameEndIn(string fileName, string ending) =>
219-
Path.GetFileNameWithoutExtension(fileName).EndsWith(ending, StringComparison.OrdinalIgnoreCase);
220-
221196
static readonly string[] Vars = "abcdefghijklmnopqrstuvwxyz".Select(ch => ch.ToString()).ToArray();
222197

223198
[Flags]

0 commit comments

Comments
 (0)