question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SA1008 triggered by typle return types on a method (c# version 7)

See original GitHub issue

The following method triggers SA1008

public (string primary, string alternate) CalculateMetaphone(string word)
      ~
{
}

the only way to avoid the rule is thus:

public(string primary, string alternate) CalculateMetaphone(string word)

which is clearly incorrect. if the return type is a tuple, then a space should be inserted.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
meneescommented, May 19, 2017

I’m also running into it. I’m working around it by using correct spacing and then putting a SuppressMessage attribute above it.

[SuppressMessage("StyleCop", "SA1008", Justification = "StyleCop doesn't understand C#7 tuple return types yet.")]

VS 2017 suggests #pragma warning default SA1008 and #pragma warning restore SA1008 directives before and after the offending line. But I prefer SuppressMessage because it only takes a single line, and it contains the justification for why it’s there (i.e., letting me know it’s a temporary workaround). Once StyleCop.Analyzers is updated, I can search for and remove these SuppressMessage usages easily.

2reactions
Nozzielcommented, Mar 19, 2017

Fixed: pull request

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to return Tuple from a method using Visual Studio ...
Compiler is generating an error: Error CS8137 Cannot define a class or member that utilizes tuples because the compiler required type 'System.
Read more >
Tuple Trouble: Why C# Tuples Get to Break the Guidelines
The invocation of Rotate is intended to modify the instance of Arc stored within pie, but in actuality, it modifies the copy returned...
Read more >
Auto Fix StyleCop Warnings with Free Extensions - Mike Conrad
Warning Detail Code Formatter Code Maid SA1001 Commas should be followed by whitespace. Some Some SA1002 Semicolons should not be preceded by a space. Some...
Read more >
Tuple In C# 7
Tuple is an ordered sequence of heterogeneous objects. We may often write methods which return multiple values so we need to create a...
Read more >
How to infer return type from a tuple parameter? : r/typescript
The way to structure your query is by passing in a tuple of classes and the return type is an array of tuples...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found