-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metadata for Injected Properties #19
Comments
internal static class PropertyInjector
{
public static void InjectFullProperty(ClassGroupBase group, TypeSignature propertySignature, string propertyName, bool nullable)
{
InjectedInterfaceProperty interfaceProperty;
{
PropertyDefinition property = group.Interface.AddFullProperty(propertyName, InterfaceUtils.InterfacePropertyDeclaration, propertySignature);
if (nullable)
{
property.AddNullableAttributesForMaybeNull();
}
interfaceProperty = new InjectedInterfaceProperty(property, group);
group.InterfaceProperties.Add(interfaceProperty);
}
foreach (GeneratedClassInstance instance in group.Instances)
{
TypeDefinition type = instance.Type;
FieldDefinition field = type.AddField(propertySignature, $"m_{propertyName}");
PropertyDefinition property = type.ImplementFullProperty(propertyName, InterfaceUtils.InterfacePropertyImplementation, null, field);
if (nullable)
{
field.AddNullableAttributesForMaybeNull();
property.AddNullableAttributesForMaybeNull();
}
instance.Properties.Add(new InjectedClassProperty(property, field, interfaceProperty, instance));
}
}
private sealed class InjectedInterfaceProperty : InterfaceProperty
{
public InjectedInterfaceProperty(PropertyDefinition definition, ClassGroupBase group) : base(definition, group)
{
}
public override bool IsInjected => true;
}
private sealed class InjectedClassProperty : ClassProperty
{
public InjectedClassProperty(PropertyDefinition definition, FieldDefinition backingField, InjectedInterfaceProperty @base, GeneratedClassInstance @class) : base(definition, backingField, @base, @class)
{
}
public override bool IsInjected => true;
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Motivation
Injected properties currently can't be (easily) used outside the pass they're created in. This prevents them from being used in other passes, such as the equality comparison pass.
Design Concept
Other considerations
Existing properties on
UnityAssetBase
andUnityObjectBase
may need metadata, too.The text was updated successfully, but these errors were encountered: