question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enforce good naming behavior in fields and properties

See original GitHub issue

Make sure that fields, properties and events are properly named. First, make sure that they’re not defined with a single character but also, that they respect the camelCase such as fields are to respect lowerCamelCase and properties are to respect UpperCamelCase. Warning level : Info Diagnostics : CC0016

As for test cases, this is straightfoward. The analyzer will verify FieldDeclarationSyntax, EventDeclarationSyntax, PropertyDeclarationSyntax and evaluate their ISymbol to find out their name. Then, a simple Regex for each of those syntax will either validate or invalidate the name that was retrieved within the ISymbol.

Basically, there would be six test case: one good and one bad foreach of the SyntaxNode that the analyzer has to evaluate. @giggio

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
thiagolunardicommented, Sep 3, 2015

And about sugest lowdash/underscore (‘_’) prefix for private fields?

0reactions
wmjordancommented, Feb 4, 2016

@thiagolunardi I agree with you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Are protected members/fields really that bad?
Are protected members/fields really that bad? No. They are way, way worse. As soon as a member is more accessible than private ,...
Read more >
NET documentation C# Coding Conventions
Rename properties when the property names in the result would be ambiguous. For example, if your query returns a customer name and a...
Read more >
Using Properties - C# Programming Guide
See how the get and set accessors implement read and write access and find out ... Unlike fields, properties aren't classified as variables....
Read more >
Should you use Fields or just Properties in C#? - ...
Short answer: Yes, when there is a need. Otherwise, use an Auto-Implemented Property getter and setter like private string Whatever { get; ...
Read more >
c# - Should I prefer properties with or without private fields?
Some (including me) consider auto properties with private accessor “good enough” for immutable properties. True, they may not be truly immutable ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found