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
22 changes: 12 additions & 10 deletions src/Build/Evaluation/Conditionals/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,33 +325,35 @@ private static bool ScanForPropertyExpressionEnd(string expression, int index, o
{
fixed (char* pchar = expression)
{
if (expression.Length > 1 && pchar[0] == '(' && char.IsWhiteSpace(pchar[1]) && ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave16_10))
Copy link
Member

Choose a reason for hiding this comment

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

is the first character in the expression guaranteed to be a '('?

Should this maybe move under the `if (character == '(')?

Something like:

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

{
indexResult = 1;
return false;
}

while (index < expression.Length)
{
char character = pchar[index];
if (character == '(')
{
nestLevel++;
if (index + 1 < expression.Length && char.IsWhiteSpace(pchar[index + 1]) && ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave16_10))
{
indexResult = index + 1;
return false;
}
}
else if (character == ')')
{
nestLevel--;
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
// this should be the end of the property expression
// If it is not then the calling code will determine that
if (nestLevel == 0)
{
if (index > 0 && char.IsWhiteSpace(pchar[index - 1]) && ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave16_10))
{
indexResult = index - 1;
return false;
}

indexResult = index;
return true;
}
Expand Down