mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-05 06:39:50 +00:00
remove tests : )
This commit is contained in:
parent
0aa347567e
commit
3c4b84d0fb
6
QSB.sln
6
QSB.sln
@ -5,8 +5,6 @@ VisualStudioVersion = 17.0.31903.59
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QSB", "QSB\QSB.csproj", "{1F00090A-C697-4C55-B401-192F3CFB9DC2}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QSB", "QSB\QSB.csproj", "{1F00090A-C697-4C55-B401-192F3CFB9DC2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QSBTests", "QSBTests\QSBTests.csproj", "{2FE8256C-0CB6-48F1-A4C0-5FA18A1846A3}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2569F98D-F671-42AA-82DE-505B05CDCEF2}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2569F98D-F671-42AA-82DE-505B05CDCEF2}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
@ -32,10 +30,6 @@ Global
|
|||||||
{1F00090A-C697-4C55-B401-192F3CFB9DC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1F00090A-C697-4C55-B401-192F3CFB9DC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1F00090A-C697-4C55-B401-192F3CFB9DC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1F00090A-C697-4C55-B401-192F3CFB9DC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1F00090A-C697-4C55-B401-192F3CFB9DC2}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1F00090A-C697-4C55-B401-192F3CFB9DC2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{2FE8256C-0CB6-48F1-A4C0-5FA18A1846A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{2FE8256C-0CB6-48F1-A4C0-5FA18A1846A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{2FE8256C-0CB6-48F1-A4C0-5FA18A1846A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{2FE8256C-0CB6-48F1-A4C0-5FA18A1846A3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{DA8A467E-15BA-456C-9034-6EB80BAF1FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{DA8A467E-15BA-456C-9034-6EB80BAF1FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{DA8A467E-15BA-456C-9034-6EB80BAF1FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{DA8A467E-15BA-456C-9034-6EB80BAF1FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{DA8A467E-15BA-456C-9034-6EB80BAF1FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DA8A467E-15BA-456C-9034-6EB80BAF1FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
@ -1,94 +0,0 @@
|
|||||||
using HarmonyLib;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Mono.Cecil;
|
|
||||||
using Mono.Cecil.Cil;
|
|
||||||
using Mono.Cecil.Rocks;
|
|
||||||
using MonoMod.Cil;
|
|
||||||
using MonoMod.Utils;
|
|
||||||
using QSB.Messaging;
|
|
||||||
using QSB.Utility;
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace QSBTests
|
|
||||||
{
|
|
||||||
[TestClass]
|
|
||||||
public class MessageTests
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMessages()
|
|
||||||
{
|
|
||||||
var module = ModuleDefinition.ReadModule("QSB.dll");
|
|
||||||
var messageTypes = typeof(QSBMessage).GetDerivedTypes();
|
|
||||||
|
|
||||||
var fromField = typeof(QSBMessage).GetField("From", Util.AllInstance);
|
|
||||||
var toField = typeof(QSBMessage).GetField("To", Util.AllInstance);
|
|
||||||
var objectIdField = typeof(QSBWorldObjectMessage<>).GetField("ObjectId", Util.AllInstance);
|
|
||||||
|
|
||||||
foreach (var type in messageTypes)
|
|
||||||
{
|
|
||||||
var fields = type.GetFields(Util.AllInstance)
|
|
||||||
.Select(x => module.ImportReference(x).Resolve());
|
|
||||||
|
|
||||||
var constructor = module.ImportReference(type.GetConstructors(Util.AllInstance).Single()).Resolve();
|
|
||||||
var serialize = module.ImportReference(type.GetMethod("Serialize", Util.AllInstance)).Resolve();
|
|
||||||
var deserialize = module.ImportReference(type.GetMethod("Deserialize", Util.AllInstance)).Resolve();
|
|
||||||
|
|
||||||
foreach (var field in fields)
|
|
||||||
{
|
|
||||||
if (!field.Is(fromField) && !field.Is(toField) && !field.Is(objectIdField))
|
|
||||||
{
|
|
||||||
constructor.CheckUses(field, Util.UseType.Store);
|
|
||||||
}
|
|
||||||
|
|
||||||
serialize.CheckUses(field, Util.UseType.Load);
|
|
||||||
deserialize.CheckUses(field, Util.UseType.Store);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Util
|
|
||||||
{
|
|
||||||
public static readonly BindingFlags AllInstance = AccessTools.all ^ BindingFlags.Static;
|
|
||||||
|
|
||||||
public enum UseType { Store, Load }
|
|
||||||
|
|
||||||
public static void CheckUses(this MethodDefinition method, FieldDefinition field, UseType useType)
|
|
||||||
{
|
|
||||||
Func<Instruction, bool> matches = useType switch
|
|
||||||
{
|
|
||||||
UseType.Store => x => x.MatchStfld(out var f) && f.Resolve() == field,
|
|
||||||
UseType.Load => i => (i.MatchLdfld(out var f) || i.MatchLdflda(out f)) && f.Resolve() == field,
|
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(useType), useType, null)
|
|
||||||
};
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var instructions = method.Body.Instructions;
|
|
||||||
var uses = instructions.Any(matches);
|
|
||||||
if (uses)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var baseMethod = method.GetBaseMethod();
|
|
||||||
if (baseMethod == method)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var callsBase = instructions.Any(x => x.MatchCall(out var m) && m.Resolve() == baseMethod);
|
|
||||||
if (!callsBase)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
method = baseMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.Fail($"{method} does not {useType} {field}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
<PropertyGroup>
|
|
||||||
<AssemblyTitle>QSBTests</AssemblyTitle>
|
|
||||||
<Product>QSBTests</Product>
|
|
||||||
<ProjectGuid>{2FE8256C-0CB6-48F1-A4C0-5FA18A1846A3}</ProjectGuid>
|
|
||||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
|
||||||
<IsCodedUITest>False</IsCodedUITest>
|
|
||||||
<TestProjectType>UnitTest</TestProjectType>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
|
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
|
|
||||||
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.168" />
|
|
||||||
<PackageReference Include="OWML" Version="2.3.2" />
|
|
||||||
<PackageReference Include="HarmonyX" Version="2.9.0" />
|
|
||||||
<ProjectReference Include="..\QSB\QSB.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
Loading…
x
Reference in New Issue
Block a user