Skip to content

Commit c5a16db

Browse files
committed
Merge pull request #1792 from vweijsters/fix-1776
SA1003 now ignores pointer dereference
2 parents 661522c + 9074cff commit c5a16db

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1003UnitTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,30 @@ public class C1
853853
await this.VerifyCSharpFixAsync(testCode, fixedTestCode).ConfigureAwait(false);
854854
}
855855

856+
/// <summary>
857+
/// Verifies that pointer dereference will not trigger SA1003, as it is covered by SA1023.
858+
/// This is a regression test for #1776
859+
/// </summary>
860+
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
861+
[Fact]
862+
public async Task TestPointerDereferenceNotReportedAsync()
863+
{
864+
var testCode = @"public class TestClass
865+
{
866+
public void TestMethod()
867+
{
868+
unsafe
869+
{
870+
int * value = null;
871+
int blah = * value;
872+
}
873+
}
874+
}
875+
";
876+
877+
await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
878+
}
879+
856880
/// <inheritdoc/>
857881
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
858882
{

StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1003SymbolsMustBeSpacedCorrectly.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ internal class SA1003SymbolsMustBeSpacedCorrectly : DiagnosticAnalyzer
9999
SyntaxKind.LogicalNotExpression,
100100
SyntaxKind.PreIncrementExpression,
101101
SyntaxKind.PreDecrementExpression,
102-
SyntaxKind.AddressOfExpression,
103-
SyntaxKind.PointerIndirectionExpression);
102+
SyntaxKind.AddressOfExpression);
104103

105104
private static readonly ImmutableArray<SyntaxKind> PostfixUnaryExpressionKinds =
106105
ImmutableArray.Create(SyntaxKind.PostIncrementExpression, SyntaxKind.PostDecrementExpression);

0 commit comments

Comments
 (0)