@@ -117,6 +117,24 @@ internal static ImmutableArray<string> GenerateStandardText(Document document, B
117117 }
118118 }
119119
120+ internal static SyntaxList < XmlNodeSyntax > BuildStandardTextSyntaxList ( BaseTypeDeclarationSyntax typeDeclaration , string preText , string postText )
121+ {
122+ TypeParameterListSyntax typeParameterList ;
123+ if ( typeDeclaration is ClassDeclarationSyntax classDeclaration )
124+ {
125+ typeParameterList = classDeclaration . TypeParameterList ;
126+ }
127+ else
128+ {
129+ typeParameterList = ( typeDeclaration as StructDeclarationSyntax ) ? . TypeParameterList ;
130+ }
131+
132+ return XmlSyntaxFactory . List (
133+ XmlSyntaxFactory . Text ( preText ) ,
134+ BuildSeeElement ( typeDeclaration . Identifier , typeParameterList ) ,
135+ XmlSyntaxFactory . Text ( postText . EndsWith ( "." ) ? postText : ( postText + "." ) ) ) ;
136+ }
137+
120138 internal static SyntaxList < XmlNodeSyntax > BuildStandardTextSyntaxList ( BaseTypeDeclarationSyntax typeDeclaration , string newLineText , string preText , string postText )
121139 {
122140 TypeParameterListSyntax typeParameterList ;
@@ -143,8 +161,6 @@ private static Task<Document> GetTransformedDocumentAsync(Document document, Syn
143161
144162 var standardText = GenerateStandardText ( document , declarationSyntax , typeDeclaration , cancellationToken ) ;
145163
146- string newLineText = document . Project . Solution . Workspace . Options . GetOption ( FormattingOptions . NewLine , LanguageNames . CSharp ) ;
147-
148164 string trailingString = string . Empty ;
149165
150166 var newContent = RemoveMalformattedStandardText ( node . Content , standardText [ 0 ] , standardText [ 1 ] , ref trailingString ) ;
@@ -157,7 +173,18 @@ private static Task<Document> GetTransformedDocumentAsync(Document document, Syn
157173 }
158174 }
159175
160- var list = BuildStandardTextSyntaxList ( typeDeclaration , newLineText , standardText [ 0 ] , standardText [ 1 ] + trailingString ) ;
176+ SyntaxList < XmlNodeSyntax > list ;
177+ if ( IsMultiLine ( node ) )
178+ {
179+ string newLineText = document . Project . Solution . Workspace . Options . GetOption ( FormattingOptions . NewLine , LanguageNames . CSharp ) ;
180+ list = BuildStandardTextSyntaxList ( typeDeclaration , newLineText , standardText [ 0 ] , standardText [ 1 ] + trailingString ) ;
181+ }
182+ else
183+ {
184+ list = BuildStandardTextSyntaxList ( typeDeclaration , standardText [ 0 ] , standardText [ 1 ] + trailingString ) ;
185+ }
186+
187+
161188 newContent = newContent . InsertRange ( 0 , list ) ;
162189
163190 newContent = RemoveTrailingEmptyLines ( newContent ) ;
@@ -171,6 +198,12 @@ private static Task<Document> GetTransformedDocumentAsync(Document document, Syn
171198 return Task . FromResult ( newDocument ) ;
172199 }
173200
201+ private static bool IsMultiLine ( XmlElementSyntax node )
202+ {
203+ var lineSpan = node . GetLineSpan ( ) ;
204+ return lineSpan . StartLinePosition . Line != lineSpan . EndLinePosition . Line ;
205+ }
206+
174207 private static Task < Document > GetTransformedDocumentAsync ( Document document , SyntaxNode root , XmlEmptyElementSyntax node )
175208 {
176209 var typeDeclaration = node . FirstAncestorOrSelf < BaseTypeDeclarationSyntax > ( ) ;
0 commit comments