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

Support raw UTF8 String Literals #59390

Merged

Conversation

AlekseyTs
Copy link
Contributor

@AlekseyTs AlekseyTs commented Feb 8, 2022

Relates to test plan #58848

@AlekseyTs AlekseyTs added Area-Compilers New Feature - Utf8StringLiterals PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. and removed PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. labels Feb 8, 2022
@AlekseyTs AlekseyTs requested review from RikkiGibson, cston and a team February 8, 2022 23:16
@AlekseyTs AlekseyTs marked this pull request as ready for review February 8, 2022 23:16
@AlekseyTs
Copy link
Contributor Author

@cston, @RikkiGibson, @dotnet/roslyn-compiler Please review.

@RikkiGibson RikkiGibson self-assigned this Feb 9, 2022
@AlekseyTs
Copy link
Contributor Author

@cston, @dotnet/roslyn-compiler For the second review.

N(SyntaxKind.EndOfDirectiveToken);
}
EOF();
}
Copy link
Member

@cston cston Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

Please add tests for enhanced line directives with UTF8 string literals and UTF8 raw string literals:

#line (1, 2)-(3, 4) ""file.cs""u8
#line (1, 2)-(3, 4) """file.cs"""u8
``` #Resolved

Copy link
Contributor Author

@AlekseyTs AlekseyTs Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for enhanced line directives with UTF8 string literals and UTF8 raw string literals:

If you insist, I can add the suggested test. However, I do not see much benefits in testing every single directive flavor. The goal is to test how we scan literals in context of directives, i.e. to confirm that we do not recognize the suffix. I believe the existing tests are sufficient to cover the scenario.

Please let me know if you still want me to add the tests.

@@ -32,3 +32,5 @@ static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.InterpolatedStringExpression(
Microsoft.CodeAnalysis.CSharp.Conversion.IsUtf8StringLiteral.get -> bool
Copy link
Member

@cston cston Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utf8

Consider changing to IsUTF8StringLiteral for consistency with public API members below. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing to IsUTF8StringLiteral for consistency with public API members below.

If there are no objections, I prefer doing this in a separate PR.


[Theory]
[InlineData("u80")]
[InlineData("U80")]
Copy link
Member

@cston cston Feb 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be "u8" and "U8" rather than "u80" and "U80"? Same question for other Interpolation_0*() tests below. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be "u8" and "U8" rather than "u80" and "U80"?

Yes, good catch. I'll fix.

@AlekseyTs AlekseyTs enabled auto-merge (squash) February 10, 2022 23:02
@AlekseyTs AlekseyTs merged commit 414ebea into dotnet:features/Utf8StringLiterals Feb 10, 2022
@CyrusNajmabadi
Copy link
Member

Note to self: IDE code that works with raw string literals must not presume that a syntactically valid raw string starts and ends with the exact same sequence of quotes. e.g. """x"""u8 is legal. Code in the ide that finds the content portion needs to be resilient to u8/U8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants