dennisdoomen / CSharpGuidelines

A set of coding guidelines for C# 9.0, design principles and layout rules for improving the overall quality of your code development.
https://www.csharpcodingguidelines.com
Other
746 stars 271 forks source link

Error AV1500 caps max class statements instead of methods when using primary constructors #275

Closed TomasMalcanek closed 4 months ago

TomasMalcanek commented 4 months ago

Description: When a primary constructor is used, and inheriting another class the AV1500 is counting statements in the class instead of single methods.

Code to test:

public class Skoda(string someParameter) : Car(someParameter)
{
    void Method1()
    {
        int statement = 1;
        statement += 1;
        statement += 1;
        statement += 1;
        statement += 1;
    }

    void Method2()
    {
        int statement = 1;
        statement += 1;
        statement += 1;
        statement += 1;
        statement += 1;
        statement += 1;
    }

    void Method3()
    {
        int statement = 1;
        statement += 1;
        statement += 1;
        statement += 1;
    }
}

public class Car(string someParameter)
{
    public string SomeParameterUpper => someParameter.ToUpper();
}

image

Versions: Using .NET 8

bkoelman commented 4 months ago

This should be fixed in the latest version. Which version are you using?

TomasMalcanek commented 4 months ago

Well, that would be the fastest fix. I did have the 3.8.4 version, I just checked github changelogs and not my nuget version :D Updated to 3.8.5 and it's gone.