Skip to content

Commit 6ff4c3e

Browse files
authored
Merge pull request kekekeks#134 from grokys/fixes/xstatic-fields-derived
Fix `x:Static` not searching base classes for fields.
2 parents 2597a8d + 6a48322 commit 6ff4c3e

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/XamlX/Ast/Intrinsics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public XamlILNodeEmitResult Emit(XamlEmitContext<IXamlILEmitter, XamlILNodeEmitR
113113
internal IXamlMember? ResolveMember(bool throwOnUnknown)
114114
{
115115
var type = TargetType?.GetClrType();
116-
var member = type?.Fields.FirstOrDefault(f => f.IsPublic && f.IsStatic && f.Name == Member) ??
116+
var member = type?.GetAllFields().FirstOrDefault(f => f.IsPublic && f.IsStatic && f.Name == Member) ??
117117
(IXamlMember?)type?.GetAllProperties().FirstOrDefault(p =>
118118
p.Name == Member && p.Getter is { IsPublic: true, IsStatic: true });
119119

tests/XamlParserTests/IntrinsicsTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class IntrinsicsTestsClass
2121
public const double DoubleConstant = 3;
2222
}
2323

24+
public class IntrinsicsTestsDerivedClass : IntrinsicsTestsClass;
25+
2426
public class IntrinsicsListTestsClass
2527
{
2628
internal int AddInt32CallCount;
@@ -93,6 +95,8 @@ public void Type_Extension_Resolves_Types(Type expectedType, string typeExt)
9395
InlineData(100, "IntrinsicsTestsClass.IntConstant"),
9496
InlineData(2f, "IntrinsicsTestsClass.FloatConstant"),
9597
InlineData(3d, "IntrinsicsTestsClass.DoubleConstant"),
98+
InlineData("StaticPropValue", "IntrinsicsTestsDerivedClass.StaticProp"),
99+
InlineData("StaticFieldValue", "IntrinsicsTestsDerivedClass.StaticField"),
96100
]
97101
public void Static_Extension_Resolves_Values(object expected, string r)
98102
{

0 commit comments

Comments
 (0)