From 68ec7a747e65dbb64785a026660c2deb12c9bc9d Mon Sep 17 00:00:00 2001 From: KarthikRajaKalaimani <92777139+KarthikRajaKalaimani@users.noreply.github.com> Date: Tue, 14 Jul 2026 12:39:36 +0530 Subject: [PATCH 1/2] Fixed the test case failure UsesReflectionBasedBindingsWhenCompilationOfBindingsWithSourceIsDisabled --- .../src/Build.Tasks/SetPropertiesVisitor.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs index 7fee80fb0f80..7f0a43a80bb7 100644 --- a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs +++ b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs @@ -532,7 +532,7 @@ static bool TryCompileBindingPath(ElementNode node, ILContext context, VariableD } TypeReference tSourceRef = null; - if (HasRelativeOrReferenceSource(node) && !xDataTypeIsOnBindingNode) + if (HasRelativeOrReferenceSource(node) && xDataTypeIsInOuterScope) { if (!TryGetRelativeSourceAncestorTypeReference(node, context, module, out tSourceRef)) { @@ -798,7 +798,7 @@ bool DoesNotInheritDataType(ElementNode node) } } - static bool TryParsePath(ILContext context, string path, TypeReference tSourceRef, IXmlLineInfo lineInfo, ModuleDefinition module, out IList<(PropertyDefinition property, TypeReference propDeclTypeRef, string indexArg)> pathProperties) + static bool TryParsePath(ILContext context, string path, TypeReference tSourceRef, IXmlLineInfo lineInfo, ModuleDefinition module, out IList<(PropertyDefinition property, TypeReference propDeclTypeRef, string indexArg)> pathProperties, bool suppressPropertyNotFoundWarning = false) { pathProperties = null; @@ -838,7 +838,14 @@ static bool TryParsePath(ILContext context, string path, TypeReference tSourceRe var property = previousPartTypeRef.GetProperty(context.Cache, pd => pd.Name == p && pd.GetMethod != null && pd.GetMethod.IsPublic && !pd.GetMethod.IsStatic, out var propDeclTypeRef); if (property is null) { - context.LoggingHelper.LogWarningOrError(BindingPropertyNotFound, context.XamlFilePath, lineInfo.LineNumber, lineInfo.LinePosition, 0, 0, p, previousPartTypeRef); + // For x:Reference-sourced bindings, resolving against the referenced + // element's actual type is a best-effort improvement over always falling + // back to reflection. If the path doesn't resolve against that type, we + // silently fall back to a reflection-based binding instead of emitting a + // new warning — these bindings were never compiled before, so emitting a + // warning here would be a regression in diagnostic noise. + if (!suppressPropertyNotFoundWarning) + context.LoggingHelper.LogWarningOrError(BindingPropertyNotFound, context.XamlFilePath, lineInfo.LineNumber, lineInfo.LinePosition, 0, 0, p, previousPartTypeRef); return false; } From 1e03e9d1e0e591a3612343320b404d31a90a145a Mon Sep 17 00:00:00 2001 From: KarthikRajaKalaimani <92777139+KarthikRajaKalaimani@users.noreply.github.com> Date: Tue, 14 Jul 2026 12:45:54 +0530 Subject: [PATCH 2/2] removed unwanted changes --- src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs index 7f0a43a80bb7..76075601ed02 100644 --- a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs +++ b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs @@ -798,7 +798,7 @@ bool DoesNotInheritDataType(ElementNode node) } } - static bool TryParsePath(ILContext context, string path, TypeReference tSourceRef, IXmlLineInfo lineInfo, ModuleDefinition module, out IList<(PropertyDefinition property, TypeReference propDeclTypeRef, string indexArg)> pathProperties, bool suppressPropertyNotFoundWarning = false) + static bool TryParsePath(ILContext context, string path, TypeReference tSourceRef, IXmlLineInfo lineInfo, ModuleDefinition module, out IList<(PropertyDefinition property, TypeReference propDeclTypeRef, string indexArg)> pathProperties) { pathProperties = null; @@ -838,14 +838,7 @@ static bool TryParsePath(ILContext context, string path, TypeReference tSourceRe var property = previousPartTypeRef.GetProperty(context.Cache, pd => pd.Name == p && pd.GetMethod != null && pd.GetMethod.IsPublic && !pd.GetMethod.IsStatic, out var propDeclTypeRef); if (property is null) { - // For x:Reference-sourced bindings, resolving against the referenced - // element's actual type is a best-effort improvement over always falling - // back to reflection. If the path doesn't resolve against that type, we - // silently fall back to a reflection-based binding instead of emitting a - // new warning — these bindings were never compiled before, so emitting a - // warning here would be a regression in diagnostic noise. - if (!suppressPropertyNotFoundWarning) - context.LoggingHelper.LogWarningOrError(BindingPropertyNotFound, context.XamlFilePath, lineInfo.LineNumber, lineInfo.LinePosition, 0, 0, p, previousPartTypeRef); + context.LoggingHelper.LogWarningOrError(BindingPropertyNotFound, context.XamlFilePath, lineInfo.LineNumber, lineInfo.LinePosition, 0, 0, p, previousPartTypeRef); return false; }