From 04d24b6287f609d0b45e56b463142234dee84c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Sun, 15 Jan 2023 17:07:40 +0100 Subject: [PATCH] fix(packets): move validation of "not last token" from previuos parameter to current --- .../PacketConditionalIndexAttributeGenerator.cs | 9 ++++----- .../PacketContextListAttributeGenerator.cs | 9 ++++----- .../PacketGreedyIndexAttributeGenerator.cs | 9 ++++----- .../AttributeGenerators/PacketIndexAttributeGenerator.cs | 9 ++++----- .../PacketListIndexAttributeGenerator.cs | 5 ----- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketConditionalIndexAttributeGenerator.cs b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketConditionalIndexAttributeGenerator.cs index 6c0f669e4e05913ec972fa770dd2d0d7fda1968e..c25fc774730fa64814775178c3cf12abc5d792c4 100644 --- a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketConditionalIndexAttributeGenerator.cs +++ b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketConditionalIndexAttributeGenerator.cs @@ -260,6 +260,10 @@ public class PacketConditionalIndexAttributeGenerator : IParameterGenerator { generator.StartOptionalCheck(parameter, packetInfo.Name); } + else + { + generator.ValidateNotLast(parameter.Name); + } var afterSeparator = attribute.GetNamedValue("AfterSeparator", null); if (afterSeparator is not null) @@ -288,11 +292,6 @@ public class PacketConditionalIndexAttributeGenerator : IParameterGenerator generator.PopLevel(); } - if (!packetInfo.Parameters.IsLast) - { - generator.ValidateNotLast(parameter.Name); - } - // end is last token if body if (parameter.IsOptional()) { diff --git a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketContextListAttributeGenerator.cs b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketContextListAttributeGenerator.cs index 497ab1fdabb71c4e3a33da8979ca25848d16a594..6a4a6d7fb0e1fa5b99b640146444a1862c012787 100644 --- a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketContextListAttributeGenerator.cs +++ b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketContextListAttributeGenerator.cs @@ -102,6 +102,10 @@ public class PacketContextListAttributeGenerator : IParameterGenerator { generator.StartOptionalCheck(parameter, packetInfo.Name); } + else + { + generator.ValidateNotLast(parameter.Name); + } var afterSeparator = attribute.GetNamedValue("AfterSeparator", null); if (afterSeparator is not null) @@ -127,11 +131,6 @@ public class PacketContextListAttributeGenerator : IParameterGenerator generator.AssignLocalVariable(parameter); - if (!packetInfo.Parameters.IsLast) - { - generator.ValidateNotLast(parameter.Name); - } - // end is last token if body if (parameter.IsOptional()) { diff --git a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketGreedyIndexAttributeGenerator.cs b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketGreedyIndexAttributeGenerator.cs index 065b2195bb4fe813a98a4a25f737c9ff0cbed57b..b50c6a1f60757bbdfdc1d4c291a5512949dd239f 100644 --- a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketGreedyIndexAttributeGenerator.cs +++ b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketGreedyIndexAttributeGenerator.cs @@ -68,6 +68,10 @@ public class PacketGreedyIndexAttributeGenerator : IParameterGenerator { generator.StartOptionalCheck(parameter, packetInfo.Name); } + else + { + generator.ValidateNotLast(parameter.Name); + } var afterSeparator = attribute.GetNamedValue("AfterSeparator", null); if (afterSeparator is not null) @@ -99,11 +103,6 @@ public class PacketGreedyIndexAttributeGenerator : IParameterGenerator generator.PopLevel(); } - if (!packetInfo.Parameters.IsLast) - { - generator.ValidateNotLast(parameter.Name); - } - // end is last token if body if (parameter.IsOptional()) { diff --git a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketIndexAttributeGenerator.cs b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketIndexAttributeGenerator.cs index 7c5d46132ca208a337b8158ce17091f095c9bd31..2116e5eed725d3da99c4f24feff3443162685256 100644 --- a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketIndexAttributeGenerator.cs +++ b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketIndexAttributeGenerator.cs @@ -111,6 +111,10 @@ public class PacketIndexAttributeGenerator : IParameterGenerator { generator.StartOptionalCheck(parameter, packetInfo.Name); } + else + { + generator.ValidateNotLast(parameter.Name); + } var afterSeparator = attribute.GetNamedValue("AfterSeparator", null); if (afterSeparator is not null) @@ -139,11 +143,6 @@ public class PacketIndexAttributeGenerator : IParameterGenerator generator.PopLevel(); } - if (!packetInfo.Parameters.IsLast) - { - generator.ValidateNotLast(parameter.Name); - } - // end is last token if body if (parameter.IsOptional()) { diff --git a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketListIndexAttributeGenerator.cs b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketListIndexAttributeGenerator.cs index 33f3d4415f4207f95a9631c882781a706bf67249..78774978bdbc68ca5e50c1b79bafbb76a9e2afd7 100644 --- a/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketListIndexAttributeGenerator.cs +++ b/Packets/NosSmooth.PacketSerializersGenerator/AttributeGenerators/PacketListIndexAttributeGenerator.cs @@ -144,11 +144,6 @@ public class PacketListIndexAttributeGenerator : IParameterGenerator generator.AssignLocalVariable(parameter, false); - if (!packetInfo.Parameters.IsLast) - { - generator.ValidateNotLast(parameter.Name); - } - // end is last token if body if (parameter.IsOptional()) {