Comments (6)
Sorry, I got confused. I saw a warning after the curly brace, but didn't notice that it was SA1025 instead of SA1013. Checking again...
from stylecopanalyzers.
@arphox, do you interpret the documentation to mean that SA1013 should forbid spaces between the closing brace and a comma? I understand if you do, but I don't think it actually says that, although I am not really sure.
Normally, a closing brace requires a following space. But if the next token is a comma, it does not require a space. It does not forbid one, just does not require one. The reason for this behaviour should be that spacing around a comma is controlled by SA1001, so to avoid both rules having to have an opinion about the same situation, SA1013 ignores this situation instead.
For the code you presented, I get SA1001 (Commas should not be preceeded by whitespace) and SA1025 (Code should not contain multiple whitespace in a row), but not SA1013.
I think this is good thing, but I understand that the documentation could be interpreted to mean that SA1013 should forbid following spaces before a comma. I actually read it like that. Unsure if that is because I am not a native english speaker, or if it actually is misleading.
The documentation also talks about a single space and I don't think that is how this rule is implemented. We have SA1025 to deal with too many spaces, so SA1013 (and many others) just care about if there are any spaces or none.
from stylecopanalyzers.
This does not reproduce with the latest beta. Version 1.1.118 is from 2019, so there has been a lot of fixes since then. I would recommend that you switch to the latest beta version instead. If you have plans on using modern c# features (= c# 8 and later), then you really need to use a beta version, since you will experience so many problems otherwise.
from stylecopanalyzers.
@ozsvart-karoly-nexius Did you try updating the nuget package?
from stylecopanalyzers.
@ozsvart-karoly-nexius Did you try updating the nuget package?
(I'm the reporter, but I accidentally created the issue with my work account.)
Yes. It is still a problem with the latest beta at the moment: 1.2.0-beta.507
.
Code example:
public class MyClass
{
public Guid X { get; set; }
public List<string>? Y { get; set; }
}
private static void Test()
{
List<MyClass> x = new()
{
new MyClass
{
X = new Guid("58523c2d-eb9e-425e-b50a-426cb6876bf4"),
Y = new List<string> { "2", "0", "1" } ,
},
};
Console.WriteLine(x.Count);
}
dotnet_diagnostic.SA1013.severity = warning
from stylecopanalyzers.
@bjornhellander thank you for your input! 🚀
I had SA1001 disabled because I thought it is completely handled by IDE0055, but it seems I was wrong. After enabling SA1001 it reported a violation, so my issue is solved, although I think we should leave this issue open for handling the situation regarding SA1013, because if nothing else, at least the documentation should be improved to be unambiguous.
from stylecopanalyzers.
Related Issues (20)
- SA1009 triggers when having the closing parenthesis on a single line HOT 2
- StyleCop schema file URL is getting timed out HOT 1
- SA1134 exception for auto-properties HOT 1
- SA1119 false positive for parenthesis around `x switch {}` expression HOT 3
- SA1009 is triggered for the increment in prefix notation
- SA1118 false positive with multi-line collection expressions as arguments HOT 1
- [Question] proper way ot add stylecop.json to a multiproject solution using visual studio code. HOT 3
- SA1648 false positive when implementing static interface members HOT 2
- SA1516 Elements should be separated by blank line - Razor Class Library - csproj file HOT 12
- New Analyzer: Use File Scoped Namespaces HOT 3
- Remove ConfigureAwait(false) in tests? HOT 4
- SA1008 False Positive if a tuple type is assigned an alias via `using`.
- SA1313 Allow underscore for primary constructors C# 12 HOT 3
- SA1102 documentation should include a working C# snippet example HOT 1
- False positive: SA1010 cannot handle the new list-initializer syntax HOT 2
- SA1010: Opening square brackets should not be preceded by a space conflicts with IDE0305 HOT 1
- SA1010 (no space before "[") conflicts with IDE0305 (use collection expression) HOT 1
- Unexpected SA1131 HOT 5
- SA1210 and SA1208 are ignored when using statements are inside a file-scoped namespace. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stylecopanalyzers.