@@ -32,22 +32,24 @@ public void Execute(GeneratorExecutionContext context) {
32
32
33
33
static string GenerateImmutableClass ( TypeDeclarationSyntax mutableClass , Compilation compilation ) {
34
34
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 ( ) ) ;
41
38
42
39
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
+ )
44
46
. ToArray ( ) ;
45
47
46
48
var props = GetDefinitions ( SyntaxKind . SetKeyword ) . ToArray ( ) ;
47
49
48
50
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 } ;") ;
51
53
52
54
var constructor = $$ """
53
55
public ReadOnly{{ className }} ({{ className }} {{ argName }} ) {
@@ -85,7 +87,8 @@ IEnumerable<PropertyDeclarationSyntax> GetDefinitions(SyntaxKind kind)
85
87
. OfType < PropertyDeclarationSyntax > ( )
86
88
. Where (
87
89
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" ) )
89
92
) ;
90
93
}
91
- }
94
+ }
0 commit comments