diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2023-12-07 07:26:02 +0100 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2023-12-07 07:26:02 +0100 |
commit | 83f9a4df147ef58c884f43092527f5cb6fa2f0a9 (patch) | |
tree | 336f0cc008723f8dba11a480249de7c76ad3e9ea /Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs | |
parent | Cleanup, move ArcaneLibs to submodule instead of parent submodule (diff) | |
download | LibMatrix-83f9a4df147ef58c884f43092527f5cb6fa2f0a9.tar.xz |
Temp state
Diffstat (limited to '')
-rw-r--r-- | Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs | 22 |
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 |