Skip to content

Add "convert to project" menu option#9472

Closed
Copilot wants to merge 28 commits into
mainfrom
copilot/review-issue-2369
Closed

Add "convert to project" menu option#9472
Copilot wants to merge 28 commits into
mainfrom
copilot/review-issue-2369

Conversation

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Authored by @mwiemer-microsoft, closes microsoft/vscode-dotnettools#2369

Adds "convert to project" to FBA entry points based on a simple heuristic. Shells out directly to terminal (dotnet project convert <file>) to handle interactivity (which may change in future SDK versions). The command is available in the editor, explorer, and command palette.

C# files are identified as ones ending in .cs or open files with the VS Code language association of C#.

All C# files are considered possible FBAs by default. We ignore files that have a csproj "in cone." We then un-ignore files with FBA-specific code, like #! shebang or #: FBA-specific directives.

When running from command palette, we find likely FBAs using the above heuristic on all *.cs files in the workspace and all open C# files.

Implements microsoft/vscode-dotnettools#2369.

Adds a new `dotnet.convertToProject` command that lets users convert
a file-based C# app to a project-based app by running
`dotnet project convert <file>` in an integrated terminal.

Two entry points are provided:
- Right-click on a .cs file in the Explorer or editor → "Convert C# File-based App to Project"
- Command palette → "Convert C# File-based App to Project" → quick pick of all
  discoverable file-based app entry points in the workspace (files starting with
  `#!` or containing `#:` directives)

Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Copilot AI changed the title Add "Convert C# File-based App to Project" command (fixes vscode-dotnettools#2369) Add "Convert C# File-based App to Project" command Jun 25, 2026
Copilot AI requested a review from mwiemer-microsoft June 25, 2026 18:55
…ne, language-ID check

- Export `FileBasedAppKind` enum and `detectFileBasedAppKind` with injectable
  reader so unit tests don't need fs mocks
- Export `isInProjectCone` helper (walk ancestor dirs to find .csproj)
- pickAndConvertToProject: include C# files outside any .csproj cone as FBA
  entry points even when they lack explicit #! / #: markers
- pickAndConvertToProject: augment the findFiles result with any open text
  documents that VS Code already treats as csharp language but lack .cs ext
- convertToProject (right-click path): check document.languageId === 'csharp'
  via openTextDocument instead of filePath.endsWith('.cs')
- Add TODO noting that the .NET 10 SDK has no CLI command for FBA detection
  (only dotnet project convert); flag the Roslyn LSP request as the future fix
- Add 20 unit tests covering shebang, directives, BOM, None edge cases, and
  all isInProjectCone permutations

Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Copilot AI changed the title Add "Convert C# File-based App to Project" command fileBasedApps: unit tests, no-csproj cone detection, language-ID check Jun 26, 2026
Copilot AI and others added 2 commits June 30, 2026 19:01
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
@mwiemer-microsoft mwiemer-microsoft changed the title fileBasedApps: unit tests, no-csproj cone detection, language-ID check Add "convert to project" menu option Jun 30, 2026
@mwiemer-microsoft

This comment was marked as duplicate.

Comment thread src/lsptoolshost/fileBasedApps/convertToProject.ts Outdated
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Comment thread src/lsptoolshost/fileBasedApps/convertToProject.ts Outdated
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Comment thread src/lsptoolshost/fileBasedApps/convertToProject.ts
…ocalization bundle

Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Comment thread test/lsptoolshost/unitTests/convertToProjectPick.test.ts Outdated
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
Co-authored-by: mwiemer-microsoft <80539004+mwiemer-microsoft@users.noreply.github.com>
@mwiemer-microsoft

Copy link
Copy Markdown
Member

New plan is to take some time to update the existing Roslyn Language Server heuristic instead of adding a new client-side one. Closing in favor of dotnet/roslyn#84367 and subsequent PRs. Refer to backing issue for full list of refs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "Convert to project" as right-click menu item and command palette item

2 participants