File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -117,19 +117,18 @@ protected override ImmutableArray<MemberDeclarationSyntax> FilterDeclaredMembers
117
117
// If the target type has no constructors, generate constructors as well
118
118
if ( ! info . HasExplicitConstructors )
119
119
{
120
- foreach ( ConstructorDeclarationSyntax ctor in memberDeclarations . OfType < ConstructorDeclarationSyntax > ( ) )
120
+ foreach ( ConstructorDeclarationSyntax originalConstructor in memberDeclarations . OfType < ConstructorDeclarationSyntax > ( ) )
121
121
{
122
- string text = ctor . NormalizeWhitespace ( ) . ToFullString ( ) ;
123
- string replaced = text . Replace ( "ObservableRecipient" , info . TypeName ) ;
122
+ ConstructorDeclarationSyntax modifiedConstructor = originalConstructor . WithIdentifier ( Identifier ( info . TypeName ) ) ;
124
123
125
124
// Adjust the visibility of the constructors based on whether the target type is abstract.
126
125
// If that is not the case, the constructors have to be declared as public and not protected.
127
126
if ( ! info . IsAbstract )
128
127
{
129
- replaced = replaced . Replace ( "protected" , "public" ) ;
128
+ modifiedConstructor = modifiedConstructor . WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) ) ) ;
130
129
}
131
130
132
- builder . Add ( ( ConstructorDeclarationSyntax ) ParseMemberDeclaration ( replaced ) ! ) ;
131
+ builder . Add ( modifiedConstructor ) ;
133
132
}
134
133
}
135
134
You can’t perform that action at this time.
0 commit comments