зеркало из https://github.com/DeGsoft/maui-linux.git
[X] avoid throwing in VisualDiagnostics (#7571)
this fixes a regression introduced in #7474 - fixes #7570
This commit is contained in:
Родитель
f417a8743e
Коммит
66b32f6f04
|
@ -346,22 +346,28 @@ namespace Xamarin.Forms.Xaml
|
|||
|
||||
//If it's a BindableProberty, SetValue
|
||||
if (xpe == null && TrySetValue(xamlelement, property, attached, value, lineInfo, serviceProvider, out xpe)) {
|
||||
VisualDiagnostics.RegisterSourceInfo(value, null, ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
|
||||
VisualDiagnostics.SendVisualTreeChanged(xamlelement, value);
|
||||
if (!(node is ValueNode) && value != null && !value.GetType().GetTypeInfo().IsValueType && XamlFilePathAttribute.GetFilePathForObject(context.RootElement) is string path) {
|
||||
VisualDiagnostics.RegisterSourceInfo(value, new Uri(path, UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
|
||||
VisualDiagnostics.SendVisualTreeChanged(xamlelement, value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//If we can assign that value to a normal property, let's do it
|
||||
if (xpe == null && TrySetProperty(xamlelement, localName, value, lineInfo, serviceProvider, context, out xpe)) {
|
||||
VisualDiagnostics.RegisterSourceInfo(value, null, ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
|
||||
VisualDiagnostics.SendVisualTreeChanged(xamlelement, value);
|
||||
if (!(node is ValueNode) && value != null && !value.GetType().GetTypeInfo().IsValueType && XamlFilePathAttribute.GetFilePathForObject(context.RootElement) is string path) {
|
||||
VisualDiagnostics.RegisterSourceInfo(value, new Uri(path, UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
|
||||
VisualDiagnostics.SendVisualTreeChanged(xamlelement, value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//If it's an already initialized property, add to it
|
||||
if (xpe == null && TryAddToProperty(xamlelement, propertyName, value, xKey, lineInfo, serviceProvider, context, out xpe)) {
|
||||
VisualDiagnostics.RegisterSourceInfo(value, null, ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
|
||||
VisualDiagnostics.SendVisualTreeChanged(xamlelement, value);
|
||||
if (!(node is ValueNode) && value != null && !value.GetType().GetTypeInfo().IsValueType && XamlFilePathAttribute.GetFilePathForObject(context.RootElement) is string path) {
|
||||
VisualDiagnostics.RegisterSourceInfo(value, new Uri(path, UriKind.Relative), ((IXmlLineInfo)node).LineNumber, ((IXmlLineInfo)node).LinePosition);
|
||||
VisualDiagnostics.SendVisualTreeChanged(xamlelement, value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@ namespace Xamarin.Forms.Xaml.Diagnostics
|
|||
{
|
||||
static class DebuggerHelper
|
||||
{
|
||||
#if DEBUG
|
||||
static DebuggerHelper() => _mockDebuggerIsAttached = true;
|
||||
#endif
|
||||
|
||||
internal static bool _mockDebuggerIsAttached;
|
||||
public static bool DebuggerIsAttached => _mockDebuggerIsAttached || Debugger.IsAttached;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Xamarin.Forms.Xaml.Diagnostics
|
|||
static ConditionalWeakTable<object, XamlSourceInfo> sourceInfos = new ConditionalWeakTable<object, XamlSourceInfo>();
|
||||
internal static void RegisterSourceInfo(object target, Uri uri, int lineNumber, int linePosition)
|
||||
{
|
||||
if (DebuggerHelper.DebuggerIsAttached)
|
||||
if (DebuggerHelper.DebuggerIsAttached && !sourceInfos.TryGetValue(target, out _))
|
||||
sourceInfos.Add(target, new XamlSourceInfo(uri, lineNumber, linePosition));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче