Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
buyaa-n authored Dec 19, 2022
1 parent c358bfb commit d22ec17
Showing 1 changed file with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ public override void Initialize(AnalysisContext context)
var stringType = context.Compilation.GetSpecialType(SpecialType.System_String);
var hasAnyStartsWith = false;
var hasStartsWithCharOverload = false;
foreach (var startsWith in stringType.GetMembers("StartsWith"))
foreach (var startsWithMethod in stringType.GetMembers("StartsWith").OfType<IMethodSymbol>())
{
if (startsWith is IMethodSymbol startsWithMethod)
hasAnyStartsWith = true;
if (startsWithMethod.Parameters is [{ Type.SpecialType: SpecialType.System_Char }])
{
hasAnyStartsWith = true;
if (startsWithMethod.Parameters is [{ Type.SpecialType: SpecialType.System_Char }])
{
hasStartsWithCharOverload = true;
break;
}
hasStartsWithCharOverload = true;
break;
}
}

Expand All @@ -68,26 +65,23 @@ public override void Initialize(AnalysisContext context)
}

var indexOfMethodsBuilder = ImmutableArray.CreateBuilder<(IMethodSymbol IndexOfSymbol, string OverloadPropertyValue)>();
foreach (var indexOf in stringType.GetMembers("IndexOf"))
foreach (var indexOfMethod in stringType.GetMembers("IndexOf").OfType<IMethodSymbol>())
{
if (indexOf is IMethodSymbol indexOfMethod)
if (indexOfMethod.Parameters is [{ Type.SpecialType: SpecialType.System_String }])
{
if (indexOfMethod.Parameters is [{ Type.SpecialType: SpecialType.System_String }])
{
indexOfMethodsBuilder.Add((indexOfMethod, OverloadString));
}
else if (indexOfMethod.Parameters is [{ Type.SpecialType: SpecialType.System_Char }])
{
indexOfMethodsBuilder.Add((indexOfMethod, OverloadChar));
}
else if (indexOfMethod.Parameters is [{ Type.SpecialType: SpecialType.System_String }, { Name: "comparisonType" }])
{
indexOfMethodsBuilder.Add((indexOfMethod, OverloadString_StringComparison));
}
else if (indexOfMethod.Parameters is [{ Type.SpecialType: SpecialType.System_Char }, { Name: "comparisonType" }])
{
indexOfMethodsBuilder.Add((indexOfMethod, OverloadChar_StringComparison));
}
indexOfMethodsBuilder.Add((indexOfMethod, OverloadString));
}
else if (indexOfMethod.Parameters is [{ Type.SpecialType: SpecialType.System_Char }])
{
indexOfMethodsBuilder.Add((indexOfMethod, OverloadChar));
}
else if (indexOfMethod.Parameters is [{ Type.SpecialType: SpecialType.System_String }, { Name: "comparisonType" }])
{
indexOfMethodsBuilder.Add((indexOfMethod, OverloadString_StringComparison));
}
else if (indexOfMethod.Parameters is [{ Type.SpecialType: SpecialType.System_Char }, { Name: "comparisonType" }])
{
indexOfMethodsBuilder.Add((indexOfMethod, OverloadChar_StringComparison));
}
}

Expand Down

0 comments on commit d22ec17

Please sign in to comment.