@@ -29,11 +29,17 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
2929 } )
3030 . Where ( s => s is not null ) ! ;
3131
32+
33+
3234 var compilationAndClasses = context . CompilationProvider
3335 . Combine ( classSymbols . Collect ( ) ) ;
3436
3537 context . RegisterSourceOutput ( compilationAndClasses , ( spc , source ) =>
3638 {
39+ if ( source . Right . IsEmpty ) return ;
40+
41+ var projectName = source . Left . AssemblyName ?? "GeneratedProject" ;
42+
3743 var ( compilation , classes ) = source ;
3844 var services = classes . OfType < ( INamedTypeSymbol symbol , AttributeData attr ) > ( ) . Distinct ( ) . ToList ( ) ;
3945
@@ -44,7 +50,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
4450 sb . AppendLine ( "using System.Collections.Generic;" ) ;
4551 sb . AppendLine ( "using System.Reflection;" ) ;
4652 sb . AppendLine ( ) ;
47- sb . AppendLine ( "namespace SimpleInjection.Injection ;" ) ;
53+ sb . AppendLine ( $ "namespace { projectName } .Genenerated ;") ;
4854 sb . AppendLine ( "public sealed class Host : IDisposable" ) ;
4955 sb . AppendLine ( "{" ) ;
5056 sb . AppendLine ( " private readonly Dictionary<Type, object> _singletonInstances = new();" ) ;
@@ -64,10 +70,10 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
6470
6571 // Build dependency graph and sort services
6672 var serviceInfos = BuildServiceInfos ( services , compilation ) ;
67- var sortedServices = TopologicalSort ( serviceInfos ) ;
73+
6874
6975 // Generate baked factories in dependency order
70- foreach ( var serviceInfo in sortedServices )
76+ foreach ( var serviceInfo in TopologicalSort ( serviceInfos ) )
7177 {
7278 GenerateFactory ( sb , serviceInfo , compilation ) ;
7379 }
@@ -82,7 +88,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
8288
8389 sb . AppendLine ( "}" ) ;
8490
85- spc . AddSource ( " Host.Configure.g.cs", SourceText . From ( sb . ToString ( ) , Encoding . UTF8 ) ) ;
91+ spc . AddSource ( $ " { projectName } . Host.Configure.g.cs", SourceText . From ( sb . ToString ( ) , Encoding . UTF8 ) ) ;
8692 } ) ;
8793 }
8894
0 commit comments