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

Simplify AvoidUninstantiatedInternalClasses #6309

Merged
merged 4 commits into from
Jan 3, 2023

Conversation

Youssef1313
Copy link
Member

No description provided.

@Youssef1313 Youssef1313 requested a review from a team as a code owner December 9, 2022 07:16
// The type containing the assembly's entry point is OK.
if (ContainsEntryPoint(type, compilation))
Copy link
Member Author

@Youssef1313 Youssef1313 Dec 9, 2022

Choose a reason for hiding this comment

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

On roslyn side, this is calculated once for the compilation and cached:

https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs#L1676-L1684

@mavasani Do you think this PR can contribute to #6301 ? (the new approach is very likely more efficient, but I'm not sure if the improvement is large enough here)

I'm not sure how much the existing code was expensive. Specifically, we could have been calling GetMembers for lots of types. Did the compiler already cached them before invoking the analyzer? or does the analyzer come through this code path:

https://github.com/dotnet/roslyn/blob/1100e56a04e144352af43181df077a13957e6a58/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol.cs#L1656-L1665

We also were doing more symbol comparison than with this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Regardless of whether or not this addresses #6301, it seems to definitely be more hardened code and should likely also improve performance.

Comment on lines -378 to -381
// TODO: Handle the case where Compilation.Options.MainTypeName matches this type.
// TODO: Test: can't have type parameters.
// TODO: Main in nested class? If allowed, what name does it have?
// TODO: Test that parameter is array of int.
Copy link
Member Author

Choose a reason for hiding this comment

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

All these should be handled now by the compiler :)

@@ -375,7 +375,7 @@ public async Task CA1812_Basic_NoDiagnostic_MainMethodIsDifferentlyCasedAsync()
OutputKind = OutputKind.ConsoleApplication,
Sources =
{
@"Friend Class C
@"Friend Class [|C|]
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 false negative.

@codecov
Copy link

codecov bot commented Dec 9, 2022

Codecov Report

Merging #6309 (e22457d) into main (1eb2caf) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6309   +/-   ##
=======================================
  Coverage   96.08%   96.08%           
=======================================
  Files        1367     1367           
  Lines      315352   315307   -45     
  Branches    10187    10177   -10     
=======================================
- Hits       302991   302963   -28     
+ Misses       9930     9918   -12     
+ Partials     2431     2426    -5     

@mavasani mavasani merged commit fad2bc6 into dotnet:main Jan 3, 2023
@github-actions github-actions bot added this to the vNext milestone Jan 3, 2023
@Youssef1313 Youssef1313 deleted the patch-20 branch January 3, 2023 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants