diff options
Diffstat (limited to 'Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs')
-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 |