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

Ensure both parts of partial methods are analyzed when requesting analyzer diagnostics for a single file #71201

Merged
merged 2 commits into from
Dec 11, 2023

Conversation

mavasani
Copy link
Contributor

Fixes #71149

This is a bug in the core analyzer driver that only happens when we have a partial implementation part of a partial method in a separate file (doesn't matter if it is a regular file or a generated file), and this partial type definition has no other members defined. First commit in this PR: 65ca155 shows the unit test that fails when separateFiles = true without the fix.

The fix is to ensure we analyze both parts of partial when requesting analyzer diagnostics for a single file (happens for open file analysis for IDE live analysis)

Verified that the test fails for `separateFiles = true` and passes for `separateFiles = false`, confirming that SymbolEnd action is not being called when the type has a partial definition in a separate file with partial member implementation part.
…analysis, regardless of whether one or both of them are defined in the same file

Fixes dotnet#71149
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Dec 11, 2023
@mavasani mavasani marked this pull request as ready for review December 11, 2023 07:48
@mavasani mavasani requested a review from a team as a code owner December 11, 2023 07:48
@mavasani mavasani requested review from AlekseyTs and cston December 11, 2023 07:48
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 2)

@CyrusNajmabadi
Copy link
Member

@333fred could you ptal. thanks!

@CyrusNajmabadi
Copy link
Member

@mavasani does this fix #71149 ? If so, could you add a test? I'm also happy to do so if you'd just like to get this PR in :)

@mavasani
Copy link
Contributor Author

mavasani commented Dec 11, 2023

@mavasani does this fix #71149 ? If so, could you add a test? I'm also happy to do so if you'd just like to get this PR in :)

Yes, this should fix that issue. I tried adding the unit test for the analyzer first and get it to fail. However, the MS.CA.Testing library runs the test by computing diagnostics over the whole compilation, it does not mimic IDE open file analysis that requests diagnostics for a single file at a time. This bug only repros with the latter approach, hence adding an IDE analyzer test won’t help with respect to this fix.

@CyrusNajmabadi
Copy link
Member

@mavasani Gotcha.

@mavasani
Copy link
Contributor Author

Thanks!

@mavasani mavasani merged commit c743585 into dotnet:main Dec 11, 2023
@mavasani mavasani deleted the Issue_71149 branch December 11, 2023 21:40
@ghost ghost added this to the Next milestone Dec 11, 2023
@Cosifne Cosifne modified the milestones: Next, 17.9 P3 Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IDE0290 refactoring doesn't work in presense of GeneratedRegex
5 participants