Bootsharp makes malformed bindings.g.js file in some cases when the first namespace name is a part of the second namespace name and parseAst.js fails with a message like Expected ',' got 'export'.
I manged to reproduce this issue with the following toy example:
using BootSharpBackendCore.Input;
namespace BootSharpBackendCore.Output;
public record Bar(Foo Foo);
namespace BootSharpBackendCore;
public static class Facade
{
public static IReadOnlyList<Bar> Test(Foo foo) => new[] { new Bar(foo) };
}
and a project with JSInvokable:
using Bootsharp;
using BootSharpBackendCore;
using BootSharpBackendCore.Input;
using BootSharpBackendCore.Output;
namespace BootSharpBackend;
public static partial class Program
{
public static void Main()
{
}
[JSInvokable]
public static IReadOnlyList<Bar> Test(Foo foo) => Facade.Test(foo);
}
dotnet publish command will fail, but some of artifacts will remain, so, the bin\Release\net8.0\browser-wasm\AppBundle\_framework\bindings.g.js file will have something like that:
import { exports } from "./exports";
import { Event } from "./event";
function getExports () { if (exports == null) throw Error("Boot the runtime before invoking C# APIs."); return exports; }
function serialize(obj) { return JSON.stringify(obj); }
function deserialize(json) { const result = JSON.parse(json); if (result === null) return undefined; return result; }
export const BootSharpBackend = {
test: (foo) => deserialize(getExports().BootSharpBackend_Program.Test(serialize(foo)))
export const BootSharpBackendCore = {
Input: {
Foo: { "0": "Value1", "1": "Value2", "Value1": 0, "Value2": 1 }
}
};
Hi @elringus ,
Bootsharp makes malformed
bindings.g.js
file in some cases when the first namespace name is a part of the second namespace name andparseAst.js
fails with a message likeExpected ',' got 'export'
.I manged to reproduce this issue with the following toy example:
and a project with
JSInvokable
:dotnet publish
command will fail, but some of artifacts will remain, so, thebin\Release\net8.0\browser-wasm\AppBundle\_framework\bindings.g.js
file will have something like that:Thank you!