Code Monkey home page Code Monkey logo

Comments (6)

TickettEnterprises avatar TickettEnterprises commented on July 3, 2024 1

Have checked the configuration and both SA1300 and SX1309 are set to error.

However no error is shown for:

private const string _testing = "";

Only shown for

private const string _testing = "";
private string testing = "";

from stylecopanalyzers.

sharwell avatar sharwell commented on July 3, 2024

What about turning on SA1300 and SX1309?

from stylecopanalyzers.

TickettEnterprises avatar TickettEnterprises commented on July 3, 2024

What about turning on SA1300 and SX1309?

This would not work because what we are trying to achieve is:

Private const use PascalCase starting with capital.
But we still want non const privates to start with a _

Turning on SX1309 would mean all fields need to start with _.

from stylecopanalyzers.

sharwell avatar sharwell commented on July 3, 2024

The code for SX1309 seems to suggest otherwise:

case SyntaxKind.StaticKeyword:
case SyntaxKind.ConstKeyword:
// This analyzer only looks at instance fields.
return;

from stylecopanalyzers.

TickettEnterprises avatar TickettEnterprises commented on July 3, 2024

Have checked the configuration and both SA1300 and SX1309 are set to error.

However no error is shown for:

private const string _testing = "";

Only shown for

private const string _testing = "";
private string testing = "";

This is not the intended result, as outlined we want to enforce private const to start with Cap and not _.
And private to start with a _

from stylecopanalyzers.

CruseCtrl avatar CruseCtrl commented on July 3, 2024

What about using IDE1006 along with this in your .editorconfig:

dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = warning
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields
dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase

dotnet_naming_symbols.private_constant_fields.applicable_kinds = field
dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected
dotnet_naming_symbols.private_constant_fields.required_modifiers = const

dotnet_naming_style.pascalcase.required_prefix =
dotnet_naming_style.pascalcase.required_suffix =
dotnet_naming_style.pascalcase.word_separator =
dotnet_naming_style.pascalcase.capitalization = pascal_case

That seems to do what you want

(I'm using this .editorconfig file, which was made by one of my colleages)

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.