From f680486ab8065c07a16c329ac875fab148ff1782 Mon Sep 17 00:00:00 2001 From: dannoe Date: Fri, 5 Jul 2024 23:21:39 +0200 Subject: [PATCH 1/2] Fix NRE on missing MandatoryAffixes --- .../Design/Rule0054FollowInterfaceObjectNameGuide.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs b/BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs index 02e73a1c..2b135dfc 100644 --- a/BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs +++ b/BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs @@ -103,6 +103,9 @@ private static List GetAffixes(Compilation compilation) if (copConfiguration is null) return null; + if (copConfiguration.MandatoryAffixes == null) + return null; + List affixes = new List(); if (!string.IsNullOrEmpty(copConfiguration.MandatoryPrefix) && !affixes.Contains(copConfiguration.MandatoryPrefix, StringComparer.OrdinalIgnoreCase)) affixes.Add(copConfiguration.MandatoryPrefix); From 2c53abcfdf530ad3b221f3665f97619bca4fabbe Mon Sep 17 00:00:00 2001 From: dannoe Date: Sun, 7 Jul 2024 18:17:52 +0200 Subject: [PATCH 2/2] Fixed too early return --- .../Design/Rule0054FollowInterfaceObjectNameGuide.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs b/BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs index 2b135dfc..e0ce4458 100644 --- a/BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs +++ b/BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs @@ -103,17 +103,17 @@ private static List GetAffixes(Compilation compilation) if (copConfiguration is null) return null; - if (copConfiguration.MandatoryAffixes == null) - return null; - List affixes = new List(); if (!string.IsNullOrEmpty(copConfiguration.MandatoryPrefix) && !affixes.Contains(copConfiguration.MandatoryPrefix, StringComparer.OrdinalIgnoreCase)) affixes.Add(copConfiguration.MandatoryPrefix); - foreach (string mandatoryAffix in copConfiguration.MandatoryAffixes) + if (copConfiguration.MandatoryAffixes != null) { - if (!string.IsNullOrEmpty(mandatoryAffix) && !affixes.Contains(mandatoryAffix, StringComparer.OrdinalIgnoreCase)) - affixes.Add(mandatoryAffix); + foreach (string mandatoryAffix in copConfiguration.MandatoryAffixes) + { + if (!string.IsNullOrEmpty(mandatoryAffix) && !affixes.Contains(mandatoryAffix, StringComparer.OrdinalIgnoreCase)) + affixes.Add(mandatoryAffix); + } } return affixes; }