diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index b51147f..3a26e57 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -22,7 +22,7 @@
- 3.0.12
+ 3.0.13
diff --git a/src/Menees.Analyzers/Men010AvoidMagicNumbers.cs b/src/Menees.Analyzers/Men010AvoidMagicNumbers.cs
index 4430efb..c3a3d52 100644
--- a/src/Menees.Analyzers/Men010AvoidMagicNumbers.cs
+++ b/src/Menees.Analyzers/Men010AvoidMagicNumbers.cs
@@ -111,6 +111,12 @@ private static bool InAllowedDeclarationContext(LiteralExpressionSyntax literalE
case SyntaxKind.RangeExpression:
allowed = literalExpression.Parent == ancestor;
break;
+
+ case SyntaxKind.SimpleAssignmentExpression:
+ allowed = ancestor is AssignmentExpressionSyntax assignment
+ && assignment.Left is MemberAccessExpressionSyntax member
+ && settings.IsAllowedNumericLiteralCaller(member.Name.Identifier.Text);
+ break;
}
return allowed;
diff --git a/src/Menees.Analyzers/Settings.cs b/src/Menees.Analyzers/Settings.cs
index 10fc675..7db2de4 100644
--- a/src/Menees.Analyzers/Settings.cs
+++ b/src/Menees.Analyzers/Settings.cs
@@ -76,7 +76,7 @@ internal sealed class Settings
private readonly HashSet allowedNumericLiterals = new(new[] { "0", "1", "2", "100" });
private readonly HashSet allowedNumericCallerNames = new(new[]
{
- "FromDays", "FromHours", "FromMilliseconds", "FromSeconds", "FromTicks"
+ "FromDays", "FromHours", "FromMicroseconds", "FromMilliseconds", "FromMinutes", "FromSeconds", "FromTicks", "MaxLength"
});
private readonly IEnumerable>? allowedNumericCallerRegexes;
private readonly Dictionary preferredTerms = DefaultPreferredTerms;
diff --git a/tests/Menees.Analyzers.Test/Men010UnitTests.cs b/tests/Menees.Analyzers.Test/Men010UnitTests.cs
index 31da000..787f427 100644
--- a/tests/Menees.Analyzers.Test/Men010UnitTests.cs
+++ b/tests/Menees.Analyzers.Test/Men010UnitTests.cs
@@ -73,6 +73,9 @@ public double GetRate()
return FridayValue;
}
+ DataColumn col = new(""Test"", typeof(string));
+ col.MaxLength = 20;
+
const int DefaultValue = 17;
return DefaultValue;
}
diff --git a/tests/Menees.Analyzers.Test/Menees.Analyzers.Settings.xml b/tests/Menees.Analyzers.Test/Menees.Analyzers.Settings.xml
index 67a2cb5..8724804 100644
--- a/tests/Menees.Analyzers.Test/Menees.Analyzers.Settings.xml
+++ b/tests/Menees.Analyzers.Test/Menees.Analyzers.Settings.xml
@@ -30,6 +30,7 @@
1
2
FromDays
+ MaxLength
^From(Hours|Minutes)$