Skip to content

Commit

Permalink
MA0075: Fix false-positive for array element reference operations (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou authored Sep 30, 2023
1 parent d09d775 commit dec1611
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 @@ -206,6 +206,9 @@ public bool IsCultureSensitiveOperation(IOperation operation, CultureSensitiveOp

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

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

// Unknown operation
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ await CreateProjectBuilder()
.ValidateAsync();
}

[Fact]
public async Task Concat_Char_String_NoDiagnostic()
{
var sourceCode = """
class Test
{
void A(char[] c)
{
string str = "";
str = c[0] + str;
}
}
""";
await CreateProjectBuilder()
.WithSourceCode(sourceCode)
.ValidateAsync();
}

[Theory]
[InlineData("abc[|{(sbyte)-1}|]")]
[InlineData("abc[|{(short)-1}|]")]
Expand Down

0 comments on commit dec1611

Please sign in to comment.