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

Fix the ability to expand the list of analyzers in a reference #49574

Merged
1 commit merged into from
Nov 23, 2020

Conversation

jasonmalinowski
Copy link
Member

This was broken by 7fa2c96, where I asserted that GetDiagnosticItems was only called when we already knew we would have items. This was broken since right before we called the method the collection would get created, which changed the answer it would return. A small refactoring ensures we create the list and fill it in at once. This also makes it clear we aren't passing a non-trivial LINQ query across method boundaries anyways in a way that might result in multiple enumerations.

Fixes #49524

This was broken by 7fa2c96, where I
asserted that GetDiagnosticItems was only called when we already knew
we would have items. This was broken since right before we called the
method the collection would get created, which changed the answer
it would return. A small refactoring ensures we create the list and
fill it in at once. This also makes it clear we aren't passing a
non-trivial LINQ query across method boundaries anyways in a way that
might result in multiple enumerations.

Fixes dotnet#49524
@@ -110,7 +109,9 @@ private IEnumerable<BaseDiagnosticItem> GetDiagnosticItems(string language, Comp

Contract.ThrowIfFalse(HasItems);
Copy link
Member Author

Choose a reason for hiding this comment

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

This was the problematic assert: conceptually the idea was "we shouldn't be trying to create items if we know we don't have any to show", but in the code prior to this new change we would assign the field before calling GetDiagnosticItems, so HasItems would instead return false because we had realized the list prematurely.

@ghost
Copy link

ghost commented Nov 23, 2020

Hello @jasonmalinowski!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit 4262935 into dotnet:master Nov 23, 2020
@ghost ghost added this to the Next milestone Nov 23, 2020
@jasonmalinowski jasonmalinowski deleted the fix-broken-analyzer-list branch November 23, 2020 23:40
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Analyzer nodes aren't expanding properly
5 participants