2025-09-17 16:40:02 -07:00

29 lines
1023 B
C#

using AssetRipper.AssemblyDumper.Methods;
using AssetRipper.AssemblyDumper.Types;
namespace AssetRipper.AssemblyDumper.Passes;
internal static class PropertyInjector
{
public static void InjectFullProperty(ClassGroupBase group, TypeSignature propertySignature, string propertyName, bool nullable)
{
PropertyDefinition interfaceProperty = group.Interface.AddFullProperty(propertyName, InterfaceUtils.InterfacePropertyDeclaration, propertySignature);
if (nullable)
{
interfaceProperty.AddNullableAttributesForMaybeNull();
}
foreach (TypeDefinition type in group.Types)
{
FieldDefinition field = type.AddField($"m_{propertyName}", propertySignature, visibility: Visibility.Internal);
field.AddDebuggerBrowsableNeverAttribute();
PropertyDefinition property = type.ImplementFullProperty(propertyName, InterfaceUtils.InterfacePropertyImplementation, null, field);
if (nullable)
{
field.AddNullableAttributesForMaybeNull();
property.AddNullableAttributesForMaybeNull();
}
}
}
}