diff --git a/analyzers/rspec/cs/S3993.html b/analyzers/rspec/cs/S3993.html index dbb59261656..7ed722a6f0d 100644 --- a/analyzers/rspec/cs/S3993.html +++ b/analyzers/rspec/cs/S3993.html @@ -1,55 +1,48 @@

Why is this an issue?

-

When defining custom attributes, System.AttributeUsageAttribute must be used to indicate where the attribute can be applied. This will -determine its valid locations in the code.

-

Noncompliant code example

-
-using System;
-
-namespace MyLibrary
+

When defining custom attributes, AttributeUsageAttribute +must be used to indicate where the attribute can be applied. This will:

+ +

How to fix it

+

Code examples

+

Noncompliant code example

+
+public sealed class MyAttribute : Attribute // Noncompliant - AttributeUsage is missing
 {
+    private string text;
 
-   public sealed class MyAttribute :Attribute // Noncompliant
-   {
-      string text;
+    public MyAttribute(string text)
+    {
+        this.text = text;
+    }
 
-      public MyAttribute(string myText)
-      {
-         text = myText;
-      }
-      public string Text
-      {
-         get
-         {
-            return text;
-         }
-      }
-   }
+    public string Text => text;
 }
 
-

Compliant solution

-
-using System;
-
-namespace MyLibrary
+

Compliant solution

+
+[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Delegate)]
+public sealed class MyAttribute : Attribute
 {
+    private string text;
 
-   [AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Delegate)]
-   public sealed class MyAttribute :Attribute
-   {
-      string text;
+    public MyAttribute(string text)
+    {
+        this.text = text;
+    }
 
-      public MyAttribute(string myText)
-      {
-         text = myText;
-      }
-      public string Text
-      {
-         get
-         {
-            return text;
-         }
-      }
-   }
+    public string Text => text;
 }
 
+

Resources

+

Documentation

+ diff --git a/analyzers/rspec/cs/Sonar_way_profile.json b/analyzers/rspec/cs/Sonar_way_profile.json index 3450e95492b..a014e25d37c 100644 --- a/analyzers/rspec/cs/Sonar_way_profile.json +++ b/analyzers/rspec/cs/Sonar_way_profile.json @@ -227,6 +227,7 @@ "S3973", "S3981", "S3984", + "S3993", "S3998", "S4015", "S4019",