Skip to content

C# and Razor compiler playground in the browser via Blazor WebAssembly

Notifications You must be signed in to change notification settings

jjonescz/DotNetInternals

Repository files navigation

DotNetInternals

C# and Razor compiler playground in the browser via Blazor WebAssembly.

C# Razor
C# screenshot Razor screenshot

Features

  • Razor/CSHTML to generated C# code / IR / Syntax Tree / Errors.
  • C# to IL / Syntax / decompiled-C# / Errors / Execution console output.
  • Any Roslyn/Razor compiler version (NuGet official builds or CI builds given PR number / branch / build number).
  • Offline support (PWA).
  • VSCode Monaco Editor.
  • Multiple input sources (especially useful for interlinked Razor components).
  • C# Language Services (completions, live diagnostics) - experimental.
  • Configuring any C# parse options (e.g., LangVersion, Features).

Development

The recommended startup app for development is src/Server.

To hit breakpoints, it is recommended to turn off the worker (in app settings).

  • src/App: the WebAssembly app.
    • cd src/App; dotnet watch - src/Server is better for development though.
  • src/Compiler: self-contained project referencing Roslyn/Razor. It's reloaded at runtime with a user-chosen version of Roslyn/Razor. It should be small (for best reloading perf). It can reference shared code which does not depend on Roslyn/Razor from elsewhere (e.g., Shared.csproj).
  • src/RazorAccess: internal access to Razor DLLs (via fake assembly name).
  • src/RoslynAccess: internal access to Roslyn DLLs (via fake assembly name).
  • src/Server: a Blazor Server entrypoint for easier development of the App (it has better tooling support for hot reload and debugging).
    • cd src/Server; dotnet watch
  • src/Shared: code used by Compiler that does not depend on Roslyn/Razor.
  • src/Worker: an app loaded in a web worker (a separate process in the browser), so it does all the CPU-intensive work to avoid lagging the user interface.
  • test/UnitTests
    • dotnet test

Attribution

Related work

Razor REPLs:

C# REPLs:

C# compiler playgrounds:

XAML REPLs:

About

C# and Razor compiler playground in the browser via Blazor WebAssembly

Resources

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •