-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Field-backed properties: recognize field in interpolated string #75566
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs tests for field used in the alignment or format specifier sections of an interpolation. In particular, what will happen when there's a constant named field and field is used in the alignment section.
@@ -377,6 +378,7 @@ private static InterpolationSyntax ParseInterpolation( | |||
|
|||
// Now create a parser to actually handle the expression portion of the interpolation | |||
using var tempParser = new LanguageParser(tempLexer, oldTree: null, changes: null); | |||
using var __ = new FieldKeywordContext(tempParser, isInFieldKeywordContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why __
instead of simply _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var __
was used for the other location in the parser to avoid conflicting with out _
. Updated here.
var verifier = CompileAndVerify(comp, verify: Verification.Skipped, expectedOutput: IncludeExpectedOutput(""" | ||
P1: True | ||
2 | ||
""")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider calling verifier.VerifyDiagnostics
. Applies to the tests below as well.
Parse
field
as a keyword when used in an interpolated string in an accessor.See dotnet/csharplang#140 (comment)