diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2023-12-14 07:20:46 +0100 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2023-12-14 07:20:46 +0100 |
commit | 5affd9f061e75f6575a2fe6715f9e8757cfe87e8 (patch) | |
tree | 13ea35ce981094a960746777a16dff8815c45e55 /Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs | |
parent | Temp state (diff) | |
download | LibMatrix-5affd9f061e75f6575a2fe6715f9e8757cfe87e8.tar.xz |
Cleanup
Diffstat (limited to 'Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs')
-rw-r--r-- | Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs | 28 |
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 |