Skip to content

Run the simplifier over the expression generation tests to fix issue 26586#28831

Merged
jinujoseph merged 1 commit intodotnet:masterfrom
Paxxi:issue-26586
Aug 30, 2018
Merged

Run the simplifier over the expression generation tests to fix issue 26586#28831
jinujoseph merged 1 commit intodotnet:masterfrom
Paxxi:issue-26586

Conversation

@Paxxi
Copy link
Copy Markdown
Contributor

@Paxxi Paxxi commented Jul 25, 2018

Adds a new test helper method that runs the expressions
through the simplifier to remove parenthesis.

New test helper wraps the expression under test in some boilerplate to make sure the simplifier works properly. Without the boilerplate the simplifier never did any work. Did I miss something maybe?

Included also is a fix for one of the TestMemberAccessOffOfElementAccess test where the VB simplifier removed parenthesis when it shouldn't. I'm not sure the fix is correct but I included it here to allow for discussion and to get some input on it.
I'm not sure about the template and could use some help filling it out if it's required :)

Ask Mode template not completed

Customer scenario

What does the customer do to get into this situation, and why do we think this
is common enough to address for this release. (Granted, sometimes this will be
obvious "Open project, VS crashes" but in general, I need to understand how
common a scenario is)

Bugs this fixes

#26586

Workarounds, if any

Also, why we think they are insufficient for RC vs. RC2, RC3, or RTW

Risk

This is generally a measure our how central the affected code is to adjacent
scenarios and thus how likely your fix is to destabilize a broader area of code

Performance impact

PR only touches test code so low or no perf impact.

Is this a regression from a previous update?

No

Root cause analysis

How did we miss it? What tests are we adding to guard against it in the future?

How was the bug found?

(E.g. customer reported it vs. ad hoc testing)

Test documentation updated?

If this is a new non-compiler feature or a significant improvement to an existing feature, update https://github.com/dotnet/roslyn/wiki/Manual-Testing once you know which release it is targeting.

@Paxxi Paxxi requested a review from a team as a code owner July 25, 2018 06:37
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Hey @Paxxi , could you update your title to something a bit more descriptive? Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feels like the nodeCreator is superfluous. Just pass the SyntaxGenerator and the generated expression to put in the local-decl-statement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

my preference is that TestWithSimplifier would also run the normal test. So this should actually take 4 strings. cs, csSimple, vb, vbSimple.

After all, the point of this file is to test the generator not the simplifier, so we want to ensure we're always at least testing the generator output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Then it doesn't make so much sense to have two different test methods. I'll merge it all into the Test method. I initially separated them because some tests appeared to not result in valid syntax when used as a local declaration. Can pass null to csSimple/vbSimple if that's the case then.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

comment above needs to be updated to explain why this is necessary.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Included also is a fix for one of the TestMemberAccessOffOfElementAccess test where the VB simplifier removed parenthesis when it shouldn't. I'm not sure the fix is correct but I included it here to allow for discussion and to get some input on it.

I think the fix is likely correct. presumably this is to deal with the (a + b)(0) case, yes? If so, removing parens around a + b would definitely break things.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Without the boilerplate the simplifier never did any work. Did I miss something maybe?

Nope. That's the correct way to do things. The Simplifier needs real code to work on. Something like "(1) + (1)" is not actually legal C#, so there's no way to properly parse that, let alone doing any semantic analysis of it to determine if can be simplified.

@Paxxi Paxxi changed the title Fixes issue 26586 Run the simplifier over the expression generation tests to fix issue 26586 Jul 25, 2018
@Paxxi
Copy link
Copy Markdown
Contributor Author

Paxxi commented Jul 25, 2018

Merged the TestWithSimplifier into the Test and updated all the test cases to supply expected values for both versions. Added a comment in the same style as those already present.
Should take care of all comments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

might be a good idea to assert that at least one of those 4 tests is not null. We've def had cases in the past where you could call a test method with not enough info and always pass :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I'll add that :)

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

In addition to testing the expressions as generated,
with parenthesis in place, also run them through the simplifier.
New Test method helper takes two new parameters, csSimple and
vbSimple. When set to null the simplifier step is skipped.
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@dotnet/roslyn-ide @jinujoseph @jcouv can this test-only change be merged in? thanks!

@jinujoseph jinujoseph added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Aug 13, 2018
@jinujoseph jinujoseph added this to the 16.0 milestone Aug 13, 2018
@jinujoseph jinujoseph added the Test Test failures in roslyn-CI label Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. Test Test failures in roslyn-CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants