-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Issue with QuoteSnippetStringCStyle when parsing '\u0085' character #1740
Comments
Thanks for reporting this! Your reasoning seems sound to me. Feel free to look through our contribution guidelines then send a PR with your proposed fix. Remember also to update any appropriate unit tests to validate your change |
@GrabYourPitchforks, what sort of a test would I need, a test that checks if a class with a string in it has the correct contents when the string has newline characters in it? Also, where should I put the test? Maybe in here? [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"";
}");
} Is there anything that I should rename? |
That looks like a fine test. The area owners might have further feedback regarding naming once you submit the PR. |
The PR is at #1853 |
#1740) (#1853) * Fix for issue #1740 U+0085 not recognised as a newline character in CSharpCodeGenerator.cs Fix $1740 * Fix for issue #1740 U+0085 not recognised as a newline character in CSharpCodeGenerator.cs * Fix for issue #1740 U+0085 not recognised as a newline character in CSharpCodeGenerator.cs This change fixes a previous test that incorrectly causes the character to be forced out of being in unicode format. * Stop the changes from #1740 on the .Net Framework as per #1913 Read #1913 for why, view PR #1853 and #1740 also.
This has now been solved, see PR #1853. |
Another line needs to be added after this, which would be
This is because it is recognised as a newline character in C# (see here), which cannot be in literal strings.
If the CSharpCodeGenerator class was used to make code with a string in it that has U+0085 in it, it would generate invalid C# code.
NB: this is also an issue on the .NET Framework (see here)
I would like to implement this change, thanks!
The text was updated successfully, but these errors were encountered: