2025-07-18 00:23:23 -05:00
|
|
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
|
using Microsoft.Iris.Markup;
|
2025-07-17 17:55:04 -05:00
|
|
|
using System.Linq.Expressions;
|
2025-07-18 00:23:23 -05:00
|
|
|
|
|
|
|
|
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
2025-07-17 17:55:04 -05:00
|
|
|
|
|
|
|
|
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-17 17:55:04 -05:00
|
|
|
{
|
2025-07-18 00:23:23 -05:00
|
|
|
var targetExpression = Target switch
|
2025-07-17 17:55:04 -05:00
|
|
|
{
|
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-17 17:55:04 -05:00
|
|
|
|
2025-07-18 00:23:23 -05:00
|
|
|
var propertyAccessExpression = MemberAccessExpression(CodeAnalysis.CSharp.SyntaxKind.SimpleMemberAccessExpression,
|
|
|
|
|
targetExpression, IdentifierName(Property.Name));
|
2025-07-17 17:55:04 -05:00
|
|
|
|
2025-07-18 00:23:23 -05:00
|
|
|
return propertyAccessExpression;
|
2025-07-17 17:55:04 -05:00
|
|
|
}
|
|
|
|
|
}
|