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

Exclude entry points from unused members analysis #45090

Merged
merged 1 commit into from
Jun 12, 2020

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Jun 11, 2020

Fixes #45496

@@ -689,7 +696,7 @@ private bool IsCandidateSymbol(ISymbol memberSymbol)
}

private bool IsEntryPoint(IMethodSymbol methodSymbol)
=> methodSymbol.Name == WellKnownMemberNames.EntryPointMethodName &&
=> (methodSymbol.Name == WellKnownMemberNames.EntryPointMethodName || methodSymbol.Name == "$Main") &&
Copy link
Member 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)

@@ -689,7 +696,7 @@ private bool IsCandidateSymbol(ISymbol memberSymbol)
}

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
Member 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