8000 GitHub - jjonescz/DotNetLab: C# and Razor compiler playground in the browser via Blazor WebAssembly
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

License

Notifications You must be signed in to change notification settings

jjonescz/DotNetLab

Repository files navigation

.NET Lab

(aka Razor Lab, formerly also DotNetInternals)

C# and Razor compiler playground in the browser via Blazor WebAssembly. https://lab.razor.fyi/

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).
  • Configuring any C# options (e.g., LangVersion, Features, OptimizationLevel, AllowUnsafe).

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 Compiler DLLs (via fake assembly name).
  • src/RoslynWorkspaceAccess: internal access to Roslyn Workspace 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.
  • src/WorkerApi: shared code between Worker and App. This is in preparation for making the worker independent of the app, so the app can be optimized (trimming, NativeAOT) and the worker can be loaded more lazily.
  • test/UnitTests
    • dotnet test

Attribution

Related work

Razor REPLs:

C# REPLs:

C# compiler playgrounds:

XAML REPLs:

Web IDEs:

About

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

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 4

  •  
  •  
  •  
  •  
0