Dev Analyzer: "Anonymous Class" naming and visibility rules
- Dominant language
- C#
- Stars
- 2.4k
- Forks
- 658
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 9
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Task description
We should add dev analyzer rules to help contributors catch issues around classes that were anonymous classes in Java in our codebase.
1. Per our project naming conventions, the type name should _end_ in "AnonymousClass", optionally followed by one or more digits. i.e. ThreadAnonymousClass, ThreadAnonymousClass1, and ThreadAnonymousClass123 are all valid, but AnonymousClassThread and ThreadAnonymousClassForSomeTest are not valid.
2. The type should be `private` and `sealed` (unless there is some good reason otherwise which could be suppressed).
3. All fields on this type should be `private`.
These rules should fire if "AnonymousClass" appears anywhere in the type name.
(Another option, and could be broken out separately: we could also have a custom attribute that indicates that it maps to an anonymous class in Java. This would help us apply extra scrutiny in analysis to these types, and might even let us drop the conventional name suffix at a later time if we wanted.)
Related: #666, #715
Contributor guide
Research direction
Start by locating the project's existing dev analyzer rules and their tests, then review related issues #666 and #715 for conventions. The work is done when types containing "AnonymousClass" enforce the specified name suffix, private and sealed visibility, and private fields, with an appropriate suppression path for exceptions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100