Skip to content

Commit

Permalink
fix: Add Assembly full name
Browse files Browse the repository at this point in the history
  • Loading branch information
workgroupengineering committed Apr 16, 2024
1 parent 685a82c commit a22da07
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static string GetVisualSelector(Visual visual)
.Where(c => !c.StartsWith(":"))
.Select(c => '.' + c));
var type = StyledElement.GetStyleKey(visual);
return $$"""{{{type.Namespace}}}.{{type.Name}}{{name}}{{classes}}""";
return $$"""{{{type.Assembly.FullName}};{{type.Namespace}}.}{{type.Name}}{{name}}{{classes}}""";
}

private void ExpandNode(TreeNode? node)
Expand Down
32 changes: 29 additions & 3 deletions src/Avalonia.Diagnostics/Diagnostics/Views/TreePageView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,38 @@ private void OnClipboardCopyRequested(object? sender, string selector)
if (TopLevel.GetTopLevel(this)?.Clipboard is { } clipboard)
{
var @do = new DataObject();
@do.Set(DataFormats.Text, selector
.Replace("{",string.Empty)
.Replace("}",string.Empty));
var text = ToText(selector);
@do.Set(DataFormats.Text, text);
@do.Set(Constants.DataFormats.Avalonia_DevTools_Selector, selector);
clipboard.SetDataObjectAsync(@do);
}
}

private static string ToText(string text)
{
var sb = new System.Text.StringBuilder();
var bufferStartIndex = -1;
for (var ic = 0; ic < text.Length; ic++)
{
var c = text[ic];
switch (c)
{
case '{':
bufferStartIndex = sb.Length;
break;
case '}':
bufferStartIndex = -1;
break;
case ';' when bufferStartIndex > -1:
sb.Remove(bufferStartIndex, sb.Length - bufferStartIndex);
bufferStartIndex = sb.Length;
break;
default:
sb.Append(c);
break;
}
}
return sb.ToString();
}
}
}

0 comments on commit a22da07

Please sign in to comment.