StackTraceHelper Code Analysis 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
StackTraceHelper is a public type, so we should make these Roslyn analyzer rules part of our public analyzers. Alternatively, if we feel like this type should not be public, we can move these to our dev analyzers instead. This type does not exist in Lucene.
- For `StackTraceHelper.DoesStackTraceContainMethod(string className, string methodName)`, warn if the className argument does not use the `nameof` operator, and likewise for methodName. There are some legitimate uses of this that can be suppressed, but it should be done deliberately.
- Similar to the one above, error if the className and methodName are constant expressions (like nameof) and the method does not exist on the type. This will help prevent accidentally referencing a method that would result in the call always being false.
- Warn if methods referenced by these calls (via constant expressions like nameof) are not marked `[MethodImpl(MethodImplOptions.NoInlining)]` if the method body is not empty (overlaps with #1097)
Contributor guide
Research direction
Start at StackTraceHelper.DoesStackTraceContainMethod(string className, string methodName) and inspect how the existing Roslyn rules are organized between public and dev analyzers. Determine how the three requested diagnostics relate to #1097, then verify that the chosen analyzer placement, nameof checks, method-existence checks, and NoInlining warnings are covered by analyzer tests.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100