Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Xaml.VisualDiagnostics to Maui.Core #4333

Conversation

drasticactions
Copy link
Contributor

The current VisualDiagnostics stack is used for XAML Hot Reload, for holding the "XamlSourceInfo" and firing Visual Tree changes. While this works for the general MAUI use case, it won't work for anyone who uses MAUI.Core and not MAUI.Controls.

As these APIs are not XAML specific and can be used in a more general case, we can move these static classes down to Maui.Core, which should enable anyone to fire Visual Tree changes and register source info, which should let more MAUI implementations to get XET support.

@drasticactions drasticactions added the partner/ui-tools .NET UI Tools label Jan 26, 2022
# Conflicts:
#	src/Controls/src/Core/Xaml/Diagnostics/BindingErrorEventArgs.cs
#	src/Controls/src/Core/Xaml/Diagnostics/XamlSourceInfo.cs
#	src/Core/src/VisualDiagnostics/VisualDiagnostics.cs
#	src/Core/src/VisualDiagnostics/VisualTreeChangeEventArgs.cs
@StephaneDelcroix
Copy link
Contributor

can we wrap all that code in some kind of #if ENABLE_TOOLING or some or some [Conditional] ? The goal is still to be able to provide 2 versions of Maui, one used when you build for debug (and has tooling enabled) and the other one having all those calls stripped, for perf, when you build for distribution

@drasticactions
Copy link
Contributor Author

@StephaneDelcroix I think we should talk about that, but, IMO, I think it's outside the scope of this PR. Thinking about multiple DLLs and packages for tooling would make this much more complex and open up a can of worms that would probably be better set for a fully thought out plan.

This PR is more limited in scope. There are implications moving VisualDiagnostics to Core (Mostly being that more people who use Core only can access it, opening them up to Hot Reload tooling) but I wanted to make sure everything in Controls still functioned the same as it does today.

@Redth
Copy link
Member

Redth commented Jan 30, 2022

I agree, and added a tracking issue for the work to have this stuff removed in release builds: #4409

We can schedule that work post-RC release.

I think if everyone's happy with this PR and we can get it green we should merge it ASAP.

@Redth
Copy link
Member

Redth commented Jan 30, 2022

@drasticactions does this require a change from UI Tools to consume? Should we add a TypeForwardedTo attribute for these moving types?

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly OK, but this should all be in a separate namespace Microsoft.Maui.VisualDiagnostics as this is a tooling feature and not meant to be used by apps at all. And, as Stephane says, this might only be available in a debug build. The API might exist, but for release we might decide to have no-ops and stuff.

Comment on lines 6 to 7
namespace Microsoft.Maui.Controls.Xaml.Diagnostics
namespace Microsoft.Maui
{
static class DebuggerHelper
public static class DebuggerHelper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this internal? At the very least, this must be in a separate namespace that no-one uses it. This is purely for our testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to leave it internal, I just couldn't figure out how to make it work, since I think that would mean giving Internal access to Maui.Controls for Maui.Core, and I'm not sure if that's wanted?

If there's a way to do it and keep it working, I'm 100% happy to do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is fine to make it internal for now - especially since it is just for testing? The Controls library itself doesn't actually use this. Or it shouldn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'm dumb. I didn't notice that Internals were already exposed for Maui.Controls. I needed to add Controls.Xaml to InternalsVisibleTo and now it all works.

0310b4a

@drasticactions
Copy link
Contributor Author

drasticactions commented Jan 30, 2022

Looks mostly OK, but this should all be in a separate namespace Microsoft.Maui.VisualDiagnostics as this is a tooling feature and not meant to be used by apps at all. And, as Stephane says, this might only be available in a debug build. The API might exist, but for release we might decide to have no-ops and stuff.

I'm cool with moving the types, but the way it's set up right now would result in Microsoft.Maui.VisualDiagnostics.VisualDiagnostics, hence why I removed it to keep it in line with the others. But I'm not too pressed either way about it.

@mattleibow
Copy link
Member

I suppose the namespace is fine to be in the root.

@drasticactions drasticactions enabled auto-merge (squash) January 31, 2022 16:52
@StephaneDelcroix
Copy link
Contributor

it's better to keep the root namespace for publicly accessible types for end-users. Tooling, or Design would be an appropriate name for the ns too

@Redth Redth disabled auto-merge February 1, 2022 13:20
@drasticactions drasticactions changed the base branch from main to release/6.0.2xx-preview13 February 1, 2022 16:50
@Redth Redth merged commit 03ccde5 into dotnet:release/6.0.2xx-preview13 Feb 1, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
partner/ui-tools .NET UI Tools
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants