Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U+0085 not recognised as a newline character in CSharpCodeGenerator.cs (#1740) #1853

Merged
merged 6 commits into from
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ private string QuoteSnippetStringCStyle(string value)
break;
case '\u2028':
case '\u2029':
case '\u0085':
hamarb123 marked this conversation as resolved.
Show resolved Hide resolved
AppendEscapedChar(b, value[i]);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ public void CharEncoding()

AssertEqual(main,
"public static void Main() { " +
" System.Console.WriteLine(\"\u1234 \u4567 \uABCD \\r \\n \\t \\\\ \\\" \\' \\0 \\u2028 \\u2029 \u0084 \u0085 \U00010F00\"); " +
" System.Console.WriteLine(\"\u1234 \u4567 \uABCD \\r \\n \\t \\\\ \\\" \\' \\0 \\u2028 \\u2029 \u0084 \\u0085 \U00010F00\"); " +
hamarb123 marked this conversation as resolved.
Show resolved Hide resolved
"}");
}

Expand Down Expand Up @@ -3449,5 +3449,21 @@ public static void Main()
}
}");
}

[Fact]
public void SpecialNewLineCharactersInStringsDoneCorrectly()
{
var cd = new CodeTypeDeclaration("ClassWithStringFields") { IsClass = true };

var field = new CodeMemberField("System.String", "StringWithSpecialNewLines");
field.Attributes = MemberAttributes.Public | MemberAttributes.Static;
field.InitExpression = new CodePrimitiveExpression("\u0085\u2028\u2029");
cd.Members.Add(field);

AssertEqual(cd,
@"public class ClassWithStringFields {
public static string StringWithSpecialNewLines = ""\u0085\u2028\u2029"";
}");
}
}
}