From 0607cb6bca2b9e36a19a4aa1ff43f355a148ee1f Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sat, 6 Jan 2024 16:26:48 +0300
Subject: [PATCH 01/75] bump
---
src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs | 3 +++
src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs | 3 +++
src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs | 6 ++++++
src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs | 6 ++++++
src/cs/Directory.Build.props | 2 +-
5 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs
create mode 100644 src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs
create mode 100644 src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs
create mode 100644 src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs
new file mode 100644
index 00000000..b0d5b187
--- /dev/null
+++ b/src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs
@@ -0,0 +1,3 @@
+namespace Bootsharp.Publish.Test;
+
+public class ExportClassTest : EmitTest { }
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs
new file mode 100644
index 00000000..425f19bf
--- /dev/null
+++ b/src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs
@@ -0,0 +1,3 @@
+namespace Bootsharp.Publish.Test;
+
+public class ImportClassTest : EmitTest { }
diff --git a/src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs
new file mode 100644
index 00000000..b1df3501
--- /dev/null
+++ b/src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs
@@ -0,0 +1,6 @@
+namespace Bootsharp.Publish;
+
+internal sealed class ExportClassGenerator
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs
new file mode 100644
index 00000000..c43f0971
--- /dev/null
+++ b/src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs
@@ -0,0 +1,6 @@
+namespace Bootsharp.Publish;
+
+internal sealed class ImportClassGenerator
+{
+
+}
diff --git a/src/cs/Directory.Build.props b/src/cs/Directory.Build.props
index 93cd2b4f..27f9164b 100644
--- a/src/cs/Directory.Build.props
+++ b/src/cs/Directory.Build.props
@@ -1,6 +1,6 @@
- 0.1.3
+ 0.2.0-alpha.0
Elringus
javascript typescript ts js wasm node deno bun interop codegen
https://bootsharp.com
From d80b0e6c23fdddc3caaf6ebb5df1fcdcf6ac09f8 Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sat, 6 Jan 2024 16:36:05 +0300
Subject: [PATCH 02/75] etc
---
src/cs/Bootsharp.Publish/Pack/ModulePatcher/InternalPatcher.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/cs/Bootsharp.Publish/Pack/ModulePatcher/InternalPatcher.cs b/src/cs/Bootsharp.Publish/Pack/ModulePatcher/InternalPatcher.cs
index d95a1e38..d7f0586f 100644
--- a/src/cs/Bootsharp.Publish/Pack/ModulePatcher/InternalPatcher.cs
+++ b/src/cs/Bootsharp.Publish/Pack/ModulePatcher/InternalPatcher.cs
@@ -1,9 +1,7 @@
-using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace Bootsharp.Publish;
-[ExcludeFromCodeCoverage(Justification = "How to merge coverage from multiple OS?")]
internal sealed class InternalPatcher (string dotnet, string runtime, string native)
{
private const string url =
From df9a344de75dcb4ca6279624c6de55fe64fc7f08 Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sat, 6 Jan 2024 19:46:24 +0300
Subject: [PATCH 03/75] iteration
---
.../Bootsharp.Publish.Test/Emit/EmitTest.cs | 19 +++++++++--
.../Bootsharp.Publish.Test/Emit/EventTest.cs | 6 ++++
.../Emit/ExportClassTest.cs | 3 --
.../Bootsharp.Publish.Test/Emit/ExportTest.cs | 6 ++++
.../Emit/FunctionTest.cs | 6 ++++
.../Emit/ImportClassTest.cs | 3 --
.../Bootsharp.Publish.Test/Emit/ImportTest.cs | 3 ++
.../Emit/InvokableTest.cs | 6 ++++
.../Bootsharp.Publish/Emit/BootsharpEmit.cs | 32 +++++++++++++++----
.../Bootsharp.Publish/Emit/EventGenerator.cs | 10 ++++++
.../Emit/ExportClassGenerator.cs | 6 ----
.../Bootsharp.Publish/Emit/ExportGenerator.cs | 10 ++++++
.../Emit/FunctionGenerator.cs | 10 ++++++
.../Emit/ImportClassGenerator.cs | 6 ----
.../Bootsharp.Publish/Emit/ImportGenerator.cs | 10 ++++++
.../Emit/InteropExportGenerator.cs | 4 +++
.../Emit/InteropImportGenerator.cs | 5 +++
.../Emit/InvokableGenerator.cs | 12 +++++++
.../Emit/SerializerGenerator.cs | 5 +++
src/cs/Bootsharp/Build/Bootsharp.targets | 24 ++++++++++++--
20 files changed, 158 insertions(+), 28 deletions(-)
create mode 100644 src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
delete mode 100644 src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs
create mode 100644 src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs
create mode 100644 src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs
delete mode 100644 src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs
create mode 100644 src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs
create mode 100644 src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs
create mode 100644 src/cs/Bootsharp.Publish/Emit/EventGenerator.cs
delete mode 100644 src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs
create mode 100644 src/cs/Bootsharp.Publish/Emit/ExportGenerator.cs
create mode 100644 src/cs/Bootsharp.Publish/Emit/FunctionGenerator.cs
delete mode 100644 src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs
create mode 100644 src/cs/Bootsharp.Publish/Emit/ImportGenerator.cs
create mode 100644 src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/EmitTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/EmitTest.cs
index 5b3003b4..6213b6d0 100644
--- a/src/cs/Bootsharp.Publish.Test/Emit/EmitTest.cs
+++ b/src/cs/Bootsharp.Publish.Test/Emit/EmitTest.cs
@@ -2,10 +2,20 @@
public class EmitTest : TaskTest
{
+ protected string GeneratedInvokables => ReadProjectFile(invokablesPath);
+ protected string GeneratedFunctions => ReadProjectFile(functionsPath);
+ protected string GeneratedEvents => ReadProjectFile(eventsPath);
+ protected string GeneratedExports => ReadProjectFile(exportsPath);
+ protected string GeneratedImports => ReadProjectFile(importsPath);
protected string GeneratedInteropExports => ReadProjectFile(interopExportsPath);
protected string GeneratedInteropImports => ReadProjectFile(interopImportsPath);
protected string GeneratedSerializer => ReadProjectFile(serializerPath);
+ private string invokablesPath => $"{Project.Root}/Invokables.g.cs";
+ private string functionsPath => $"{Project.Root}/Functions.g.cs";
+ private string eventsPath => $"{Project.Root}/Events.g.cs";
+ private string exportsPath => $"{Project.Root}/Exports.g.cs";
+ private string importsPath => $"{Project.Root}/Imports.g.cs";
private string interopExportsPath => $"{Project.Root}/InteropExports.g.cs";
private string interopImportsPath => $"{Project.Root}/InteropImports.g.cs";
private string serializerPath => $"{Project.Root}/SerializerContext.g.cs";
@@ -15,8 +25,13 @@ public class EmitTest : TaskTest
private BootsharpEmit CreateTask () => new() {
InspectedDirectory = Project.Root,
EntryAssemblyName = LastAddedAssemblyName ?? "System.Runtime.dll",
- ExportsFilePath = interopExportsPath,
- ImportsFilePath = interopImportsPath,
+ InvokablesFilePath = invokablesPath,
+ FunctionsFilePath = functionsPath,
+ EventsFilePath = eventsPath,
+ ExportsFilePath = exportsPath,
+ ImportsFilePath = importsPath,
+ InteropExportsFilePath = interopExportsPath,
+ InteropImportsFilePath = interopImportsPath,
SerializerFilePath = serializerPath,
BuildEngine = Engine
};
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
new file mode 100644
index 00000000..d2a29351
--- /dev/null
+++ b/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
@@ -0,0 +1,6 @@
+namespace Bootsharp.Publish.Test;
+
+public class EventTest
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs
deleted file mode 100644
index b0d5b187..00000000
--- a/src/cs/Bootsharp.Publish.Test/Emit/ExportClassTest.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-namespace Bootsharp.Publish.Test;
-
-public class ExportClassTest : EmitTest { }
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs
new file mode 100644
index 00000000..98dfda80
--- /dev/null
+++ b/src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs
@@ -0,0 +1,6 @@
+namespace Bootsharp.Publish.Test;
+
+public class ExportTest : EmitTest
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs
new file mode 100644
index 00000000..f3deb709
--- /dev/null
+++ b/src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs
@@ -0,0 +1,6 @@
+namespace Bootsharp.Publish.Test;
+
+public class FunctionTest
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs
deleted file mode 100644
index 425f19bf..00000000
--- a/src/cs/Bootsharp.Publish.Test/Emit/ImportClassTest.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-namespace Bootsharp.Publish.Test;
-
-public class ImportClassTest : EmitTest { }
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs
new file mode 100644
index 00000000..20f8c63d
--- /dev/null
+++ b/src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs
@@ -0,0 +1,3 @@
+namespace Bootsharp.Publish.Test;
+
+public class ImportTest : EmitTest { }
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs
new file mode 100644
index 00000000..5e64443b
--- /dev/null
+++ b/src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs
@@ -0,0 +1,6 @@
+namespace Bootsharp.Publish.Test;
+
+public class InvokableTest
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish/Emit/BootsharpEmit.cs b/src/cs/Bootsharp.Publish/Emit/BootsharpEmit.cs
index 1c953d3c..167e7bea 100644
--- a/src/cs/Bootsharp.Publish/Emit/BootsharpEmit.cs
+++ b/src/cs/Bootsharp.Publish/Emit/BootsharpEmit.cs
@@ -9,16 +9,26 @@ public sealed class BootsharpEmit : Microsoft.Build.Utilities.Task
{
[Required] public required string InspectedDirectory { get; set; }
[Required] public required string EntryAssemblyName { get; set; }
+ [Required] public required string InvokablesFilePath { get; set; }
+ [Required] public required string FunctionsFilePath { get; set; }
+ [Required] public required string EventsFilePath { get; set; }
[Required] public required string ExportsFilePath { get; set; }
[Required] public required string ImportsFilePath { get; set; }
+ [Required] public required string InteropExportsFilePath { get; set; }
+ [Required] public required string InteropImportsFilePath { get; set; }
[Required] public required string SerializerFilePath { get; set; }
public override bool Execute ()
{
var spaceBuilder = CreateNamespaceBuilder();
using var inspection = InspectAssemblies(spaceBuilder);
+ GenerateInvokables(inspection);
+ GenerateFunctions(inspection);
+ GenerateEvents(inspection);
GenerateExports(inspection);
GenerateImports(inspection);
+ GenerateInteropExports(inspection);
+ GenerateInteropImports(inspection);
GenerateSerializer(inspection);
return true;
}
@@ -38,20 +48,30 @@ private AssemblyInspection InspectAssemblies (NamespaceBuilder spaceBuilder)
return inspection;
}
- private void GenerateExports (AssemblyInspection inspection)
+ private void GenerateInvokables (AssemblyInspection inspection) { }
+
+ private void GenerateFunctions (AssemblyInspection inspection) { }
+
+ private void GenerateEvents (AssemblyInspection inspection) { }
+
+ private void GenerateExports (AssemblyInspection inspection) { }
+
+ private void GenerateImports (AssemblyInspection inspection) { }
+
+ private void GenerateInteropExports (AssemblyInspection inspection)
{
var generator = new InteropExportGenerator();
var content = generator.Generate(inspection);
- Directory.CreateDirectory(Path.GetDirectoryName(ExportsFilePath)!);
- File.WriteAllText(ExportsFilePath, content);
+ Directory.CreateDirectory(Path.GetDirectoryName(InteropExportsFilePath)!);
+ File.WriteAllText(InteropExportsFilePath, content);
}
- private void GenerateImports (AssemblyInspection inspection)
+ private void GenerateInteropImports (AssemblyInspection inspection)
{
var generator = new InteropImportGenerator(EntryAssemblyName);
var content = generator.Generate(inspection);
- Directory.CreateDirectory(Path.GetDirectoryName(ImportsFilePath)!);
- File.WriteAllText(ImportsFilePath, content);
+ Directory.CreateDirectory(Path.GetDirectoryName(InteropImportsFilePath)!);
+ File.WriteAllText(InteropImportsFilePath, content);
}
private void GenerateSerializer (AssemblyInspection inspection)
diff --git a/src/cs/Bootsharp.Publish/Emit/EventGenerator.cs b/src/cs/Bootsharp.Publish/Emit/EventGenerator.cs
new file mode 100644
index 00000000..5dc384e1
--- /dev/null
+++ b/src/cs/Bootsharp.Publish/Emit/EventGenerator.cs
@@ -0,0 +1,10 @@
+namespace Bootsharp.Publish;
+
+///
+/// Generates interceptors for methods
+/// in the solution (except methods generated by ).
+///
+public class EventGenerator
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs
deleted file mode 100644
index b1df3501..00000000
--- a/src/cs/Bootsharp.Publish/Emit/ExportClassGenerator.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Bootsharp.Publish;
-
-internal sealed class ExportClassGenerator
-{
-
-}
diff --git a/src/cs/Bootsharp.Publish/Emit/ExportGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ExportGenerator.cs
new file mode 100644
index 00000000..cc5a83f1
--- /dev/null
+++ b/src/cs/Bootsharp.Publish/Emit/ExportGenerator.cs
@@ -0,0 +1,10 @@
+namespace Bootsharp.Publish;
+
+///
+/// Generates implementation classes for interfaces specified
+/// under Bootsharp's .
+///
+internal sealed class ExportGenerator
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish/Emit/FunctionGenerator.cs b/src/cs/Bootsharp.Publish/Emit/FunctionGenerator.cs
new file mode 100644
index 00000000..0914dd3b
--- /dev/null
+++ b/src/cs/Bootsharp.Publish/Emit/FunctionGenerator.cs
@@ -0,0 +1,10 @@
+namespace Bootsharp.Publish;
+
+///
+/// Generates interceptors for methods
+/// in the solution (except methods generated by ).
+///
+public class FunctionGenerator
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs
deleted file mode 100644
index c43f0971..00000000
--- a/src/cs/Bootsharp.Publish/Emit/ImportClassGenerator.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Bootsharp.Publish;
-
-internal sealed class ImportClassGenerator
-{
-
-}
diff --git a/src/cs/Bootsharp.Publish/Emit/ImportGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ImportGenerator.cs
new file mode 100644
index 00000000..50714ba2
--- /dev/null
+++ b/src/cs/Bootsharp.Publish/Emit/ImportGenerator.cs
@@ -0,0 +1,10 @@
+namespace Bootsharp.Publish;
+
+///
+/// Generates implementation classes for interfaces specified
+/// under Bootsharp's .
+///
+internal sealed class ImportGenerator
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish/Emit/InteropExportGenerator.cs b/src/cs/Bootsharp.Publish/Emit/InteropExportGenerator.cs
index fdc98156..7bd2f5c8 100644
--- a/src/cs/Bootsharp.Publish/Emit/InteropExportGenerator.cs
+++ b/src/cs/Bootsharp.Publish/Emit/InteropExportGenerator.cs
@@ -1,5 +1,9 @@
namespace Bootsharp.Publish;
+///
+/// For all the methods in the solution,
+/// generates C# -> JS bindings to be picked by DotNet's source generators.
+///
internal sealed class InteropExportGenerator
{
public string Generate (AssemblyInspection inspection)
diff --git a/src/cs/Bootsharp.Publish/Emit/InteropImportGenerator.cs b/src/cs/Bootsharp.Publish/Emit/InteropImportGenerator.cs
index 9ffff22c..14dab858 100644
--- a/src/cs/Bootsharp.Publish/Emit/InteropImportGenerator.cs
+++ b/src/cs/Bootsharp.Publish/Emit/InteropImportGenerator.cs
@@ -1,5 +1,10 @@
namespace Bootsharp.Publish;
+///
+/// For all the and
+/// methods in the solution,
+/// generates JS -> C# bindings to be picked by DotNet's source generators.
+///
internal sealed class InteropImportGenerator (string entryAssembly)
{
public string Generate (AssemblyInspection inspection)
diff --git a/src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs b/src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs
new file mode 100644
index 00000000..b58ffbe7
--- /dev/null
+++ b/src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs
@@ -0,0 +1,12 @@
+namespace Bootsharp.Publish;
+
+///
+/// Generates hints for DotNet to not trim classes with
+/// methods (they're used by
+/// generated interop bindings, which is not obvious for DotNet), except
+/// methods generated by .
+///
+public class InvokableGenerator
+{
+
+}
diff --git a/src/cs/Bootsharp.Publish/Emit/SerializerGenerator.cs b/src/cs/Bootsharp.Publish/Emit/SerializerGenerator.cs
index 383dadab..489f7024 100644
--- a/src/cs/Bootsharp.Publish/Emit/SerializerGenerator.cs
+++ b/src/cs/Bootsharp.Publish/Emit/SerializerGenerator.cs
@@ -1,5 +1,10 @@
namespace Bootsharp.Publish;
+///
+/// Generates hints for all the types used in interop to be picked by
+/// DotNet's JSON serializer source generator. Required for the serializer to
+/// work without using reflection (which is required to support trimming).
+///
internal sealed class SerializerGenerator
{
private readonly HashSet attributes = [];
diff --git a/src/cs/Bootsharp/Build/Bootsharp.targets b/src/cs/Bootsharp/Build/Bootsharp.targets
index 5be9df60..110426df 100644
--- a/src/cs/Bootsharp/Build/Bootsharp.targets
+++ b/src/cs/Bootsharp/Build/Bootsharp.targets
@@ -5,8 +5,13 @@
$(BootsharpRoot)/js
$(BootsharpRoot)/tasks/Bootsharp.Publish.dll
$(IntermediateOutputPath)bootsharp
- $(BootsharpIntermediateDirectory)/InteropExports.g.cs
- $(BootsharpIntermediateDirectory)/InteropImports.g.cs
+ $(BootsharpIntermediateDirectory)/Invokables.g.cs
+ $(BootsharpIntermediateDirectory)/Functions.g.cs
+ $(BootsharpIntermediateDirectory)/Events.g.cs
+ $(BootsharpIntermediateDirectory)/Exports.g.cs
+ $(BootsharpIntermediateDirectory)/Imports.g.cs
+ $(BootsharpIntermediateDirectory)/InteropExports.g.cs
+ $(BootsharpIntermediateDirectory)/InteropImports.g.cs
$(BootsharpIntermediateDirectory)/SerializerContext.g.cs
$(AssemblyName).dll
@@ -61,15 +66,30 @@
+
+
+
+
+
+
+
+
+
+
From 1059829e266b87b849e0af08a95660f75e847640 Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sun, 7 Jan 2024 17:38:38 +0300
Subject: [PATCH 04/75] iteration
---
src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs | 4 ++--
src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs | 2 +-
src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs | 4 ++--
src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs | 5 ++++-
src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs | 4 ++--
5 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
index d2a29351..0fcd3ebe 100644
--- a/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
+++ b/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
@@ -1,6 +1,6 @@
namespace Bootsharp.Publish.Test;
-public class EventTest
+public class EventTest : EmitTest
{
-
+ protected override string TestedContent => GeneratedEvents;
}
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs
index 98dfda80..2fe72d31 100644
--- a/src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs
+++ b/src/cs/Bootsharp.Publish.Test/Emit/ExportTest.cs
@@ -2,5 +2,5 @@
public class ExportTest : EmitTest
{
-
+ protected override string TestedContent => GeneratedExports;
}
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs
index f3deb709..a3082b68 100644
--- a/src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs
+++ b/src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs
@@ -1,6 +1,6 @@
namespace Bootsharp.Publish.Test;
-public class FunctionTest
+public class FunctionTest : EmitTest
{
-
+ protected override string TestedContent => GeneratedFunctions;
}
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs
index 20f8c63d..79c42dfd 100644
--- a/src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs
+++ b/src/cs/Bootsharp.Publish.Test/Emit/ImportTest.cs
@@ -1,3 +1,6 @@
namespace Bootsharp.Publish.Test;
-public class ImportTest : EmitTest { }
+public class ImportTest : EmitTest
+{
+ protected override string TestedContent => GeneratedImports;
+}
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs
index 5e64443b..9dd4761d 100644
--- a/src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs
+++ b/src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs
@@ -1,6 +1,6 @@
namespace Bootsharp.Publish.Test;
-public class InvokableTest
+public class InvokableTest : EmitTest
{
-
+ protected override string TestedContent => GeneratedInvokables;
}
From 98e47cae224471e2fc7d876b043e5218d526ee92 Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sun, 7 Jan 2024 17:51:36 +0300
Subject: [PATCH 05/75] iteration
---
.../Bootsharp.Publish.Test/Emit/EventTest.cs | 15 ++++++
.../Bootsharp.Publish/Emit/BootsharpEmit.cs | 50 +++++++++++++++----
.../Bootsharp.Publish/Emit/EventGenerator.cs | 4 +-
.../Bootsharp.Publish/Emit/ExportGenerator.cs | 2 +-
.../Emit/FunctionGenerator.cs | 4 +-
.../Bootsharp.Publish/Emit/ImportGenerator.cs | 2 +-
.../Emit/InvokableGenerator.cs | 4 +-
7 files changed, 62 insertions(+), 19 deletions(-)
diff --git a/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs b/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
index 0fcd3ebe..ccd6c718 100644
--- a/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
+++ b/src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
@@ -3,4 +3,19 @@
public class EventTest : EmitTest
{
protected override string TestedContent => GeneratedEvents;
+
+ [Fact]
+ public void WhenNothingInspectedNothingIsGenerated ()
+ {
+ Execute();
+ Assert.Empty(TestedContent);
+ }
+
+ [Fact]
+ public void WhenNoEventsNothingIsGenerated ()
+ {
+ AddAssembly(WithClass("[JSFunction] public static void Foo () {}"));
+ Execute();
+ Assert.Empty(TestedContent);
+ }
}
diff --git a/src/cs/Bootsharp.Publish/Emit/BootsharpEmit.cs b/src/cs/Bootsharp.Publish/Emit/BootsharpEmit.cs
index 167e7bea..44b519b6 100644
--- a/src/cs/Bootsharp.Publish/Emit/BootsharpEmit.cs
+++ b/src/cs/Bootsharp.Publish/Emit/BootsharpEmit.cs
@@ -48,37 +48,65 @@ private AssemblyInspection InspectAssemblies (NamespaceBuilder spaceBuilder)
return inspection;
}
- private void GenerateInvokables (AssemblyInspection inspection) { }
+ private void GenerateInvokables (AssemblyInspection inspection)
+ {
+ var generator = new InvokableGenerator();
+ var content = generator.Generate(inspection);
+ WriteGenerated(InvokablesFilePath, content);
+ }
- private void GenerateFunctions (AssemblyInspection inspection) { }
+ private void GenerateFunctions (AssemblyInspection inspection)
+ {
+ var generator = new FunctionGenerator();
+ var content = generator.Generate(inspection);
+ WriteGenerated(FunctionsFilePath, content);
+ }
- private void GenerateEvents (AssemblyInspection inspection) { }
+ private void GenerateEvents (AssemblyInspection inspection)
+ {
+ var generator = new EventGenerator();
+ var content = generator.Generate(inspection);
+ WriteGenerated(EventsFilePath, content);
+ }
- private void GenerateExports (AssemblyInspection inspection) { }
+ private void GenerateExports (AssemblyInspection inspection)
+ {
+ var generator = new ExportGenerator();
+ var content = generator.Generate(inspection);
+ WriteGenerated(ExportsFilePath, content);
+ }
- private void GenerateImports (AssemblyInspection inspection) { }
+ private void GenerateImports (AssemblyInspection inspection)
+ {
+ var generator = new ImportGenerator();
+ var content = generator.Generate(inspection);
+ WriteGenerated(ImportsFilePath, content);
+ }
private void GenerateInteropExports (AssemblyInspection inspection)
{
var generator = new InteropExportGenerator();
var content = generator.Generate(inspection);
- Directory.CreateDirectory(Path.GetDirectoryName(InteropExportsFilePath)!);
- File.WriteAllText(InteropExportsFilePath, content);
+ WriteGenerated(InteropExportsFilePath, content);
}
private void GenerateInteropImports (AssemblyInspection inspection)
{
var generator = new InteropImportGenerator(EntryAssemblyName);
var content = generator.Generate(inspection);
- Directory.CreateDirectory(Path.GetDirectoryName(InteropImportsFilePath)!);
- File.WriteAllText(InteropImportsFilePath, content);
+ WriteGenerated(InteropImportsFilePath, content);
}
private void GenerateSerializer (AssemblyInspection inspection)
{
var generator = new SerializerGenerator();
var content = generator.Generate(inspection);
- Directory.CreateDirectory(Path.GetDirectoryName(SerializerFilePath)!);
- File.WriteAllText(SerializerFilePath, content);
+ WriteGenerated(SerializerFilePath, content);
+ }
+
+ private static void WriteGenerated (string path, string content)
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(path)!);
+ File.WriteAllText(path, content);
}
}
diff --git a/src/cs/Bootsharp.Publish/Emit/EventGenerator.cs b/src/cs/Bootsharp.Publish/Emit/EventGenerator.cs
index 5dc384e1..9f76229e 100644
--- a/src/cs/Bootsharp.Publish/Emit/EventGenerator.cs
+++ b/src/cs/Bootsharp.Publish/Emit/EventGenerator.cs
@@ -4,7 +4,7 @@
/// Generates interceptors for methods
/// in the solution (except methods generated by ).
///
-public class EventGenerator
+internal sealed class EventGenerator
{
-
+ public string Generate (AssemblyInspection inspection) => "";
}
diff --git a/src/cs/Bootsharp.Publish/Emit/ExportGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ExportGenerator.cs
index cc5a83f1..ba3627d6 100644
--- a/src/cs/Bootsharp.Publish/Emit/ExportGenerator.cs
+++ b/src/cs/Bootsharp.Publish/Emit/ExportGenerator.cs
@@ -6,5 +6,5 @@
///
internal sealed class ExportGenerator
{
-
+ public string Generate (AssemblyInspection inspection) => "";
}
diff --git a/src/cs/Bootsharp.Publish/Emit/FunctionGenerator.cs b/src/cs/Bootsharp.Publish/Emit/FunctionGenerator.cs
index 0914dd3b..5234f759 100644
--- a/src/cs/Bootsharp.Publish/Emit/FunctionGenerator.cs
+++ b/src/cs/Bootsharp.Publish/Emit/FunctionGenerator.cs
@@ -4,7 +4,7 @@
/// Generates interceptors for methods
/// in the solution (except methods generated by ).
///
-public class FunctionGenerator
+internal sealed class FunctionGenerator
{
-
+ public string Generate (AssemblyInspection inspection) => "";
}
diff --git a/src/cs/Bootsharp.Publish/Emit/ImportGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ImportGenerator.cs
index 50714ba2..e634ae4e 100644
--- a/src/cs/Bootsharp.Publish/Emit/ImportGenerator.cs
+++ b/src/cs/Bootsharp.Publish/Emit/ImportGenerator.cs
@@ -6,5 +6,5 @@
///
internal sealed class ImportGenerator
{
-
+ public string Generate (AssemblyInspection inspection) => "";
}
diff --git a/src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs b/src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs
index b58ffbe7..e04f8a1c 100644
--- a/src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs
+++ b/src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs
@@ -6,7 +6,7 @@
/// generated interop bindings, which is not obvious for DotNet), except
/// methods generated by .
///
-public class InvokableGenerator
+internal sealed class InvokableGenerator
{
-
+ public string Generate (AssemblyInspection inspection) => "";
}
From f61c62f76bf440360a850920112824c2be66d6c8 Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sun, 7 Jan 2024 20:06:11 +0300
Subject: [PATCH 06/75] iteration
---
src/cs/Bootsharp.Common/Bootsharp.Common.csproj | 2 --
.../Emit/{ => ForDotNet}/InteropExportGenerator.cs | 0
.../Emit/{ => ForDotNet}/InteropImportGenerator.cs | 0
.../Emit/{ => ForDotNet}/SerializerGenerator.cs | 0
4 files changed, 2 deletions(-)
rename src/cs/Bootsharp.Publish/Emit/{ => ForDotNet}/InteropExportGenerator.cs (100%)
rename src/cs/Bootsharp.Publish/Emit/{ => ForDotNet}/InteropImportGenerator.cs (100%)
rename src/cs/Bootsharp.Publish/Emit/{ => ForDotNet}/SerializerGenerator.cs (100%)
diff --git a/src/cs/Bootsharp.Common/Bootsharp.Common.csproj b/src/cs/Bootsharp.Common/Bootsharp.Common.csproj
index b52f6d7a..76a68d46 100644
--- a/src/cs/Bootsharp.Common/Bootsharp.Common.csproj
+++ b/src/cs/Bootsharp.Common/Bootsharp.Common.csproj
@@ -12,8 +12,6 @@
-
diff --git a/src/cs/Bootsharp.Publish/Emit/InteropExportGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ForDotNet/InteropExportGenerator.cs
similarity index 100%
rename from src/cs/Bootsharp.Publish/Emit/InteropExportGenerator.cs
rename to src/cs/Bootsharp.Publish/Emit/ForDotNet/InteropExportGenerator.cs
diff --git a/src/cs/Bootsharp.Publish/Emit/InteropImportGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ForDotNet/InteropImportGenerator.cs
similarity index 100%
rename from src/cs/Bootsharp.Publish/Emit/InteropImportGenerator.cs
rename to src/cs/Bootsharp.Publish/Emit/ForDotNet/InteropImportGenerator.cs
diff --git a/src/cs/Bootsharp.Publish/Emit/SerializerGenerator.cs b/src/cs/Bootsharp.Publish/Emit/ForDotNet/SerializerGenerator.cs
similarity index 100%
rename from src/cs/Bootsharp.Publish/Emit/SerializerGenerator.cs
rename to src/cs/Bootsharp.Publish/Emit/ForDotNet/SerializerGenerator.cs
From 8bf4e0183869864405241ee554e0bf0cfd248445 Mon Sep 17 00:00:00 2001
From: Artyom Sovetnikov <2056864+Elringus@users.noreply.github.com>
Date: Sun, 7 Jan 2024 23:16:11 +0300
Subject: [PATCH 07/75] remove source gen
---
src/cs/.scripts/cover.ps1 | 1 -
src/cs/Bootsharp.Common.Test/BindingTest.cs | 9 +-
.../Bootsharp.Common.Test.csproj | 3 -
src/cs/Bootsharp.Common.Test/ExceptionTest.cs | 12 +
src/cs/Bootsharp.Common.Test/FunctionTest.cs | 28 --
.../{ => Exceptions}/Error.cs | 0
.../Exceptions/NotIntercepted.cs | 9 +
src/cs/Bootsharp.Common/Interop/Function.cs | 40 ---
.../{Interop => }/Serializer.cs | 0
.../Bootsharp.Generate.Test.csproj | 41 ---
.../Emitters/EventTest.cs | 73 -----
.../Emitters/ExportTest.cs | 121 --------
.../Emitters/FunctionTest.cs | 229 ----------------
.../Emitters/ImportTest.cs | 258 ------------------
.../Emitters/InvokableTest.cs | 47 ----
.../Bootsharp.Generate.Test/GeneratorTest.cs | 161 -----------
src/cs/Bootsharp.Generate.Test/Verifier.cs | 16 --
.../Bootsharp.Generate.csproj | 15 -
src/cs/Bootsharp.Generate/Common.cs | 143 ----------
.../Emitters/BindingEmitter.cs | 102 -------
.../Bootsharp.Generate/Emitters/ExportType.cs | 65 -----
.../Bootsharp.Generate/Emitters/ImportType.cs | 63 -----
.../Emitters/PartialClass.cs | 72 -----
.../Emitters/PartialMethod.cs | 23 --
src/cs/Bootsharp.Generate/SourceGenerator.cs | 45 ---
src/cs/Bootsharp.Generate/SyntaxReceiver.cs | 42 ---
.../Bootsharp.Publish.Test/Emit/EmitTest.cs | 24 +-
.../Bootsharp.Publish.Test/Emit/EventTest.cs | 21 --
.../Emit/FunctionTest.cs | 6 -
.../Emit/InteropExportTest.cs | 186 -------------
.../Emit/InteropImportTest.cs | 213 ---------------
.../Emit/InvokableTest.cs | 6 -
.../Bootsharp.Publish/Emit/BootsharpEmit.cs | 56 ++--
.../Emit/DependenciesGenerator.cs | 10 +
.../Bootsharp.Publish/Emit/EventGenerator.cs | 10 -
.../Emit/ForDotNet/InteropExportGenerator.cs | 82 ------
.../Emit/ForDotNet/InteropImportGenerator.cs | 83 ------
...onGenerator.cs => InterceptorGenerator.cs} | 6 +-
.../Emit/InteropGenerator.cs | 9 +
.../Emit/InvokableGenerator.cs | 12 -
.../{ForDotNet => }/SerializerGenerator.cs | 0
src/cs/Bootsharp.sln | 12 -
src/cs/Bootsharp/Build/Bootsharp.targets | 34 +--
43 files changed, 90 insertions(+), 2298 deletions(-)
create mode 100644 src/cs/Bootsharp.Common.Test/ExceptionTest.cs
delete mode 100644 src/cs/Bootsharp.Common.Test/FunctionTest.cs
rename src/cs/Bootsharp.Common/{ => Exceptions}/Error.cs (100%)
create mode 100644 src/cs/Bootsharp.Common/Exceptions/NotIntercepted.cs
delete mode 100644 src/cs/Bootsharp.Common/Interop/Function.cs
rename src/cs/Bootsharp.Common/{Interop => }/Serializer.cs (100%)
delete mode 100644 src/cs/Bootsharp.Generate.Test/Bootsharp.Generate.Test.csproj
delete mode 100644 src/cs/Bootsharp.Generate.Test/Emitters/EventTest.cs
delete mode 100644 src/cs/Bootsharp.Generate.Test/Emitters/ExportTest.cs
delete mode 100644 src/cs/Bootsharp.Generate.Test/Emitters/FunctionTest.cs
delete mode 100644 src/cs/Bootsharp.Generate.Test/Emitters/ImportTest.cs
delete mode 100644 src/cs/Bootsharp.Generate.Test/Emitters/InvokableTest.cs
delete mode 100644 src/cs/Bootsharp.Generate.Test/GeneratorTest.cs
delete mode 100644 src/cs/Bootsharp.Generate.Test/Verifier.cs
delete mode 100644 src/cs/Bootsharp.Generate/Bootsharp.Generate.csproj
delete mode 100644 src/cs/Bootsharp.Generate/Common.cs
delete mode 100644 src/cs/Bootsharp.Generate/Emitters/BindingEmitter.cs
delete mode 100644 src/cs/Bootsharp.Generate/Emitters/ExportType.cs
delete mode 100644 src/cs/Bootsharp.Generate/Emitters/ImportType.cs
delete mode 100644 src/cs/Bootsharp.Generate/Emitters/PartialClass.cs
delete mode 100644 src/cs/Bootsharp.Generate/Emitters/PartialMethod.cs
delete mode 100644 src/cs/Bootsharp.Generate/SourceGenerator.cs
delete mode 100644 src/cs/Bootsharp.Generate/SyntaxReceiver.cs
delete mode 100644 src/cs/Bootsharp.Publish.Test/Emit/EventTest.cs
delete mode 100644 src/cs/Bootsharp.Publish.Test/Emit/FunctionTest.cs
delete mode 100644 src/cs/Bootsharp.Publish.Test/Emit/InteropExportTest.cs
delete mode 100644 src/cs/Bootsharp.Publish.Test/Emit/InteropImportTest.cs
delete mode 100644 src/cs/Bootsharp.Publish.Test/Emit/InvokableTest.cs
create mode 100644 src/cs/Bootsharp.Publish/Emit/DependenciesGenerator.cs
delete mode 100644 src/cs/Bootsharp.Publish/Emit/EventGenerator.cs
delete mode 100644 src/cs/Bootsharp.Publish/Emit/ForDotNet/InteropExportGenerator.cs
delete mode 100644 src/cs/Bootsharp.Publish/Emit/ForDotNet/InteropImportGenerator.cs
rename src/cs/Bootsharp.Publish/Emit/{FunctionGenerator.cs => InterceptorGenerator.cs} (60%)
create mode 100644 src/cs/Bootsharp.Publish/Emit/InteropGenerator.cs
delete mode 100644 src/cs/Bootsharp.Publish/Emit/InvokableGenerator.cs
rename src/cs/Bootsharp.Publish/Emit/{ForDotNet => }/SerializerGenerator.cs (100%)
diff --git a/src/cs/.scripts/cover.ps1 b/src/cs/.scripts/cover.ps1
index 5fe991b2..4b07125f 100644
--- a/src/cs/.scripts/cover.ps1
+++ b/src/cs/.scripts/cover.ps1
@@ -2,7 +2,6 @@ try {
$out = "../.cover/"
$json = "../.cover/coverage.json"
dotnet test Bootsharp.Common.Test/Bootsharp.Common.Test.csproj /p:CollectCoverage=true /p:ExcludeByAttribute=GeneratedCodeAttribute /p:CoverletOutput=$out
- dotnet test Bootsharp.Generate.Test/Bootsharp.Generate.Test.csproj /p:CollectCoverage=true /p:ExcludeByAttribute=GeneratedCodeAttribute /p:CoverletOutput=$out /p:MergeWith=$json
dotnet test Bootsharp.Inject.Test/Bootsharp.Inject.Test.csproj /p:CollectCoverage=true /p:ExcludeByAttribute=GeneratedCodeAttribute /p:CoverletOutput=$out /p:MergeWith=$json
dotnet test Bootsharp.Publish.Test/Bootsharp.Publish.Test.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="json%2copencover" /p:ExcludeByAttribute=GeneratedCodeAttribute /p:CoverletOutput=$out /p:MergeWith=$json
reportgenerator "-reports:*/*.xml" "-targetdir:.cover" -reporttypes:HTML
diff --git a/src/cs/Bootsharp.Common.Test/BindingTest.cs b/src/cs/Bootsharp.Common.Test/BindingTest.cs
index 18e58625..6cb3f72d 100644
--- a/src/cs/Bootsharp.Common.Test/BindingTest.cs
+++ b/src/cs/Bootsharp.Common.Test/BindingTest.cs
@@ -13,13 +13,16 @@ public void Records ()
[Fact]
public void RegistersExports ()
{
- Assert.Equal(typeof(IBackend), BindingRegistry.Exports[typeof(global::Backend.JSBackend)].Api);
- Assert.IsType>(BindingRegistry.Exports[typeof(global::Backend.JSBackend)].Factory);
+ var binding = new ExportBinding(typeof(IBackend), default);
+ BindingRegistry.Register(typeof(Backend), binding);
+ Assert.Equal(typeof(IBackend), BindingRegistry.Exports[typeof(Backend)].Api);
}
[Fact]
public void RegistersImports ()
{
- Assert.IsType(BindingRegistry.Imports[typeof(IFrontend)].Implementation);
+ var binding = new ImportBinding(new Frontend());
+ BindingRegistry.Register(typeof(IFrontend), binding);
+ Assert.IsType(BindingRegistry.Imports[typeof(IFrontend)].Implementation);
}
}
diff --git a/src/cs/Bootsharp.Common.Test/Bootsharp.Common.Test.csproj b/src/cs/Bootsharp.Common.Test/Bootsharp.Common.Test.csproj
index 36603de7..585af504 100644
--- a/src/cs/Bootsharp.Common.Test/Bootsharp.Common.Test.csproj
+++ b/src/cs/Bootsharp.Common.Test/Bootsharp.Common.Test.csproj
@@ -29,9 +29,6 @@
-
diff --git a/src/cs/Bootsharp.Common.Test/ExceptionTest.cs b/src/cs/Bootsharp.Common.Test/ExceptionTest.cs
new file mode 100644
index 00000000..9377e54f
--- /dev/null
+++ b/src/cs/Bootsharp.Common.Test/ExceptionTest.cs
@@ -0,0 +1,12 @@
+namespace Bootsharp.Common.Test;
+
+public class ExceptionTest
+{
+ [Fact]
+ public void NotImplementedIncludesMethodName ()
+ {
+ Assert.Contains("$Func", Assert.Throws(Func).Message);
+ }
+
+ private static void Func () => throw new NotIntercepted();
+}
diff --git a/src/cs/Bootsharp.Common.Test/FunctionTest.cs b/src/cs/Bootsharp.Common.Test/FunctionTest.cs
deleted file mode 100644
index 7a02f78a..00000000
--- a/src/cs/Bootsharp.Common.Test/FunctionTest.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using static Bootsharp.Function;
-
-namespace Bootsharp.Common.Test;
-
-public class FunctionTest
-{
- [Fact]
- public void WhenEndpointNotFoundErrorIsThrown ()
- {
- Assert.Contains("Endpoint 'foo' is not found.",
- Assert.Throws(() => Get("foo")).Message);
- }
-
- [Fact]
- public void WhenFunctionTypeIsWrongErrorIsThrown ()
- {
- Set("bar", null);
- Assert.Contains("Endpoint 'bar' is not 'System.Action'.",
- Assert.Throws(() => Get("bar")).Message);
- }
-
- [Fact]
- public void CanSetAndGetDelegate ()
- {
- Set("echo", (int x, int y) => x + y);
- Assert.Equal(15, Get>("echo")(6, 9));
- }
-}
diff --git a/src/cs/Bootsharp.Common/Error.cs b/src/cs/Bootsharp.Common/Exceptions/Error.cs
similarity index 100%
rename from src/cs/Bootsharp.Common/Error.cs
rename to src/cs/Bootsharp.Common/Exceptions/Error.cs
diff --git a/src/cs/Bootsharp.Common/Exceptions/NotIntercepted.cs b/src/cs/Bootsharp.Common/Exceptions/NotIntercepted.cs
new file mode 100644
index 00000000..9756a992
--- /dev/null
+++ b/src/cs/Bootsharp.Common/Exceptions/NotIntercepted.cs
@@ -0,0 +1,9 @@
+using System.Runtime.CompilerServices;
+
+namespace Bootsharp;
+
+///
+/// Exception thrown when Bootsharp fails to intercept user-defined interop method.
+///
+public sealed class NotIntercepted ([CallerMemberName] string name = "") :
+ Exception($"Bootsharp failed to intercept '${name}'.");
diff --git a/src/cs/Bootsharp.Common/Interop/Function.cs b/src/cs/Bootsharp.Common/Interop/Function.cs
deleted file mode 100644
index 880b1c1c..00000000
--- a/src/cs/Bootsharp.Common/Interop/Function.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-namespace Bootsharp;
-
-///
-/// Provides access to JavaScript function delegates via endpoints.
-///
-///
-/// Endpoint is composed of JavaScript object and function names joined with dot.
-/// In case host object is composed, object chain is joined with dots as well.
-///
-public static class Function
-{
- private static readonly Dictionary functions = new();
-
- ///
- /// Maps function delegate to specified endpoint.
- ///
- ///
- /// Performed at 'PrepareBootsharp' build step (not in source generator).
- ///
- public static void Set (string endpoint, Delegate func)
- {
- functions[endpoint] = func;
- }
-
- ///
- /// Returns function delegate of specified endpoint and type.
- ///
- ///
- /// Used in sources generated for partial
- /// and methods.
- ///
- public static T Get (string endpoint) where T : Delegate
- {
- if (!functions.TryGetValue(endpoint, out var func))
- throw new Error($"Endpoint '{endpoint}' is not found.");
- if (func is not T specific)
- throw new Error($"Endpoint '{endpoint}' is not '{typeof(T)}'.");
- return specific;
- }
-}
diff --git a/src/cs/Bootsharp.Common/Interop/Serializer.cs b/src/cs/Bootsharp.Common/Serializer.cs
similarity index 100%
rename from src/cs/Bootsharp.Common/Interop/Serializer.cs
rename to src/cs/Bootsharp.Common/Serializer.cs
diff --git a/src/cs/Bootsharp.Generate.Test/Bootsharp.Generate.Test.csproj b/src/cs/Bootsharp.Generate.Test/Bootsharp.Generate.Test.csproj
deleted file mode 100644
index 8b23a226..00000000
--- a/src/cs/Bootsharp.Generate.Test/Bootsharp.Generate.Test.csproj
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- net8.0
- enable
- false
-
-
-
- https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json;
-
-
-
-
-
-
-
-
-
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
diff --git a/src/cs/Bootsharp.Generate.Test/Emitters/EventTest.cs b/src/cs/Bootsharp.Generate.Test/Emitters/EventTest.cs
deleted file mode 100644
index 466ed93d..00000000
--- a/src/cs/Bootsharp.Generate.Test/Emitters/EventTest.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-namespace Bootsharp.Generate.Test;
-
-public static class EventTest
-{
- public static IEnumerable