remove QSB reference from weaver

This commit is contained in:
JohnCorby 2022-01-14 01:31:09 -08:00
parent fd6519f104
commit 15f68f19ad
2 changed files with 15 additions and 4 deletions

View File

@ -7,6 +7,5 @@
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.125" IncludeAssets="compile" />
<ProjectReference Include="..\Mirror\Mirror.csproj" />
<ProjectReference Include="..\QSB\QSB.csproj" />
</ItemGroup>
</Project>

View File

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
using QSB.Messaging;
namespace Mirror.Weaver
{
@ -209,8 +208,21 @@ namespace Mirror.Weaver
return null;
}
public static bool IsQSBMessageType(this TypeDefinition typeDefinition) =>
typeDefinition.IsDerivedFrom<QSBMessage>() || typeDefinition.IsDerivedFrom<QSBMessageRaw>();
public static bool IsQSBMessageType(this TypeDefinition td)
{
if (!td.IsClass) return false;
while (true)
{
var parent = td.BaseType;
if (parent == null) return false;
if (parent.FullName is "QSB.Messaging.QSBMessage" or "QSB.Messaging.QSBMessageRaw")
return true;
if (!parent.CanBeResolved()) return false;
td = parent.Resolve();
}
}
// Finds public fields in type and base type
public static IEnumerable<FieldDefinition> FindAllPublicFields(this TypeReference variable)