private static string ProcessClass(INamedTypeSymbol classSymbol, INamedTypeSymbol attributeSymbol, List <IFieldSymbol> fields, GeneratorExecutionContext generatorExecutionContext) { if (!classSymbol.ContainingSymbol.Equals(classSymbol.ContainingNamespace, SymbolEqualityComparer.Default)) { var syntaxTree = classSymbol.DeclaringSyntaxReferences.First().SyntaxTree; var textSpan = classSymbol.DeclaringSyntaxReferences.First().Span; generatorExecutionContext.ReportDiagnostic( Diagnostics.ClassNotTopLevelDiagnostic(classSymbol.Name, classSymbol.ContainingSymbol.Name, syntaxTree, textSpan)); return(null); } var namespaceName = classSymbol.ContainingNamespace.ToDisplayString(); var source = new ClassTemplate() .WithUsings( new UsingsTemplate() .WithNamespace("System"), new UsingsTemplate() .WithNamespace("System.Windows")) .WithNamespace( new NamespaceTemplate() .WithNamespace(namespaceName)) .WithName(classSymbol.Name); AssignModifiers(source, classSymbol); foreach (var fieldSymbol in fields) { ProcessField(source, classSymbol, attributeSymbol, fieldSymbol); } return(source.GenerateString()); }