Skip to content

Commit ce87a5b

Browse files
Code review changes
1 parent fa906c1 commit ce87a5b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/ProvideCorrectArgumentsToFormattingMethods.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ public StringFormatInfo(Compilation compilation)
346346
return info;
347347
}
348348

349-
if (TryGetFormatInfoByCompositeFormatStringSyntaxAttribute(method, out info))
349+
if (StringSyntaxAttribute is not null &&
350+
TryGetFormatInfoByCompositeFormatStringSyntaxAttribute(method, out info))
350351
{
351352
return info;
352353
}
@@ -448,20 +449,15 @@ private static int FindParameterIndexByParameterName(ImmutableArray<IParameterSy
448449

449450
private int FindParameterIndexOfCompositeFormatStringSyntaxAttribute(ImmutableArray<IParameterSymbol> parameters)
450451
{
451-
if (StringSyntaxAttribute is null)
452-
{
453-
return -1;
454-
}
455-
456452
for (var i = 0; i < parameters.Length; i++)
457453
{
458454
ImmutableArray<AttributeData> attributes = parameters[i].GetAttributes();
459455
for (int j = 0; j < attributes.Length; j++)
460456
{
461-
if (Equals(attributes[j].AttributeClass, StringSyntaxAttribute))
457+
if (StringSyntaxAttribute!.Equals(attributes[j].AttributeClass))
462458
{
463459
ImmutableArray<TypedConstant> arguments = attributes[j].ConstructorArguments;
464-
if (arguments.Length == 1 && Equals(arguments[0].Value, CompositeFormat))
460+
if (arguments.Length == 1 && CompositeFormat.Equals(arguments[0].Value))
465461
{
466462
return i;
467463
}

0 commit comments

Comments
 (0)