@@ -54,6 +54,17 @@ public void Generate_with_usage_in_external_file()
5454 } ) ;
5555 }
5656
57+ [ Test ]
58+ public void Generate_with_empty_root_namespace ( )
59+ {
60+ AssertMatchesSnapshot (
61+ analyzerConfigOptions : new ( KeyValuePair . Create ( "build_property.RootNamespace" , string . Empty ) ) ,
62+ sources : new [ ]
63+ {
64+ ( "Program.docopt.txt" , SourceText . From ( NavalFateUsage ) )
65+ } ) ;
66+ }
67+
5768 [ Test ]
5869 public void Generate_with_inline_usage ( )
5970 {
@@ -256,9 +267,10 @@ sealed partial class ProgramArguments
256267 }
257268
258269 void AssertMatchesSnapshot ( ( string Path , SourceText Text ) [ ] sources ,
270+ AnalyzerConfigOptions ? analyzerConfigOptions = null ,
259271 [ CallerMemberName ] string ? callerName = null )
260272 {
261- var ( driver , compilation ) = PrepareForGeneration ( sources ) ;
273+ var ( driver , compilation ) = PrepareForGeneration ( analyzerConfigOptions ?? new ( ) , sources ) ;
262274
263275 var grr = driver . RunGeneratorsAndUpdateCompilation ( compilation , out var outputCompilation , out _ )
264276 . GetRunResult ( ) . Results . Single ( ) ;
@@ -340,7 +352,16 @@ where Path.GetFileName(fp) is { } fn
340352 || fn . EndsWith ( ".json" , StringComparison . OrdinalIgnoreCase ) )
341353 select Path . GetRelativePath ( solutionDirPath , fp ) ;
342354
343- var actualFiles = EnumerateFiles ( actualSourcesPath ) ;
355+ var actualFiles = EnumerateFiles ( actualSourcesPath ) . ToImmutableArray ( ) ;
356+
357+ Assert . That ( from gs in grr . GeneratedSources
358+ orderby gs . HintName
359+ select gs . HintName ,
360+ Is . EqualTo ( from af in actualFiles
361+ select Path . GetFileName ( af ) into af
362+ where af . EndsWith ( ".cs" , StringComparison . OrdinalIgnoreCase )
363+ orderby af
364+ select af ) ) ;
344365
345366 var expectedFiles = Directory . Exists ( expectedSourcesPath )
346367 ? EnumerateFiles ( expectedSourcesPath )
@@ -553,7 +574,12 @@ public partial class " + ProgramArgumentsClassName + @" { }
553574 new AnalyzerConfigOptions ( KeyValuePair . Create ( "build_metadata.AdditionalFiles.SourceItemType" , "Docopt" ) ) ;
554575
555576 internal static ( CSharpGeneratorDriver , CSharpCompilation )
556- PrepareForGeneration ( params ( string Path , SourceText Text ) [ ] sources )
577+ PrepareForGeneration ( params ( string Path , SourceText Text ) [ ] sources ) =>
578+ PrepareForGeneration ( new AnalyzerConfigOptions ( ) , sources ) ;
579+
580+ internal static ( CSharpGeneratorDriver , CSharpCompilation )
581+ PrepareForGeneration ( AnalyzerConfigOptions analyzerConfigOptions ,
582+ params ( string Path , SourceText Text ) [ ] sources )
557583 {
558584 var trees = new List < SyntaxTree > ( ) ;
559585 var additionalTexts = new List < AdditionalText > ( ) ;
@@ -579,11 +605,9 @@ internal static (CSharpGeneratorDriver, CSharpCompilation)
579605
580606 ISourceGenerator generator = new SourceGenerator ( ) ;
581607
582- var globalOptions = Enumerable . Empty < KeyValuePair < string , string > > ( ) ;
583-
584608 var optionsProvider =
585609 new AnalyzerConfigOptionsProvider (
586- new AnalyzerConfigOptions ( globalOptions ) ,
610+ analyzerConfigOptions ,
587611 additionalTexts . Select ( at => KeyValuePair . Create ( at , DocoptSourceItemTypeConfigOption ) )
588612 . ToImmutableDictionary ( ) ) ;
589613
0 commit comments