about summary refs log tree commit diff
path: root/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs28
1 files changed, 19 insertions, 9 deletions
diff --git a/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs b/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
index 76d6357..0c0277b 100644
--- a/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
+++ b/Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs
@@ -1,8 +1,6 @@
-using System.Reflection;
-using ArcaneLibs;
+using ArcaneLibs;
 using ArcaneLibs.Extensions.Streams;
-using LibMatrix;
-using LibMatrix.Interfaces;
+using LibMatrix.EventTypes;
 
 // string binary = args.Length > 1 ? args[0] : Console.ReadLine()!;
 
@@ -10,13 +8,25 @@ using LibMatrix.Interfaces;
 File.Delete("EventSerializerContexts.g.cs");
 var stream = File.OpenWrite("EventSerializerContexts.g.cs");
 var eventContentTypes = new ClassCollector<EventContent>().ResolveFromAllAccessibleAssemblies();
+
+stream.WriteString("using System.Text.Json.Serialization;\n");
+
+stream.WriteString(string.Join('\n', eventContentTypes.DistinctBy(x => x.Namespace)
+    .Select(x => $"using {x.Namespace};")));
+stream.WriteString("\n\nnamespace LibMatrix.Generated;\n\n[JsonSourceGenerationOptions(WriteIndented = true)]\n");
+
+// stream.WriteString(string.Join('\n', eventContentTypes//.DistinctBy(x => x.Namespace)
+//     .Select(x => $$"""
+//                   [JsonSourceGenerationOptions(WriteIndented = true)]
+//                   [JsonSerializable(typeof({{x.Name}}))]
+//                   internal partial class {{x.Name}}SerializerContext : JsonSerializerContext { }
+//
+//                   """)));
+
 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 { }
+    .Select(x => $"[JsonSerializable(typeof({x.Name}))]")));
 
-                  """)));
+stream.WriteString("\ninternal partial class EventTypeSerializerContext : JsonSerializerContext { }");
 
 await stream.FlushAsync();
 stream.Close();
\ No newline at end of file