Analyzer to enforce classes to be either [Virtual], abstract, or sealed. (#2469)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Pieter-Jan Briers
2022-02-05 19:31:58 +01:00
committed by GitHub
parent ec768c563f
commit de4d255841
593 changed files with 1165 additions and 829 deletions

View File

@@ -3,7 +3,7 @@ using System;
namespace Robust.Shared.Analyzers
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct)]
public class FriendAttribute : Attribute
public sealed class FriendAttribute : Attribute
{
public readonly Type[] Friends;

View File

@@ -3,5 +3,5 @@ using System;
namespace Robust.Shared.Analyzers
{
[AttributeUsage(AttributeTargets.Interface)]
public class RequiresExplicitImplementationAttribute : Attribute { }
public sealed class RequiresExplicitImplementationAttribute : Attribute { }
}

View File

@@ -3,5 +3,5 @@ using System;
namespace Robust.Shared.Analyzers
{
[AttributeUsage(AttributeTargets.Class)]
public class RequiresSerializableAttribute : Attribute { }
public sealed class RequiresSerializableAttribute : Attribute { }
}

View File

@@ -0,0 +1,15 @@
using System;
namespace Robust.Shared.Analyzers;
/// <summary>
/// Specify that this class is allowed to be inherited.
/// </summary>
/// <remarks>
/// Robust uses analyzers to prevent accidental usage of non-sealed classes:
/// a class must be either marked [Virtual], abstract, or sealed.
/// </remarks>
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class VirtualAttribute : Attribute
{
}