Skip to content

Extract file-based app entry point heuristic#84385

Draft
mwiemer-microsoft wants to merge 2 commits into
mainfrom
mwiemer-microsoft-extract-fba-entrypoint-heuristic
Draft

Extract file-based app entry point heuristic#84385
mwiemer-microsoft wants to merge 2 commits into
mainfrom
mwiemer-microsoft-extract-fba-entrypoint-heuristic

Conversation

@mwiemer-microsoft

@mwiemer-microsoft mwiemer-microsoft commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Extract the file-based program entry-point classification into a shared internal heuristic
  • Preserve existing open-file classification behavior, including avoiding ambiguous top-level-statement parsing when ambiguous entry points are disabled

Validation

  • dotnet build src\LanguageServer\Microsoft.CodeAnalysis.LanguageServer\Microsoft.CodeAnalysis.LanguageServer.csproj --no-restore
  • dotnet test src\LanguageServer\Microsoft.CodeAnalysis.LanguageServer.UnitTests\Microsoft.CodeAnalysis.LanguageServer.UnitTests.csproj --filter "FullyQualifiedName~FileBasedProgramsEntryPointDiscoveryTests" --no-restore
Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mwiemer-microsoft mwiemer-microsoft requested a review from a team as a code owner July 2, 2026 22:29
Copilot AI review requested due to automatic review settings July 2, 2026 22:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the file-based program “entry point” classification logic in the Language Server by extracting it into a shared internal heuristic, and adds focused unit tests to validate explicit, ambiguous, and non-entry-point outcomes.

Changes:

  • Introduces FileBasedProgramEntryPointKind and FileBasedProgramEntryPointHeuristic.GetEntryPointKind(...) to centralize entry-point classification.
  • Updates FileBasedProgramsProjectSystem.ClassifyDocumentAsync to use the extracted heuristic while preserving the existing option-gated “ambiguous entry point” behavior.
  • Adds a new theory to unit test the heuristic across representative inputs (shebang, #: directives, top-level statements, and non-entry-point cases).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/FileBasedPrograms/FileBasedProgramsProjectSystem.cs Extracts entry-point classification into an internal heuristic and rewires document classification to use it.
src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/MiscellaneousFiles/FileBasedProgramsEntryPointDiscoveryTests.cs Adds direct unit coverage for the new heuristic’s explicit/ambiguous/none outcomes.

@mwiemer-microsoft mwiemer-microsoft marked this pull request as draft July 2, 2026 22:33
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants