SA1000 ignores 'default' in a default literal expression
See original GitHub issueCurrently SA1000 is getting reported for the following C# 7.1 syntax:
var x = value == null ? default : 3;
Edit: a workaround is now implemented to simply ignore default literal expressions. The bug has a new title for providing full support for this keyword.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
SA1000 doesn't handle 'target-typed' new · Issue #3214
With C# 9.0, SA1000 complains about "target type new expressions": ... SA1000 ignores 'default' in a default literal expression #2420.
Read more >Default literal expressions in C# 7.1
Default literal expressions let us use default values for types. I think most of my readers know default keyword from C#. Here are...
Read more >In c#, is it a good practice to return default literal? [closed]
Recently, I saw some are writing code to return default literal for nullable primitive type, is there a real benefit for it?
Read more >C# 7.0 and 7.1 support in ReSharper - Default literal
Visual Studio 2017 15.3 introduced another nice C# 7.1 feature: the default literal. It can be used instead of the default(T) expression, ...
Read more >IDE0034: Simplify 'default' expression - .NET
This style rule concerns using the default literal for default value expressions when the compiler can infer the type of the expression.
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 think the current behaviour is correct. In this context,
default
is equivalent to a literal or a variable, so I expect SA1000 to continue to ignore it. Removing the trailing space in this example already triggers SA1003 and SA1024.SA1000 tests should be added, though, to make sure that it doesn’t regress.
@jethas-bennettjones you’re seeing #3214