[Enhancement] C# playground: Roslyn / dotnet formatter for Monaco #38

Open
opened 2026-04-28 23:48:47 +00:00 by spikerj · 0 comments
Owner

Summary

Provide C# formatting aligned with dotnet format / Roslyn conventions for the Monaco C# playground model.

Approach candidates

A. Roslyn formatter on existing backend compilation path — reuse same service that emits diagnostics (single round-trip).
B. WASM-only path if Mono/.NET toolchain exposes Microsoft.CodeAnalysis.Formatting compatible API in WASM debug story — only if bundled cost acceptable.
C. Degrade gracefully: formatter unavailable offline → tooltip explains.

Integration

  • Register provider for csharp (or our Monaco language id for .cs).
  • Preserve PDB line mapping / project layout context if formatting affects multi-file advanced sandbox (only format active file vs whole solution — specify behavior).

Dependency

Platform Format toolbar + Monaco #24 + #33 WASM/Roslyn context may intersect — coordinate breakpoints vs format ordering.

## Summary Provide **C#** formatting aligned with **`dotnet format`** / **Roslyn** conventions for the Monaco C# playground model. ## Approach candidates **A.** **Roslyn** formatter on **existing backend** compilation path — reuse same service that emits diagnostics (single round-trip). **B.** WASM-only path if Mono/.NET toolchain exposes **`Microsoft.CodeAnalysis.Formatting`** compatible API in WASM debug story — only if bundled cost acceptable. **C.** Degrade gracefully: formatter unavailable offline → tooltip explains. ## Integration - Register provider for **`csharp`** (or our Monaco language id for `.cs`). - Preserve **PDB line mapping** / project layout context if formatting affects multi-file advanced sandbox (only format active file vs whole solution — specify behavior). ## Dependency Platform Format toolbar + Monaco `#24` + `#33` WASM/Roslyn context may intersect — coordinate breakpoints vs format ordering.
Sign in to join this conversation.