Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,21 @@ public unsafe string TestMethod(int n, byte* a, byte* b)

await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp8, testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestStackAllocExpressionInExpressionAsync()
{
const string testCode = @"public class TestClass
{
public unsafe void TestMethod()
{
var ptr = stackalloc byte[1];
var span = (stackalloc byte[1]);
}
}
";

await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp8, testCode, DiagnosticResult.EmptyDiagnosticResults).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult
internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, DiagnosticResult expected, CancellationToken cancellationToken)
=> StyleCopDiagnosticVerifier<TAnalyzer>.VerifyCSharpDiagnosticAsync(languageVersion, source, expected, cancellationToken);

internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, DiagnosticResult[] expected, CancellationToken cancellationToken = default)
Comment thread
nxtn marked this conversation as resolved.
Resolved
=> StyleCopDiagnosticVerifier<TAnalyzer>.VerifyCSharpDiagnosticAsync(languageVersion, source, settings: null, expected, cancellationToken);

internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, string settings, DiagnosticResult[] expected, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ private static void HandleParenthesizedExpression(SyntaxNodeAnalysisContext cont
return;
}

if (node.Expression.IsKind(SyntaxKind.StackAllocArrayCreationExpression)
Comment thread
nxtn marked this conversation as resolved.
Resolved
&& node.Parent.IsKind(SyntaxKind.EqualsValueClause))
{
return;
}

ReportDiagnostic(context, node);
}
else
Expand Down