From 781f6734ef55c91cfb0f75f7d1bb4bfbbda16738 Mon Sep 17 00:00:00 2001 From: rokklobster <37376850+rokklobster@users.noreply.github.com> Date: Mon, 26 Sep 2022 12:17:43 +0300 Subject: Fix errors arising from NullableAttribute analysis (#68) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix errors arising from NullableAttribute analysis * Fix indentation Co-authored-by: Andrey Sayapin <103108530+an-sayapin@users.noreply.github.com> Co-authored-by: Alexander Köplinger --- gendarme/framework/Gendarme.Framework/BasicIgnoreList.cs | 4 ++++ .../AttributeArgumentsShouldHaveAccessorsRule.cs | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gendarme/framework/Gendarme.Framework/BasicIgnoreList.cs b/gendarme/framework/Gendarme.Framework/BasicIgnoreList.cs index 26717ab7..f1dc1fee 100644 --- a/gendarme/framework/Gendarme.Framework/BasicIgnoreList.cs +++ b/gendarme/framework/Gendarme.Framework/BasicIgnoreList.cs @@ -61,6 +61,10 @@ namespace Gendarme.Framework { public void Add (string rule, IMetadataTokenProvider metadata) { + if (rule is null) { + Console.Error.WriteLine("Attempted to add null rule"); + return; + } HashSet list; if (!ignore.TryGetValue (rule, out list)) { list = new HashSet (); diff --git a/gendarme/rules/Gendarme.Rules.Design/AttributeArgumentsShouldHaveAccessorsRule.cs b/gendarme/rules/Gendarme.Rules.Design/AttributeArgumentsShouldHaveAccessorsRule.cs index cc037aa3..1a803c97 100644 --- a/gendarme/rules/Gendarme.Rules.Design/AttributeArgumentsShouldHaveAccessorsRule.cs +++ b/gendarme/rules/Gendarme.Rules.Design/AttributeArgumentsShouldHaveAccessorsRule.cs @@ -126,7 +126,11 @@ namespace Gendarme.Rules.Design { continue; foreach (ParameterDefinition param in constructor.Parameters) { - // pascal case it + // pascal case it + if (param.Name.Length == 0) { + Console.Error.WriteLine("Unexpected empty constructor parameter.\n Type: {0}\n Method: {1}", type.FullName, constructor); + continue; + } string correspondingPropertyName = Char.ToUpper (param.Name [0], CultureInfo.InvariantCulture).ToString (CultureInfo.InvariantCulture) + param.Name.Substring (1); if (!allProperties.Contains (correspondingPropertyName)) { -- cgit v1.2.3