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
co-authored by metalgearsloth metalgearsloth
parent ec768c563f
commit de4d255841
593 changed files with 1165 additions and 829 deletions
@@ -3,6 +3,7 @@ using Moq;
using NUnit.Framework;
using Robust.Server.ViewVariables;
using Robust.Server.ViewVariables.Traits;
using Robust.Shared.Analyzers;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -10,7 +11,7 @@ namespace Robust.UnitTesting.Server.ViewVariables
{
[Parallelizable]
[TestFixture]
internal class ViewVariablesTraitMembersTest
internal sealed class ViewVariablesTraitMembersTest
{
[Test]
public void Test()
@@ -40,22 +41,24 @@ namespace Robust.UnitTesting.Server.ViewVariables
Assert.That(group0.groupMembers[0].Name, Is.EqualTo("Y"));
Assert.That(group0.groupMembers[1].Name, Is.EqualTo("Z"));
Assert.That(group1.groupMembers[0].Name, Is.EqualTo("X"));
}
#pragma warning disable 649
[Virtual]
private class A
{
[ViewVariables] public int X;
}
[Virtual]
private class B : A
{
public int Hidden { get; set; }
}
private class C : B
private sealed class C : B
{
[ViewVariables] public int Y { get; set; }
[ViewVariables] public string? Z { get; set; }