Skip to content

Commit 6c65cd9

Browse files
committed
Changed to use XAttribute when encoding the company name and file name so quote characters work. Modified the test to match.
1 parent 03fa028 commit 6c65cd9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1634UnitTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public async Task TestFileHeaderWithMultiLineCommentAndFieldsNeedingXmlEscapingA
285285
{
286286
""settings"": {
287287
""documentationRules"": {
288-
""companyName"": ""Foo & Bar Corp"",
288+
""companyName"": ""Foo & Bar \""quote\"" Corp"",
289289
""copyrightText"": ""copyright (c) {companyName}. All rights reserved.\n\nLine #3""
290290
}
291291
}
@@ -300,8 +300,8 @@ namespace Bar
300300
}
301301
";
302302

303-
var fixedCode = @"// <copyright file=""Test0.cs"" company=""Foo &amp; Bar Corp"">
304-
// copyright (c) Foo &amp; Bar Corp. All rights reserved.
303+
var fixedCode = @"// <copyright file=""Test0.cs"" company=""Foo &amp; Bar &quot;quote&quot; Corp"">
304+
// copyright (c) Foo &amp; Bar ""quote"" Corp. All rights reserved.
305305
//
306306
// Line #3
307307
// </copyright>

StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/FileHeaderCodeFixProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ private static SyntaxTriviaList CreateNewHeader(string prefixWithLeadingSpaces,
353353

354354
private static string WrapInXmlComment(string prefixWithLeadingSpaces, string copyrightText, string filename, StyleCopSettings settings, string newLineText)
355355
{
356-
string encodedFilename = new XText(filename).ToString();
357-
string encodedCompanyName = new XText(settings.DocumentationRules.CompanyName).ToString();
356+
string encodedFilename = new XAttribute("t", filename).ToString().Substring(2).Trim('"');
357+
string encodedCompanyName = new XAttribute("t", settings.DocumentationRules.CompanyName).ToString().Substring(2).Trim('"');
358358
string encodedCopyrightText = new XText(copyrightText).ToString();
359359

360360
return

0 commit comments

Comments
 (0)