![JAR search and dependency download from the Maven repository](/logo.png)
org.sonar.plugins.csharp.S4060.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonarlint-omnisharp-plugin Show documentation
Show all versions of sonarlint-omnisharp-plugin Show documentation
Code Analyzer based on Omnisharp
Why is this an issue?
The .NET framework class library provides methods for retrieving custom attributes. Sealing the attribute eliminates the search through the
inheritance hierarchy, and can improve performance.
This rule raises an issue when a public type inherits from System.Attribute
, is not abstract, and is not sealed.
Noncompliant code example
using System;
public class MyAttribute: Attribute // Noncompliant
{
public string Name { get; }
public MyAttribute(string name) =>
Name = name;
}
Compliant solution
using System;
public sealed class MyAttribute : Attribute
{
public string Name { get; }
public MyAttribute(string name) =>
Name = name;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy