.NET Format Style Fixes
This commit is contained in:
@@ -27,35 +27,76 @@ public class CodeGenerator
|
||||
return new CodeInstruction(code.OpCode) { labels = GetLabelList(code) };
|
||||
}
|
||||
|
||||
if (code.OpCode == OpCodes.Ldfld || code.OpCode == OpCodes.Ldflda || code.OpCode == OpCodes.Stfld)
|
||||
if (
|
||||
code.OpCode == OpCodes.Ldfld
|
||||
|| code.OpCode == OpCodes.Ldflda
|
||||
|| code.OpCode == OpCodes.Stfld
|
||||
)
|
||||
{
|
||||
return new CodeInstruction(code.OpCode, AccessTools.Field(code.CallerType, code.OperandTarget as string)) { labels = GetLabelList(code) };
|
||||
return new CodeInstruction(
|
||||
code.OpCode,
|
||||
AccessTools.Field(code.CallerType, code.OperandTarget as string)
|
||||
)
|
||||
{
|
||||
labels = GetLabelList(code),
|
||||
};
|
||||
}
|
||||
|
||||
if (code.OpCode == OpCodes.Call || code.OpCode == OpCodes.Callvirt)
|
||||
{
|
||||
return new CodeInstruction(code.OpCode, AccessTools.Method(code.CallerType, code.OperandTarget as string, code.Parameters)) { labels = GetLabelList(code) };
|
||||
return new CodeInstruction(
|
||||
code.OpCode,
|
||||
AccessTools.Method(code.CallerType, code.OperandTarget as string, code.Parameters)
|
||||
)
|
||||
{
|
||||
labels = GetLabelList(code),
|
||||
};
|
||||
}
|
||||
|
||||
if (code.OpCode == OpCodes.Box)
|
||||
{
|
||||
return new CodeInstruction(code.OpCode, code.CallerType) { labels = GetLabelList(code) };
|
||||
return new CodeInstruction(code.OpCode, code.CallerType)
|
||||
{
|
||||
labels = GetLabelList(code),
|
||||
};
|
||||
}
|
||||
|
||||
if (code.OpCode == OpCodes.Br || code.OpCode == OpCodes.Brfalse || code.OpCode == OpCodes.Brtrue || code.OpCode == OpCodes.Brtrue_S
|
||||
|| code.OpCode == OpCodes.Brfalse_S || code.OpCode == OpCodes.Br_S)
|
||||
if (
|
||||
code.OpCode == OpCodes.Br
|
||||
|| code.OpCode == OpCodes.Brfalse
|
||||
|| code.OpCode == OpCodes.Brtrue
|
||||
|| code.OpCode == OpCodes.Brtrue_S
|
||||
|| code.OpCode == OpCodes.Brfalse_S
|
||||
|| code.OpCode == OpCodes.Br_S
|
||||
)
|
||||
{
|
||||
return new CodeInstruction(code.OpCode, code.OperandTarget) { labels = GetLabelList(code) };
|
||||
return new CodeInstruction(code.OpCode, code.OperandTarget)
|
||||
{
|
||||
labels = GetLabelList(code),
|
||||
};
|
||||
}
|
||||
|
||||
if (code.OpCode == OpCodes.Ldftn)
|
||||
{
|
||||
return new CodeInstruction(code.OpCode, AccessTools.Method(code.CallerType, code.OperandTarget as string, code.Parameters)) { labels = GetLabelList(code) };
|
||||
return new CodeInstruction(
|
||||
code.OpCode,
|
||||
AccessTools.Method(code.CallerType, code.OperandTarget as string, code.Parameters)
|
||||
)
|
||||
{
|
||||
labels = GetLabelList(code),
|
||||
};
|
||||
}
|
||||
|
||||
if (code.OpCode == OpCodes.Newobj)
|
||||
{
|
||||
return new CodeInstruction(code.OpCode, code.CallerType.GetConstructors().FirstOrDefault(x => x.GetParameters().Length == code.Parameters.Length)) { labels = GetLabelList(code) };
|
||||
return new CodeInstruction(
|
||||
code.OpCode,
|
||||
code.CallerType.GetConstructors()
|
||||
.FirstOrDefault(x => x.GetParameters().Length == code.Parameters.Length)
|
||||
)
|
||||
{
|
||||
labels = GetLabelList(code),
|
||||
};
|
||||
}
|
||||
|
||||
throw new ArgumentException($"Code with OpCode {code.OpCode.ToString()} is not supported.");
|
||||
@@ -68,6 +109,6 @@ public class CodeGenerator
|
||||
return [];
|
||||
}
|
||||
|
||||
return [ (Label)code.GetLabel() ];
|
||||
return [(Label)code.GetLabel()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,22 +6,32 @@ public class CodeWithLabel : Code
|
||||
{
|
||||
public Label Label { get; }
|
||||
|
||||
public CodeWithLabel(OpCode opCode, Label label) : base(opCode)
|
||||
public CodeWithLabel(OpCode opCode, Label label)
|
||||
: base(opCode)
|
||||
{
|
||||
Label = label;
|
||||
}
|
||||
|
||||
public CodeWithLabel(OpCode opCode, Label label, object operandTarget) : base(opCode, operandTarget)
|
||||
public CodeWithLabel(OpCode opCode, Label label, object operandTarget)
|
||||
: base(opCode, operandTarget)
|
||||
{
|
||||
Label = label;
|
||||
}
|
||||
|
||||
public CodeWithLabel(OpCode opCode, Label label, Type callerType) : base(opCode, callerType)
|
||||
public CodeWithLabel(OpCode opCode, Label label, Type callerType)
|
||||
: base(opCode, callerType)
|
||||
{
|
||||
Label = label;
|
||||
}
|
||||
|
||||
public CodeWithLabel(OpCode opCode, Label label, Type callerType, object operandTarget, Type[] parameters = null) : base(opCode, callerType, operandTarget, parameters)
|
||||
public CodeWithLabel(
|
||||
OpCode opCode,
|
||||
Label label,
|
||||
Type callerType,
|
||||
object operandTarget,
|
||||
Type[] parameters = null
|
||||
)
|
||||
: base(opCode, callerType, operandTarget, parameters)
|
||||
{
|
||||
Label = label;
|
||||
}
|
||||
|
||||
@@ -25,13 +25,17 @@ public abstract class AbstractPatch
|
||||
_finalizerList = GetPatchMethods(typeof(PatchFinalizerAttribute));
|
||||
_ilManipulatorList = GetPatchMethods(typeof(PatchIlManipulatorAttribute));
|
||||
|
||||
if (_prefixList.Count == 0
|
||||
if (
|
||||
_prefixList.Count == 0
|
||||
&& _postfixList.Count == 0
|
||||
&& _transpilerList.Count == 0
|
||||
&& _finalizerList.Count == 0
|
||||
&& _ilManipulatorList.Count == 0)
|
||||
&& _ilManipulatorList.Count == 0
|
||||
)
|
||||
{
|
||||
throw new Exception($"{_harmony.Id}: At least one of the patch methods must be specified");
|
||||
throw new Exception(
|
||||
$"{_harmony.Id}: At least one of the patch methods must be specified"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +55,14 @@ public abstract class AbstractPatch
|
||||
var T = GetType();
|
||||
var methods = new List<HarmonyMethod>();
|
||||
|
||||
foreach (var method in T.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public |
|
||||
BindingFlags.DeclaredOnly))
|
||||
foreach (
|
||||
var method in T.GetMethods(
|
||||
BindingFlags.Static
|
||||
| BindingFlags.NonPublic
|
||||
| BindingFlags.Public
|
||||
| BindingFlags.DeclaredOnly
|
||||
)
|
||||
)
|
||||
{
|
||||
if (method.GetCustomAttribute(attributeType) != null)
|
||||
{
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
namespace SPTarkov.Reflection.Patching
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class PatchPrefixAttribute : Attribute
|
||||
{
|
||||
}
|
||||
public class PatchPrefixAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class PatchPostfixAttribute : Attribute
|
||||
{
|
||||
}
|
||||
public class PatchPostfixAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class PatchTranspilerAttribute : Attribute
|
||||
{
|
||||
}
|
||||
public class PatchTranspilerAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class PatchFinalizerAttribute : Attribute
|
||||
{
|
||||
}
|
||||
public class PatchFinalizerAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class PatchIlManipulatorAttribute : Attribute
|
||||
{
|
||||
}
|
||||
public class PatchIlManipulatorAttribute : Attribute { }
|
||||
}
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\Build.props"/>
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageId>SPTarkov.Reflection</PackageId>
|
||||
<Authors>Single Player Tarkov</Authors>
|
||||
<Description>Reflection library for the Single Player Tarkov server.</Description>
|
||||
<Copyright>Copyright (c) Single Player Tarkov 2025</Copyright>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageProjectUrl>https://sp-tarkov.com</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/sp-tarkov/server-csharp</RepositoryUrl>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<OutputType>Library</OutputType>
|
||||
<IsPackable>true</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="..\..\LICENSE" Pack="true" Visible="false" PackagePath=""/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HarmonyX" Version="2.14.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\..\Build.props" />
|
||||
<PropertyGroup>
|
||||
<PackageId>SPTarkov.Reflection</PackageId>
|
||||
<Authors>Single Player Tarkov</Authors>
|
||||
<Description>Reflection library for the Single Player Tarkov server.</Description>
|
||||
<Copyright>Copyright (c) Single Player Tarkov 2025</Copyright>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageProjectUrl>https://sp-tarkov.com</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/sp-tarkov/server-csharp</RepositoryUrl>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<OutputType>Library</OutputType>
|
||||
<IsPackable>true</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\LICENSE" Pack="true" Visible="false" PackagePath="" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HarmonyX" Version="2.14.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user