2020-06-30 12:49:37 +02:00
|
|
|
include::../rule.adoc[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2022-07-29 10:45:19 +02:00
|
|
|
[source,csharp]
|
|
|
|
----
|
|
|
|
using System;
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2022-07-29 10:45:19 +02:00
|
|
|
public class MyAttribute: Attribute // Noncompliant
|
|
|
|
{
|
|
|
|
public string Name { get; }
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2022-07-29 10:45:19 +02:00
|
|
|
public MyAttribute(string name) =>
|
|
|
|
Name = name;
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2022-07-29 10:45:19 +02:00
|
|
|
|
|
|
|
[source,csharp]
|
|
|
|
----
|
|
|
|
using System;
|
|
|
|
|
|
|
|
public sealed class MyAttribute : Attribute
|
|
|
|
{
|
|
|
|
public string Name { get; }
|
|
|
|
|
|
|
|
public MyAttribute(string name) =>
|
|
|
|
Name = name;
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
include::../rspecator.adoc[]
|