@@ -36,15 +36,8 @@ public sealed class SourceGenerator : ISourceGenerator
36
36
DiagnosticSeverity . Error ,
37
37
isEnabledByDefault : true ) ;
38
38
39
- public void Initialize ( GeneratorInitializationContext context )
40
- {
39
+ public void Initialize ( GeneratorInitializationContext context ) =>
41
40
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
- }
48
41
49
42
sealed class SyntaxReceiver : ISyntaxContextReceiver
50
43
{
@@ -200,24 +193,6 @@ public void Execute(GeneratorExecutionContext context)
200
193
static readonly SourceText EmptySourceText = SourceText . From ( string . Empty ) ;
201
194
static readonly Encoding Utf8BomlessEncoding = new UTF8Encoding ( encoderShouldEmitUTF8Identifier : false ) ;
202
195
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
-
221
196
static readonly string [ ] Vars = "abcdefghijklmnopqrstuvwxyz" . Select ( ch => ch . ToString ( ) ) . ToArray ( ) ;
222
197
223
198
[ Flags ]
0 commit comments