Skip to content

Conversation

@StephaneDelcroix
Copy link
Contributor

Description of Change

Turn Visual and Binding diags on EnableDiagnostics

more diagnostics to be plugged on this later

Issues Fixed

Copilot AI review requested due to automatic review settings June 5, 2025 13:42
@StephaneDelcroix StephaneDelcroix requested a review from a team as a code owner June 5, 2025 13:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables Visual and Binding diagnostics by switching the diagnostic flag from DebuggerHelper to a new runtime feature flag. Additionally, it removes the DebuggerHelper dependency and updates tests and build targets accordingly.

  • Updated VisualDiagnostics.IsEnabled to use RuntimeFeature.EnableDiagnostics.
  • Removed DebuggerHelper and exposed previously internal RuntimeFeature properties as public.
  • Updated tests and build targets to use the new diagnostics flag.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Core/src/VisualDiagnostics/VisualDiagnostics.cs Updated IsEnabled condition to rely on RuntimeFeature.EnableDiagnostics rather than debugger status.
src/Core/src/DebuggerHelper.cs Removed obsolete DebuggerHelper functionality.
src/Core/src/RuntimeFeature.cs Exposed several runtime feature properties as public and introduced the EnableDiagnostics property.
src/Controls/tests/... Updated tests to correctly capture and restore the EnableDiagnostics flag state.
src/Controls/src/Core/Xaml/Diagnostics/BindingDiagnostics.cs Added guard conditions based on RuntimeFeature.EnableDiagnostics.
src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets Added a configuration option for EnableDiagnostics.
Comments suppressed due to low confidence (1)

src/Core/src/RuntimeFeature.cs:31

  • Changing these properties from internal to public could represent a breaking change for consumers; please confirm that this change is intentional and properly communicated.
public static bool IsIVisualAssemblyScanningEnabled =>

@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/enablediagnostics branch from d672ef2 to 8c57338 Compare June 5, 2025 13:43
@StephaneDelcroix StephaneDelcroix changed the base branch from main to net10.0 June 5, 2025 13:44
@StephaneDelcroix
Copy link
Contributor Author

/cc @jonathanpeppers @simonrozsival

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

There is a doc here, we've been listing each new feature switch:

@spadapet
Copy link
Contributor

spadapet commented Jun 6, 2025

I locally copied the NuGet packages from your PR build:

And the XAML Binding Failures window doesn't show binding failure anymore.

The repro is:

  1. Open the project
  2. F5 to build/debug on Windows
  3. Edit the {Binding Foo...} just to change Foo to something else that's invalid
  4. Look in the XAML Binding Failures window, it should have a new entry for the binding failure

@jonathanpeppers
Copy link
Member

jonathanpeppers commented Jun 6, 2025

$(EnableDiagnostics) is not set by default for Debug mode, so that would be why @spadapet's example didn't work. If you set that in the .csproj, I assume it works?

If we made a new $(EnableMauiDiagnostics) property, maybe its default could be influenced by $(DebuggerSupport), $(Optimize), and $(EnableDiagnostics)?

@spadapet
Copy link
Contributor

spadapet commented Jun 6, 2025

$(EnableDiagnostics) is not set by default for Debug mode, so that would be why @spadapet's example didn't work. If you set that in the .csproj, I assume it works?

Yes, once I set <EnableDiagnostics>true</EnableDiagnostics> in the csproj file then binding failures work.

@StephaneDelcroix
Copy link
Contributor Author

If we made a new $(EnableMauiDiagnostics) property, maybe it's default could be influenced by $(DebuggerSupport), $(Optimize), and $(EnableDiagnostics)?

let's go for added granularity

@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/enablediagnostics branch 4 times, most recently from 3403960 to 013b614 Compare June 10, 2025 14:14
@PureWeen PureWeen added this to the .NET 10.0-preview6 milestone Jun 25, 2025
@PureWeen PureWeen added the p/0 Current heighest priority issues that we are targeting for a release. label Jun 25, 2025
Copy link
Member

@PureWeen PureWeen left a comment

Choose a reason for hiding this comment

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

Failing Unit Tests

@github-project-automation github-project-automation bot moved this from Todo to Changes Requested in MAUI SDK Ongoing Jul 3, 2025
@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/enablediagnostics branch from 013b614 to 549a0e9 Compare July 4, 2025 10:08
@StephaneDelcroix
Copy link
Contributor Author

Failing Unit Tests

should be fixed

@StephaneDelcroix StephaneDelcroix force-pushed the dev/stdelc/enablediagnostics branch from 2b415f3 to 443b57e Compare July 4, 2025 11:27
@StephaneDelcroix StephaneDelcroix requested a review from PureWeen July 4, 2025 11:28
@StephaneDelcroix
Copy link
Contributor Author

failures looks unrelated

more diagnostics to be plugged on this later

- fixes #29809
rmarinho
rmarinho previously approved these changes Jul 23, 2025
Copy link
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

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

Just to me consistent some small changes

LGTM

Comment on lines +17 to +18
| EnableDiagnostics | Microsoft.Maui.RuntimeFeature.EnableDiagnostics | Enables diagnostic for the running app |
| EnableMauiDiagnostics | Microsoft.Maui.RuntimeFeature.EnableMauiDiagnostics | Enables MAUI specific diagnostics, like VisualDiagnostics and BindingDiagnostics. Defaults to EnableDiagnostics |
Copy link
Member

Choose a reason for hiding this comment

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

Just curious why we're introducing a new feature switch just for the MAUI part?

Additionally - diagnostics in WASM relates to tracing, profiling and debugger. It's a runtime thing. Here it guards functionality which does logging through DI ILogger and fires events which can be subscribed to by anything in the app.

I understand that semantically these are similar, just want to make sure that we're aware of these differences and it's intentional.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we don't need a second feature switch, but just a second MSBuild property?

$(EnableDiagnostics) adds the Mono diagnostic component in both iOS/Android workloads. But you might want to set $(EnableMauiDiagnostics) in a build without the Mono component but with the extra MAUI diagnostic information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we went back and forth with one, or 2, flags. I like having a second one for added granularity that defaults to the first one...

@rmarinho rmarinho merged commit dedcc40 into net10.0 Jul 24, 2025
130 checks passed
@rmarinho rmarinho deleted the dev/stdelc/enablediagnostics branch July 24, 2025 11:06
@github-project-automation github-project-automation bot moved this from Changes Requested to Done in MAUI SDK Ongoing Jul 24, 2025
@PureWeen PureWeen added the area-xaml XAML, CSS, Triggers, Behaviors label Aug 21, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-xaml XAML, CSS, Triggers, Behaviors p/0 Current heighest priority issues that we are targeting for a release.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Turn on diagnostics on EnableDiagnostics

7 participants