Skip to content

Exclude entry points from unused members analysis#45090

Merged
sharwell merged 1 commit intodotnet:masterfrom
sharwell:unused-main
Jun 12, 2020
Merged

Exclude entry points from unused members analysis#45090
sharwell merged 1 commit intodotnet:masterfrom
sharwell:unused-main

Conversation

@sharwell
Copy link
Contributor

@sharwell sharwell commented Jun 11, 2020

Fixes #45496


private bool IsEntryPoint(IMethodSymbol methodSymbol)
=> methodSymbol.Name == WellKnownMemberNames.EntryPointMethodName &&
=> (methodSymbol.Name == WellKnownMemberNames.EntryPointMethodName || methodSymbol.Name == "$Main") &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlekseyTs Ideally we would use a helper for "unspeakable names", but I couldn't find one. Can you point us in the right direction?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we would use a helper for "unspeakable names", but I couldn't find one. Can you point us in the right direction?

SyntaxFacts.IsValidIdentifier?

Copy link
Contributor

Choose a reason for hiding this comment

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

You also mentioned ISymbol.CanBeReferencedByName offline. However, it doesn't feel right to include all methods with unspeakable names into entry points.


In reply to: 439097752 [](ancestors = 439097752)


private bool IsEntryPoint(IMethodSymbol methodSymbol)
=> methodSymbol.Name == WellKnownMemberNames.EntryPointMethodName &&
=> (methodSymbol.Name == WellKnownMemberNames.EntryPointMethodName || methodSymbol.Name == "$Main") &&
Copy link
Contributor

Choose a reason for hiding this comment

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

"$Main" [](start = 107, length = 7)

Perhaps we should move constant from SynthesizedSimpleProgramEntryPointSymbol to WellKnownMemberNames and use it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps we should move constant from SynthesizedSimpleProgramEntryPointSymbol to WellKnownMemberNames and use it here?

I'll file a follow-up issue for this.

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 (iteration 1)

@AlekseyTs
Copy link
Contributor

CC @mavasani

@sharwell sharwell merged commit 6db6c5e into dotnet:master Jun 12, 2020
@sharwell sharwell deleted the unused-main branch June 12, 2020 15:54
@ghost ghost added this to the Next milestone Jun 12, 2020
@dibarbet dibarbet modified the milestones: Next, 16.7.P4 Jun 30, 2020
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.

Entire top-level program file is always faded with IDE0051 "Private member '$Program.$Main' is unused."

4 participants