From fda107229a573d8abd654294231718f851c717d8 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Tue, 3 Dec 2024 14:05:12 +1100 Subject: [PATCH] Update Parser.cs --- src/AustralianProtectiveMarkings/Parser.cs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/AustralianProtectiveMarkings/Parser.cs b/src/AustralianProtectiveMarkings/Parser.cs index 5a98ba3..abac9a8 100644 --- a/src/AustralianProtectiveMarkings/Parser.cs +++ b/src/AustralianProtectiveMarkings/Parser.cs @@ -79,12 +79,14 @@ public static ProtectiveMarking ParseProtectiveMarking(string input) throw new($"Only a single DOWNTO is allowed. Input: {input}"); } - if (downToItems.Count == 0 && expiresItems.Count == 0) + if (downToItems.Count == 0 && + expiresItems.Count == 0) { return null; } - if (downToItems.Count == 0 || expiresItems.Count == 0) + if (downToItems.Count == 0 || + expiresItems.Count == 0) { throw new($"EXPIRES and DOWNTO cannot be defined without the other. Input: {input}"); } @@ -111,15 +113,17 @@ static void ValidateOrder(string input, List keys) { var ordered = keys .OrderBy(_ => order.IndexOf(_)); - if (!ordered.SequenceEqual(keys)) + if (ordered.SequenceEqual(keys)) { - throw new($""" - Incorrect order. - Order must be: {string.Join(", ", order)}. - Order is: {string.Join(", ", keys)}. - Input: {input} - """); + return; } + + throw new($""" + Incorrect order. + Order must be: {string.Join(", ", order)}. + Order is: {string.Join(", ", keys)}. + Input: {input} + """); } static Classification ReadClassification(string input, List pairs)