Skip to content

Modifiy S1144: Improve C# exception #4005

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 2 commits into from
Jun 27, 2024
Merged
Changes from all commits
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
26 changes: 13 additions & 13 deletions rules/S1144/csharp/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@

include::../why.adoc[]

=== Exceptions

This rule doesn't raise issues on:

* empty constructors
* members with attributes
* the `Main` method of the application
* `void` methods with two parameters when the second parameter type derives from https://learn.microsoft.com/en-us/dotnet/api/system.eventargs[EventArgs]
* empty serialization constructor on type with https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute[System.SerializableAttribute] attribute.
* field and property members of types marked with https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute[System.SerializableAttribute] attribute
* internal members in assemblies that have a https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.internalsvisibletoattribute[System.Runtime.CompilerServices.InternalsVisibleToAttribute] attribute.
* types and members decorated with the https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute] attribute (available in .NET 5.0+) or a custom attribute named `DynamicallyAccessedMembersAttribute`.

=== Code examples

==== Noncompliant code example
Expand Down Expand Up @@ -37,19 +50,6 @@ public class Foo
}
----

=== Exceptions

This rule doesn't raise issues on:

* empty constructors
* members with attributes
* the `Main` method of the application
* methods with event handler signature `void Foo(object, EventArgs)` that are declared in partial class
* empty serialization constructor on type with https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute[System.SerializableAttribute] attribute.
* field and property members of types marked with https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute[System.SerializableAttribute] attribute
* internal members in assemblies that have a https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.internalsvisibletoattribute[System.Runtime.CompilerServices.InternalsVisibleToAttribute] attribute.
* types and members decorated with the https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.dynamicallyaccessedmembersattribute[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute] attribute (available in .NET 5.0+) or a custom attribute named `DynamicallyAccessedMembersAttribute`.

== Resources

=== Documentation
Expand Down