Skip to content

Commit

Permalink
Fix MA0075 for binary operations (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou authored Nov 8, 2023
1 parent ad76c97 commit 6c2faf3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ public bool IsCultureSensitiveOperation(IOperation operation, CultureSensitiveOp

if (operation is IArrayElementReferenceOperation arrayElementReference)
return IsCultureSensitiveType(arrayElementReference.Type, format: null, instance: null, options);

if (operation is IBinaryOperation binaryOperation)
return IsCultureSensitiveType(binaryOperation.Type, format: null, instance: null, options);

// Unknown operation
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,24 @@ void A()
_ = "abc" + char.ToLower(c, System.Globalization.CultureInfo.InvariantCulture);
}
}
""";
await CreateProjectBuilder()
.WithSourceCode(sourceCode)
.ValidateAsync();
}

[Fact]
public async Task ConcatNoDiagnostic_Boolean()
{
var sourceCode = """
class Test
{
void A()
{
bool? value = null;
_ = "=" + (value == true);
}
}
""";
await CreateProjectBuilder()
.WithSourceCode(sourceCode)
Expand Down

0 comments on commit 6c2faf3

Please sign in to comment.