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

OnlyCheckWhitespaceInsideParenthesis Fixes #5863 #5868

Merged
merged 8 commits into from
Nov 11, 2020
Merged
Changes from 1 commit
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
19 changes: 10 additions & 9 deletions src/Build/Evaluation/Conditionals/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ private string ParsePropertyOrItemMetadata()
private static bool ScanForPropertyExpressionEnd(string expression, int index, out int indexResult)
{
int nestLevel = 0;
bool whitespaceCheck = false;

unsafe
{
fixed (char* pchar = expression)
Expand All @@ -333,17 +331,20 @@ private static bool ScanForPropertyExpressionEnd(string expression, int index, o
if (character == '(')
{
nestLevel++;
whitespaceCheck = true;
if (index + 1 < expression.Length && char.IsWhiteSpace(pchar[index + 1]) && ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave16_10))
Copy link
Member

@benvillalobos benvillalobos Nov 6, 2020

Choose a reason for hiding this comment

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

we only care about a space after an open parens and before a close parens? What about before / after each one? That's the case here: #5863
<ItemGroup Condition="$(Foo.StartsWith ('A'))">

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, so we should ignore cases like that because we don't want them to fail.

{
indexResult = index + 1;
return false;
}
}
else if (character == ')')
{
nestLevel--;
whitespaceCheck = false;
}
else if (whitespaceCheck && char.IsWhiteSpace(character) && ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave16_10))
{
indexResult = index;
return false;
if (index > 0 && char.IsWhiteSpace(pchar[index - 1]) && ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave16_10))
{
indexResult = index - 1;
return false;
}
}

// We have reached the end of the parenthesis nesting
Expand Down