This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/FishNet/CodeGenerating/Helpers/Extension/FieldReferenceExtensions.cs

38 lines
1.0 KiB
C#
Raw Normal View History

2023-05-31 17:32:21 +02:00
using FishNet.CodeGenerating.Extension;
using MonoFN.Cecil;
namespace FishNet.CodeGenerating.Helping.Extension
{
internal static class FieldReferenceExtensions
{
/// <summary>
/// Gets a Resolve favoring cached results first.
/// </summary>
internal static FieldDefinition CachedResolve(this FieldReference fieldRef, CodegenSession session)
{
return session.GetClass<GeneralHelper>().GetFieldReferenceResolve(fieldRef);
}
public static FieldReference MakeHostGenericIfNeeded(this FieldDefinition fd, CodegenSession session)
{
TypeReference declaringTr = fd.DeclaringType;
if (declaringTr.HasGenericParameters)
{
GenericInstanceType git = declaringTr.MakeGenericInstanceType();
FieldReference result = new FieldReference(fd.Name, fd.FieldType, git);
return result;
}
else
{
return session.ImportReference(fd);
}
}
}
}