@@ -32,22 +32,24 @@ public void Execute(GeneratorExecutionContext context) {
3232
3333 static string GenerateImmutableClass ( TypeDeclarationSyntax mutableClass , Compilation compilation ) {
3434 var containingNamespace = compilation . GetSemanticModel ( mutableClass . SyntaxTree ) . GetDeclaredSymbol ( mutableClass ) ! . ContainingNamespace ;
35-
36- var namespaceName = containingNamespace . ToDisplayString ( ) ;
37-
38- var className = mutableClass . Identifier . Text ;
39-
40- var usings = mutableClass . SyntaxTree . GetCompilationUnitRoot ( ) . Usings . Select ( u => u . ToString ( ) ) ;
35+ var namespaceName = containingNamespace . ToDisplayString ( ) ;
36+ var className = mutableClass . Identifier . Text ;
37+ var usings = mutableClass . SyntaxTree . GetCompilationUnitRoot ( ) . Usings . Select ( u => u . ToString ( ) ) ;
4138
4239 var properties = GetDefinitions ( SyntaxKind . SetKeyword )
43- . Select ( prop => $ " public { prop . Type } { prop . Identifier . Text } {{ get; }}")
40+ . Select (
41+ prop => {
42+ var xml = prop . GetLeadingTrivia ( ) . FirstOrDefault ( x => x . IsKind ( SyntaxKind . SingleLineDocumentationCommentTrivia ) ) . GetStructure ( ) ;
43+ return $ "/// { xml } public { prop . Type } { prop . Identifier . Text } {{ get; }}";
44+ }
45+ )
4446 . ToArray ( ) ;
4547
4648 var props = GetDefinitions ( SyntaxKind . SetKeyword ) . ToArray ( ) ;
4749
4850 const string argName = "inner" ;
49- var mutableProperties = props
50- . Select ( prop => $ " { prop . Identifier . Text } = { argName } .{ prop . Identifier . Text } ;") ;
51+
52+ var mutableProperties = props . Select ( prop => $ " { prop . Identifier . Text } = { argName } .{ prop . Identifier . Text } ;") ;
5153
5254 var constructor = $$ """
5355 public ReadOnly{{ className }} ({{ className }} {{ argName }} ) {
@@ -85,7 +87,8 @@ IEnumerable<PropertyDeclarationSyntax> GetDefinitions(SyntaxKind kind)
8587 . OfType < PropertyDeclarationSyntax > ( )
8688 . Where (
8789 prop =>
88- prop . AccessorList ! . Accessors . Any ( accessor => accessor . Keyword . IsKind ( kind ) ) && prop . AttributeLists . All ( list => list . Attributes . All ( attr => attr . Name . ToString ( ) != "Exclude" ) )
90+ prop . AccessorList ! . Accessors . Any ( accessor => accessor . Keyword . IsKind ( kind ) ) &&
91+ prop . AttributeLists . All ( list => list . Attributes . All ( attr => attr . Name . ToString ( ) != "Exclude" ) )
8992 ) ;
9093 }
91- }
94+ }
0 commit comments