Skip to content

Modify rule S3236: Add rule exception #4964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions rules/S3236/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
== Why is this an issue?

Caller information attributes: ``++CallerFilePathAttribute++``, ``++CallerLineNumberAttribute++``, and ``++CallerArgumentExpressionAttribute++`` provide a way to get information about the caller of a method through optional parameters. But the arguments for these optional parameters are only generated if they are not explicitly defined in the call. Thus, specifying the argument values defeats the purpose of the attributes.
Caller information attributes: `CallerFilePathAttribute`, `CallerLineNumberAttribute`, and `CallerArgumentExpressionAttribute` provide a way to get information about the caller of a method through optional parameters. But the arguments for these optional parameters are only generated if they are not explicitly defined in the call. Thus, specifying the argument values defeats the purpose of the attributes.


=== Noncompliant code example
Expand Down Expand Up @@ -41,5 +41,6 @@ void MyMethod()

=== Exceptions

``++CallerMemberName++`` is not checked to avoid False-Positives with WPF/UWP applications.

`CallerMemberName` is not checked to avoid False-Positives with WPF/UWP applications.
`System.Diagnostics.Debug.Assert` is excluded. The signature of this method has been updated from .NET9 onwards from `public static void Assert(bool condition, string message)` to `public static void Assert([DoesNotReturnIf(false)] bool condition, [CallerArgumentExpression(nameof(condition))] string? message = null)`.
The default message provided by this method is the failed assertion and its position in the code, however a custom message from the developer is many times preferred as an explanation of the failed assertion.