Skip to content

Commit e805d00

Browse files
Expose as a new entrypoint a Compilation-accepting version
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.
1 parent 2d2ae72 commit e805d00

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpEntryPointFinder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public static IEnumerable<INamedTypeSymbol> FindEntryPoints(Compilation compilat
1818
{
1919
// This differs from the VB implementation
2020
// (Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim.EntryPointFinder) because we don't
21-
// ever consider forms entry points. Technically, this is wrong but it just doesn't matter since the ref
22-
// assemblies are unlikely to have a random Main() method that matches
21+
// ever consider forms entry points.
2322
var visitor = new CSharpEntryPointFinder(compilation);
2423
visitor.Visit(compilation.SourceModule.GlobalNamespace);
2524
return visitor.EntryPoints;

src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpEntryPointFinderService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.ProjectSystemShim;
1616
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
1717
internal sealed class CSharpEntryPointFinderService() : AbstractEntryPointFinderService
1818
{
19-
protected override IEnumerable<INamedTypeSymbol> FindEntryPoints(Compilation compilation, bool findFormsOnly)
19+
public override IEnumerable<INamedTypeSymbol> FindEntryPoints(Compilation compilation, bool findFormsOnly)
2020
=> CSharpEntryPointFinder.FindEntryPoints(compilation);
2121
}

src/VisualStudio/Core/Def/ProjectSystem/AbstractEntryPointFinderService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
99

1010
internal abstract class AbstractEntryPointFinderService : IEntryPointFinderService
1111
{
12-
protected abstract IEnumerable<INamedTypeSymbol> FindEntryPoints(Compilation compilation, bool findFormsOnly);
12+
public abstract IEnumerable<INamedTypeSymbol> FindEntryPoints(Compilation compilation, bool findFormsOnly);
1313

1414
public IEnumerable<INamedTypeSymbol> FindEntryPoints(INamespaceSymbol symbol, bool findFormsOnly)
1515
=> symbol is { ContainingCompilation: Compilation compilation }

src/VisualStudio/Core/Def/ProjectSystem/IEntryPointFinderService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@ internal interface IEntryPointFinderService : ILanguageService
1919
/// <param name="symbol">The namespace to search.</param>
2020
/// <param name="findFormsOnly">Restrict the search to only Windows Forms classes. Note that this is only implemented for VisualBasic</param>
2121
IEnumerable<INamedTypeSymbol> FindEntryPoints(INamespaceSymbol symbol, bool findFormsOnly);
22+
23+
/// <summary>
24+
/// Finds the types that contain entry points like the Main method in a given compilation.
25+
/// </summary>
26+
/// <param name="compilation">The compilation to search.</param>
27+
/// <param name="findFormsOnly">Restrict the search to only Windows Forms classes. Note that this is only implemented for VisualBasic</param>
28+
IEnumerable<INamedTypeSymbol> FindEntryPoints(Compilation compilation, bool findFormsOnly);
2229
}

src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicEntryPointFinderService.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim
1717
Public Sub New()
1818
End Sub
1919

20-
Protected Overrides Function FindEntryPoints(compilation As Compilation, findFormsOnly As Boolean) As IEnumerable(Of INamedTypeSymbol)
20+
Public Overrides Function FindEntryPoints(compilation As Compilation, findFormsOnly As Boolean) As IEnumerable(Of INamedTypeSymbol)
2121
Return VisualBasicEntryPointFinder.FindEntryPoints(compilation, findFormsOnly)
2222
End Function
2323
End Class

0 commit comments

Comments
 (0)