[features/param-nullchecking] The BangBang Update#46520
Conversation
1b210e2 to
42fa7f4
Compare
|
Done review pass (commit 23). The implementation is looking mostly good, but we need more tests. #Closed |
src/Compilers/CSharp/Test/Semantic/Semantics/NullCheckedParameterTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Semantics/NullCheckedParameterTests.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Semantic/Semantics/NullCheckedParameterTests.cs
Outdated
Show resolved
Hide resolved
|
Done review pass (commit 24). |
src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Syntax/Parsing/LambdaParameterParsingTests.cs
Outdated
Show resolved
Hide resolved
333fred
left a comment
There was a problem hiding this comment.
LGTM (commit 29). @dotnet/roslyn-compiler for a second review.
| case '!': | ||
| TextWindow.AdvanceChar(); | ||
| if (TextWindow.PeekChar() == '=') | ||
| if (TextWindow.PeekChar() == '=' && TextWindow.PeekChar(-2) != '!') |
There was a problem hiding this comment.
Was a bit worried that this would cause a compat break but then remembered we do issue an error for this case:
var x = s!! = null;Haven't gotten to the tests yet but if you didn't have to change a test like this we should write one to ensure it keeps failing after this change.
There was a problem hiding this comment.
Oh, that's no longer in there. I think that was from commit 17, and is gone now. It does break things and I had to change a bit of PeerChar that broke an invariant back then, but those have since been removed.
| if (this.CurrentToken.Kind == SyntaxKind.ExclamationEqualsToken) | ||
| { | ||
| var exclamationEquals = this.EatToken(); | ||
| var exclamation2 = SyntaxFactory.Token(exclamationEquals.GetLeadingTrivia(), SyntaxKind.ExclamationToken, null); |
There was a problem hiding this comment.
exclamation2 [](start = 32, length = 12)
Consider renaming to "exclamation" since there's no "exclamation[1]'.
There was a problem hiding this comment.
Might do that, or rename it to secondExclamation to emphasize that it's meant to be a part of the other Exclamation.
|
|
||
| private SyntaxToken MergeTokens(SyntaxToken s1, SyntaxToken s2, SyntaxKind kind) | ||
| { | ||
| if (s1.GetTrailingTriviaWidth() == 0 && s2.GetLeadingTriviaWidth() == 0) |
There was a problem hiding this comment.
s1.GetTrailingTriviaWidth() == 0 && s2.GetLeadingTriviaWidth() == 0 [](start = 16, length = 67)
Are we testing both cases where this fails? (When s1.GetTrailingTriviaWidth() > 0 and when s1.GetTrailingTriviaWidth() == 0 && s2.GetLeadingTriviaWidth() > 0?)
For instance:
static void F(object arg!
!= null);
There was a problem hiding this comment.
Here are some of the cases covered:
void M0(string name !!=null) { }
void M1(string name! !=null) { }
void M2(string name!!= null) { }
void M3(string name ! !=null) { }
void M4(string name ! ! =null) { }
void M5(string name! ! =null) { }
| } | ||
| else | ||
| { | ||
| s2 = this.AddError(s2, ErrorCode.ERR_InvalidExprTerm, this.CurrentToken.Text); |
There was a problem hiding this comment.
this.CurrentToken.Text [](start = 70, length = 22)
Referencing this.CurrentToken seems surprising. Should this be s2 instead? #Closed
There was a problem hiding this comment.
You're absolutely right, changed.
| @@ -10896,9 +10904,10 @@ private bool ScanParenthesizedImplicitlyTypedLambda(Precedence precedence) | |||
| { | |||
| // allow for a) => or a!) => | |||
There was a problem hiding this comment.
a! [](start = 53, length = 2)
"a!!" #Closed
There was a problem hiding this comment.
Fixed, thanks!
| if (exclamationExclamation != null) | ||
| { | ||
| exclamationExclamation = (exclamationExclamation.Kind != SyntaxKind.ExclamationExclamationToken) | ||
| ? ConvertToMissingWithTrailingTrivia(exclamationExclamation, SyntaxKind.ExclamationExclamationToken) |
There was a problem hiding this comment.
ConvertToMissingWithTrailingTrivia(exclamationExclamation, SyntaxKind.ExclamationExclamationToken) [](start = 26, length = 98)
Should MergeTokens() be handling, rather than requiring each caller to do so?
There was a problem hiding this comment.
Thanks for the tip, I've modified MergeTokens to handle the conversion. Shouldn't have merged so early, it'll be in the next PR.
|
|
||
| [Fact(Skip = "PROTOTYPE(BangBang)")] | ||
| [Fact] | ||
| public void TestOptParamMethodDeclarationWithNullValidationNoSpaces() |
There was a problem hiding this comment.
TestOptParamMethodDeclarationWithNullValidationNoSpaces [](start = 20, length = 55)
Is this distinct from TestNullCheckedArgWithLeadingNewLine()?
|
|
||
| [Fact(Skip = "PROTOTYPE(BangBang)")] | ||
| [Fact] | ||
| public void TestNullCheckedArgWithLeadingNewLine() |
There was a problem hiding this comment.
TestNullCheckedArgWithLeadingNewLine [](start = 20, length = 36)
The name seems misleading since there aren't any newlines.
|
|
||
| [Fact(Skip = "PROTOTYPE(BangBang)")] | ||
| [Fact] | ||
| public void TestNullCheckedArgWithLeadingSpace() |
There was a problem hiding this comment.
TestNullCheckedArgWithLeadingSpace [](start = 20, length = 34)
Are the tokens in the following three tests distinct? If not, please consider merging into a single test method using `[Theory][InlineData("...")]...".
|
|
||
| [Fact(Skip = "PROTOTYPE(BangBang)")] | ||
| [Fact] | ||
| public void TestNullCheckedArgWithSpaceAfterEquals() |
There was a problem hiding this comment.
TestNullCheckedArgWithSpaceAfterEquals [](start = 20, length = 38)
Is this distinct from TestNullCheckedArgWithTrailingSpace()?
Updated
features/param-nullcheckingfor new!!syntax.