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 | |
parent | Temp state (diff) | |
download | LibMatrix-5affd9f061e75f6575a2fe6715f9e8757cfe87e8.tar.xz |
Cleanup
Diffstat (limited to 'Utilities/LibMatrix.JsonSerializerContextGenerator')
-rw-r--r-- | Utilities/LibMatrix.JsonSerializerContextGenerator/EventSerializerContexts.g.cs | 99 | ||||
-rw-r--r-- | Utilities/LibMatrix.JsonSerializerContextGenerator/Program.cs | 28 |
2 files changed, 19 insertions, 108 deletions
diff --git a/Utilities/LibMatrix.JsonSerializerContextGenerator/EventSerializerContexts.g.cs b/Utilities/LibMatrix.JsonSerializerContextGenerator/EventSerializerContexts.g.cs deleted file mode 100644 index 1ca32dd..0000000 --- a/Utilities/LibMatrix.JsonSerializerContextGenerator/EventSerializerContexts.g.cs +++ /dev/null @@ -1,99 +0,0 @@ -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.UnknownEventContent))] -internal partial class UnknownEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.RoomMessageEventContent))] -internal partial class RoomMessageEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.PresenceEventContent))] -internal partial class PresenceEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomTypingEventContent))] -internal partial class RoomTypingEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.ServerPolicyRuleEventContent))] -internal partial class ServerPolicyRuleEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.UserPolicyRuleEventContent))] -internal partial class UserPolicyRuleEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomPolicyRuleEventContent))] -internal partial class RoomPolicyRuleEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomAliasEventContent))] -internal partial class RoomAliasEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomAvatarEventContent))] -internal partial class RoomAvatarEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomCanonicalAliasEventContent))] -internal partial class RoomCanonicalAliasEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomCreateEventContent))] -internal partial class RoomCreateEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomEncryptionEventContent))] -internal partial class RoomEncryptionEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomGuestAccessEventContent))] -internal partial class RoomGuestAccessEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomHistoryVisibilityEventContent))] -internal partial class RoomHistoryVisibilityEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomJoinRulesEventContent))] -internal partial class RoomJoinRulesEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomMemberEventContent))] -internal partial class RoomMemberEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomNameEventContent))] -internal partial class RoomNameEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomPinnedEventContent))] -internal partial class RoomPinnedEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomPowerLevelEventContent))] -internal partial class RoomPowerLevelEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomServerACLEventContent))] -internal partial class RoomServerACLEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.RoomTopicEventContent))] -internal partial class RoomTopicEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.SpaceChildEventContent))] -internal partial class SpaceChildEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Spec.State.SpaceParentEventContent))] -internal partial class SpaceParentEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Common.MjolnirShortcodeEventContent))] -internal partial class MjolnirShortcodeEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } - -[System.Text.Json.Serialization.JsonSourceGenerationOptions(WriteIndented = true)] -[System.Text.Json.Serialization.JsonSerializable(typeof(LibMatrix.EventTypes.Common.RoomEmotesEventContent))] -internal partial class RoomEmotesEventContentSerializerContext : System.Text.Json.Serialization.JsonSerializerContext { } 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 |