-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Fix locating startup objects #78972
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
Fix locating startup objects #78972
Conversation
This existed back from when the input to the function was a namespace, but that's not the case anymore.
CPS passes us an INamespaceSymbol that is the global namespace symbol; it doesn't have a containing assembly. It does have a containing Compilation though, which is what we actually need. Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2506795 Fixes dotnet#78697
I'm not sure why this ever took an INamespaceSymbol in the first place, but we either have code working around it, or having an (old) comment saying the code was wrong.
/// </summary> | ||
/// <param name="compilation">The compilation to search.</param> | ||
/// <param name="findFormsOnly">Restrict the search to only Windows Forms classes. Note that this is only implemented for VisualBasic</param> | ||
IEnumerable<INamedTypeSymbol> FindEntryPoints(Compilation compilation, bool findFormsOnly); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @drewnoakes here's an improved method for you to call here:
https://github.com/dotnet/project-system/blob/05aa25172c582d92041fdac9b15ee826e28ec1ef/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Properties/StartupObjectsEnumProvider.cs#L87
https://github.com/dotnet/project-system/blob/05aa25172c582d92041fdac9b15ee826e28ec1ef/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Properties/VisualBasic/SplashScreenEnumProvider.cs#L86
The .GlobalNamespace line isn't right, so we've been working around it all these years. A cleanup on our side to deal with this then broke stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Filed dotnet/project-system#9676
CPS passes us an INamespaceSymbol that is the global namespace symbol; it doesn't have a containing assembly. It does have a containing Compilation though, which is what we actually need. This is a 17.14 backport of the specific fix from #78972 but removes the other cleanup and the introduction of a new API that won't ever be consumed in 17.14. Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2506795 Fixes #78697
CPS passes us an INamespaceSymbol that is the global namespace symbol; it doesn't have a containing assembly. It does have a containing Compilation though, which is what we actually need.
While I'm here, let's expose a better API for this to avoid this silly dance in the first place.
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2506795
Fixes #78697