Skip to content

Fix generator crash composing plugin under long paths with scoped package names#11218

Merged
jorgerangel-msft merged 4 commits into
mainfrom
copilot/fix-generator-crashing-long-path
Jul 9, 2026
Merged

Fix generator crash composing plugin under long paths with scoped package names#11218
jorgerangel-msft merged 4 commits into
mainfrom
copilot/fix-generator-crashing-long-path

Conversation

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The C# generator crashed when composing a plugin whose node_modules package directory resolved to a long path. Scoped package names like @azure-typespec/http-client-csharp-mgmt retained their forward slash on Windows, producing a mixed-separator path (...\node_modules\@azure-typespec/http-client-csharp-mgmt). Once long enough to trigger the runtime's \\?\ extended-length prefix — which requires canonical backslash separators — Directory.EnumerateFiles failed with "The filename, directory name, or volume label syntax is incorrect."

Changes

  • GeneratorHandler.AddPluginDlls: replaced Path.Combine(rootDirectory, NodeModulesDir, package) with a new GetPackageDirectory helper that splits scoped package names on / into separate path segments, normalizing separators to the platform separator.
  • Tests: added coverage for scoped and unscoped package directory resolution.
internal static string GetPackageDirectory(string rootDirectory, string package)
{
    var segments = new List<string> { rootDirectory, NodeModulesDir };
    segments.AddRange(package.Split('/'));
    return Path.Combine(segments.ToArray());
}

…kage names

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix generator crashing issue when composing plugin under long path Fix generator crash composing plugin under long paths with scoped package names Jul 8, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jul 8, 2026
Copilot AI requested a review from jorgerangel-msft July 8, 2026 22:20
@pkg-pr-new

pkg-pr-new Bot commented Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@11218

commit: 1afd3f2

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@jorgerangel-msft jorgerangel-msft added this pull request to the merge queue Jul 9, 2026
Merged via the queue into main with commit 7c75ac6 Jul 9, 2026
29 checks passed
@jorgerangel-msft jorgerangel-msft deleted the copilot/fix-generator-crashing-long-path branch July 9, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator Is Crashing When Composing Plugin Under Long Path

3 participants