Files
ZuneUIXTools/libs/UIX.DecompXml/Mock/IrisPropertyExpression.cs
T

40 lines
1.2 KiB
C#
Raw Normal View History

2025-07-18 00:23:23 -05:00
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.Iris.Markup;
using System.Linq.Expressions;
2025-07-18 00:23:23 -05:00
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
namespace Microsoft.Iris.DecompXml.Mock;
internal class IrisPropertyExpression : IrisExpression, IReturnValueProvider
{
public IrisPropertyExpression(PropertySchema property, Expression? target)
{
Property = property;
Target = target;
}
public new PropertySchema Property { get; }
public sealed override ExpressionType NodeType => ExpressionType.MemberAccess;
public Expression? Target { get; }
public TypeSchema ReturnType => Property.PropertyType;
2025-07-18 00:23:23 -05:00
public override ExpressionSyntax ToSyntax(DecompileContext context)
{
2025-07-18 00:23:23 -05:00
var targetExpression = Target switch
{
2025-07-18 00:23:23 -05:00
null => IdentifierName(context.GetQualifiedName(Property.Owner).ToString()),
IrisExpression irisExpr => irisExpr.ToSyntax(context),
_ => IdentifierName(Target.ToString())
};
2025-07-18 00:23:23 -05:00
var propertyAccessExpression = MemberAccessExpression(CodeAnalysis.CSharp.SyntaxKind.SimpleMemberAccessExpression,
targetExpression, IdentifierName(Property.Name));
2025-07-18 00:23:23 -05:00
return propertyAccessExpression;
}
}