Code Monkey home page Code Monkey logo

Comments (6)

bjornhellander avatar bjornhellander commented on August 16, 2024 1

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.

bjornhellander avatar bjornhellander commented on August 16, 2024 1

@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.

bjornhellander avatar bjornhellander commented on August 16, 2024

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.

bjornhellander avatar bjornhellander commented on August 16, 2024

@ozsvart-karoly-nexius Did you try updating the nuget package?

from stylecopanalyzers.

arphox avatar arphox commented on August 16, 2024

@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.

arphox avatar arphox commented on August 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.