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

MSTEST0013: AssemblyCleanup should be valid #2353

Merged
merged 3 commits into from
Feb 16, 2024
Merged

Conversation

engyebrahim
Copy link
Member

fix: #2230

@Evangelink Evangelink changed the title AssemblyCleanup should be valid MSTEST0013: AssemblyCleanup should be valid Feb 16, 2024
Comment on lines +104 to +105
|| (!canDiscoverInternals && methodSymbol.GetResultantVisibility() != SymbolVisibility.Public)
|| (canDiscoverInternals && methodSymbol.GetResultantVisibility() == SymbolVisibility.Private))
Copy link
Member

@nohwnd nohwnd Feb 16, 2024

Choose a reason for hiding this comment

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

This will not run.

The declared accessibility of the method should always be public. The DiscoverInternals should only apply to the class (when disabled only public classes with [TestClass] should be scanned, if enabled public and internal classes should be scanned).

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@nohwnd Yeah that's the correct case here, I added tests that test all those scenarios correctly

Copy link
Member

Choose a reason for hiding this comment

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

@nohwnd DeclaredAccesibility is what is declared on the method and is the first check Engy's doing here. The other checks are using GetResultantVisibility that walks up tree (class + outer classes) to get the final accessibility. We had offline chat with Engy and the code she wrotes LGTM.

Copy link
Member

Choose a reason for hiding this comment

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

@Evangelink this resource, and other resources don't reflect the changes made for Task and ValueTask https://github.com/microsoft/testfx/blob/main/src/Adapter/MSTest.TestAdapter/Resources/Resource.resx#L212

Thanks! I see some other resources are missing edit. I'll do a follow-up

Copy link
Member

Choose a reason for hiding this comment

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

You are right, and I am wrong. :) (For others: The first check makes sure that the class always has public on the member, the other two check the visibility due to placement in a internal or private class (or public class in internal class etc.)).

Copy link
Member

Choose a reason for hiding this comment

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

@engyebrahim Would you mind doing a follow-up PR where you add a comment on top of the check with what Jakub wrotes for the various analyzers doing the same trick? It will be helpful for other devs.

Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

Perfect!

Comment on lines +104 to +105
|| (!canDiscoverInternals && methodSymbol.GetResultantVisibility() != SymbolVisibility.Public)
|| (canDiscoverInternals && methodSymbol.GetResultantVisibility() == SymbolVisibility.Private))
Copy link
Member

Choose a reason for hiding this comment

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

@nohwnd DeclaredAccesibility is what is declared on the method and is the first check Engy's doing here. The other checks are using GetResultantVisibility that walks up tree (class + outer classes) to get the final accessibility. We had offline chat with Engy and the code she wrotes LGTM.

Comment on lines +104 to +105
|| (!canDiscoverInternals && methodSymbol.GetResultantVisibility() != SymbolVisibility.Public)
|| (canDiscoverInternals && methodSymbol.GetResultantVisibility() == SymbolVisibility.Private))
Copy link
Member

Choose a reason for hiding this comment

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

@Evangelink this resource, and other resources don't reflect the changes made for Task and ValueTask https://github.com/microsoft/testfx/blob/main/src/Adapter/MSTest.TestAdapter/Resources/Resource.resx#L212

Thanks! I see some other resources are missing edit. I'll do a follow-up

@Evangelink Evangelink merged commit 5de0a0a into main Feb 16, 2024
7 checks passed
@Evangelink Evangelink deleted the Enji/assembly-cleanup branch February 16, 2024 15:54
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: AssemblyCleanup should be valid
3 participants