Modifiy S1144: Improve C# exception (#4005)

This commit is contained in:
Sebastien Marichal 2024-06-27 14:08:26 +02:00 committed by GitHub
parent 2d06669565
commit 90f15e5811
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
@ -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