-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
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); |
There was a problem hiding this comment.
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.
Hello @jasonmalinowski! Because this pull request has the 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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-approval
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