Skip to content

Feat/csharp playground#10189

Draft
JoshLove-msft wants to merge 16 commits intomicrosoft:mainfrom
JoshLove-msft:feat/csharp-playground
Draft

Feat/csharp playground#10189
JoshLove-msft wants to merge 16 commits intomicrosoft:mainfrom
JoshLove-msft:feat/csharp-playground

Conversation

@JoshLove-msft
Copy link
Copy Markdown
Contributor

No description provided.

JoshLove-msft and others added 2 commits March 27, 2026 16:51
…ble emitter and .NET server

Make the C# emitter loadable in browser environments by converting static
Node.js imports (child_process, fs, path, url) to dynamic imports. Add a
'playground-server-url' emitter option that, when set, POSTs the code model
to a remote .NET server instead of spawning a local dotnet process.

Create an ASP.NET Core playground server that accepts code model JSON and
configuration, runs the .NET generator, and returns the generated C# files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add @typespec/http-client-csharp and @azure-tools/typespec-client-generator-core
to the playground-website config and dependencies. The C# emitter now appears
in the emitter dropdown and its output files are shown in the file explorer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@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 Mar 28, 2026
JoshLove-msft and others added 4 commits March 27, 2026 17:35
Set playground-server-url as a default emitter option for the C# emitter
in the playground. The URL defaults to localhost:5174 for local dev and
can be overridden via VITE_PLAYGROUND_SERVER_URL env var at build time.

Add dev:playground script to http-client-csharp package.json that runs
both the Vite playground and .NET server concurrently.

Fix generator DLL path resolution in playground server.

Verified end-to-end: server generates 18 C# files from a real TypeSpec
code model (authentication/api-key test fixture).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fix the .NET server to actually bind to port 5174 (was using ASP.NET
default port 5000). Add @azure-tools/typespec-azure-core as a dependency
since TCGC has a peer dependency on it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
In playground mode, serialize the code model and configuration in memory
and send directly to the server instead of writing to the virtual FS and
reading back. Extract serializeCodeModel() from writeCodeModel() to
enable this.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…s, and highlight changed files

- Add isCompiling state with Spinner overlay in output panel during compilation
- Preserve previous output files when compilation has transient errors (mid-typing)
- Fix race condition: discard stale compilation results, catch emitter crashes
- Highlight changed files in file tree with bold green text (opt-in per emitter)
- Add nodeLabel prop to Tree component for custom label rendering
- Browser detection fallback for playground-server-url
- Enable change highlighting for C# emitter only via emittersWithChangeHighlighting
- Add CSS for Monaco changed-line decorations (playground-changed-line)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
JoshLove-msft and others added 4 commits March 30, 2026 08:57
Add fixed-window rate limiting (10 requests/minute per IP) on the
/generate endpoint. Update Dockerfile to build from the http-client-csharp
root, including the generator build step and full .NET SDK in runtime
image (needed to spawn dotnet for the generator).

Deploy with:
  cd packages/http-client-csharp
  docker build -f playground-server/Dockerfile -t csharp-playground-server .

Set PLAYGROUND_URL env var on the server to restrict CORS to the
production playground origin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The -g argument to the generator DLL is now sent by the emitter in the
request body instead of being hardcoded to ScmCodeModelGenerator. This
allows the same server to support both unbranded (@typespec/http-client-csharp)
and Azure (@azure-typespec/http-client-csharp) emitters, which use
different generator classes discovered via MEF.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The lockfile was previously generated with pnpm 9.4.0 which doesn't
match the repo's packageManager (pnpm 10.30.2), causing frozen lockfile
failures in CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 30, 2026

Open in StackBlitz

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

commit: 8f9611b

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @typespec/playground
Show changes

Switch from link: to file: protocol for the http-client-csharp dependency.
Add a CI step to build the http-client-csharp emitter before the main
build so the playground bundler can resolve the package.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
JoshLove-msft and others added 3 commits March 30, 2026 17:16
file: copies the package at install time before the emitter is built.
link: creates a symlink so the build step after install is visible
through the symlink.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
link: protocol is not supported in pnpm catalogs. Add exceptions to
check-catalog.ts for the three external dependencies needed by the
playground (azure-core, TCGC, http-client-csharp).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Azure/typespec-azure integration check also builds the playground
which needs the http-client-csharp emitter pre-built. Add the build
step before the main pnpm build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
return <Editor actions={actions} options={resolvedOptions} {...other}></Editor>;
};

/**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is the whole highlighting relevant to this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not strictly necessary, but I think at least the file explorer level highlighting is important. Right now it is opt-in so it shouldn't impact other emitters.

"@typespec/xml": "workspace:^",
"@azure-tools/typespec-azure-core": ">=0.66.0 <0.67.0",
"@azure-tools/typespec-client-generator-core": ">=0.66.3 <0.67.0",
"@typespec/http-client-csharp": "link:../http-client-csharp",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we are going to have some circular and build issue with this, not sure how we can handle it

…ript

Remove http-client-csharp and azure deps from playground-website to
avoid CI failures (the emitter is not in the pnpm workspace and can't
be built by the standard pipeline).

Instead, add a standalone upload script (upload-csharp-emitter-package.js)
that bundles and uploads the C# emitter to the playground package storage
account, following the same pattern as the core packages. This decouples
the C# emitter from the playground build pipeline.

Revert CI workflow changes and catalog check exceptions that are no
longer needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Mar 31, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

In browser environments, the emitter now reads the server URL from
globalThis.__TYPESPEC_PLAYGROUND_SERVER_URL__ before falling back to
localhost:5174. Playground deployments can set this global in their
index.html without needing to modify emitter options or code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 eng ui:playground

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants