Home

Awesome

BlazorInteropGenerator

Generates Blazor -> Javascript strongly typed interop methods, by parsing the Javascript it self and generating extension methods for IJSRuntime.

Usage

Firstly, add the project from Nuget - GoLive.Generator.BlazorInterop, then add an AdditionalFile in your .csproj named "BlazorInterop.json", like so:

<ItemGroup>
     <AdditionalFiles Include="BlazorInterop.json" />
</ItemGroup>

Once that's done, add the settings file and change as required:

{
  "Files": [
    {
      "Output": "JSInterop.cs",
      "Source": "wwwroot\\blazorinterop.js",
      "Namespace": "GoLive.Generator.BlazorInterop.Playground.Client",
      "ObjectToInterop": "window.blazorInterop",
      "Init": ["window={}"]
    }
  ],
  "InvokeVoidString": "await JSRuntime.InvokeVoidAsync(\"{0}\", {1});",
  "InvokeString": "return await JSRuntime.InvokeAsync<T>(\"{0}\",{1});"
}

Description of Each Option