Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2308 - SA1008 triggered by typle return types on a method - fixed #2319

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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 @@ -2032,6 +2032,90 @@ class ClassName
await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Verifies that spacing for public tuple return type is handled properly.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact(Skip = "Tuples currently require System.ValueTuple nuget package to be installed")]
public async Task TestNoFalsePositiveOnPublicTupleReturnAsync()
{
var testCode = @"namespace TestNamespace
{
public class TestClass
{
public (string primary, string alternate) CalculateMetaphone(string word)
{
}
}
}
";

await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Verifies that spacing for internal tuple return type is handled properly.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact(Skip = "Tuples currently require System.ValueTuple nuget package to be installed")]
public async Task TestNoFalsePositiveOnInternalTupleReturnAsync()
{
var testCode = @"namespace TestNamespace
{
internal class TestClass
{
public (string primary, string alternate) CalculateMetaphone(string word)
{
}
}
}
";

await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Verifies that spacing for private tuple return type is handled properly.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact(Skip = "Tuples currently require System.ValueTuple nuget package to be installed")]
public async Task TestNoFalsePositiveOnPrivateTupleReturnAsync()
{
var testCode = @"namespace TestNamespace
{
private class TestClass
{
public (string primary, string alternate) CalculateMetaphone(string word)
{
}
}
}
";

await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Verifies that spacing for protected tuple return type is handled properly.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Fact(Skip = "Tuples currently require System.ValueTuple nuget package to be installed")]
public async Task TestNoFalsePositiveProtectedOnTupleReturnAsync()
{
var testCode = @"namespace TestNamespace
{
protected class TestClass
{
public (string primary, string alternate) CalculateMetaphone(string word)
{
}
}
}
";

await this.VerifyCSharpDiagnosticAsync(testCode, EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}

/// <inheritdoc/>
protected override IEnumerable<DiagnosticAnalyzer> GetCSharpDiagnosticAnalyzers()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt
case SyntaxKind.WhereKeyword:
case SyntaxKind.WhileKeyword:
case SyntaxKind.YieldKeyword:
precededByKeyword = true;
case SyntaxKind.PublicKeyword:
case SyntaxKind.PrivateKeyword:
case SyntaxKind.InternalKeyword:
case SyntaxKind.ProtectedKeyword:
precededByKeyword = true;
break;

default:
Expand Down