mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
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:
committed by
GitHub
parent
ec768c563f
commit
de4d255841
@@ -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;
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ using System;
|
||||
namespace Robust.Shared.Analyzers
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Interface)]
|
||||
public class RequiresExplicitImplementationAttribute : Attribute { }
|
||||
public sealed class RequiresExplicitImplementationAttribute : Attribute { }
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ using System;
|
||||
namespace Robust.Shared.Analyzers
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class RequiresSerializableAttribute : Attribute { }
|
||||
public sealed class RequiresSerializableAttribute : Attribute { }
|
||||
}
|
||||
|
||||
15
Robust.Shared/Analyzers/VirtualAttribute.cs
Normal file
15
Robust.Shared/Analyzers/VirtualAttribute.cs
Normal 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
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user