Skip to content

Commit

Permalink
MA0074 recognize more methods
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Feb 16, 2023
1 parent b31800e commit 1e4741c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Meziantou.Analyzer/Rules/UseStringComparisonAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ private static bool IsNonCultureSensitiveMethod(IInvocationOperation operation)
if (method.ContainingType.IsString() && method.Name == nameof(string.StartsWith) && method.Parameters.Length == 1 && method.Parameters[0].Type.IsChar())
return true;

// string.Contains(char)
if (method.ContainingType.IsString() && method.Name == nameof(string.Contains) && method.Parameters.Length == 1 && method.Parameters[0].Type.IsChar())
return true;

// JObject.Property / TryGetValue / GetValue
var jobjectType = operation.SemanticModel!.Compilation.GetBestTypeByMetadataName("Newtonsoft.Json.Linq.JObject");
if (method.ContainingType.IsEqualTo(jobjectType))
Expand Down

0 comments on commit 1e4741c

Please sign in to comment.