about summary refs log tree commit diff
path: root/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
diff options
context:
space:
mode:
authorEmma [it/its]@Rory& <root@rory.gay>2023-12-07 07:26:02 +0100
committerEmma [it/its]@Rory& <root@rory.gay>2023-12-07 07:26:02 +0100
commit83f9a4df147ef58c884f43092527f5cb6fa2f0a9 (patch)
tree336f0cc008723f8dba11a480249de7c76ad3e9ea /Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
parentCleanup, move ArcaneLibs to submodule instead of parent submodule (diff)
downloadLibMatrix-83f9a4df147ef58c884f43092527f5cb6fa2f0a9.tar.xz
Temp state
Diffstat (limited to 'Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs')
-rw-r--r--Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs b/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
new file mode 100644
index 0000000..76d6357
--- /dev/null
+++ b/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
@@ -0,0 +1,22 @@
+using System.Reflection;
+using ArcaneLibs;
+using ArcaneLibs.Extensions.Streams;
+using LibMatrix;
+using LibMatrix.Interfaces;
+
+// string binary = args.Length > 1 ? args[0] : Console.ReadLine()!;
+
+// var asm = Assembly.LoadFrom(binary);
+File.Delete("EventSerializerContexts.g.cs");
+var stream = File.OpenWrite("EventSerializerContexts.g.cs");
+var eventContentTypes = new ClassCollector<EventContent>().ResolveFromAllAccessibleAssemblies();
+stream.WriteString(string.Join('\n', eventContentTypes//.DistinctBy(x => x.Namespace)
+    .Select(x => $$"""
+                  [System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)]
+                  [System.Text.Json.Serialization.JsonSerializable(typeof({{x.FullName}}))]
+                  internal partial class {{x.Name}}SerializerContext : System.Text.Json.Serialization.JsonSerializerContext { }
+
+                  """)));
+
+await stream.FlushAsync();
+stream.Close();
\ No newline at end of file