SA1008 triggered by typle return types on a method (c# version 7)
See original GitHub issueThe 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:
- Created 7 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Fixed: pull request