question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve XAML by removing noise

See original GitHub issue

Is your feature request related to a problem? Please describe.

I’m always frustrated when trying to explain XAML to a web developer.

Describe the solution you’d like

Remove all the unnecessary noise from XAML and make it friendlier to everyone.

Describe alternatives you’ve considered

None at the time.

Additional context

So, this is the XAML for an Avalonia Hello World:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="MyApp.Window1"
        Title="Window1">
  Welcome to Avalonia!
</Window>

That’s a lot of noise to explain to somebody who has never used Avalonia nor WPF. It would be awesome if it was just:

<Window Title="Window1">
  Welcome to Avalonia!
</Window>

Since none of the other stuff is really required.

  • xmlns and xmlns:x should really be implicit for every XAML file ever, since they’re pretty much required.
  • xmlns:d and xmlns:mc are designer-specific concerns that don’t really belong into production source code. The designer / previewer could handle this implicitly.
  • x:Class has 2 pieces of information:
    • the namespace could be implicitly derived by the location of the XAML file relative to the root of the project (following C# namespacing convention). It could still be explicitly added manually to override the convention if required.
    • the class name could be implicitly derived from the XAML file name.

Also: it would be awesome if custom and user controls in an assembly where implicitly mapped to the root namespace instead of having to define a custom XAML namespace for them.

Issue Analytics

  • State:open
  • Created 3 months ago
  • Reactions:9
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
cesarchefinhocommented, Jun 30, 2023

I dont like #2502

It is not better than this proposal, 2502 is flutter or qml or other strange thing but not xaml

this proposal maintain xaml and only simplifies markup, improving developper experience.

2reactions
ichthus1604commented, Jun 29, 2023

Changing it would make it even more difficult for developers coming from WPF or MAUI or any other framework using XAML

I strongly disagree.

There is nothing “more difficult” in this:

<Window Title="Window1">
  Welcome to Avalonia!
</Window>

compared to this:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="MyApp.Window1"
        Title="Window1">
  Welcome to Avalonia!
</Window>

Quite the contrary, all that useless noise makes me really want to quit XAML and learn HTML and React just to be able to write markup similar to the first example.

Nothing is more frustrating then to read tons of documentation pages to get some basics done

Again, there is absolutely no need to read any documentation to understand my first example. Quite the contrary, people need to read tons of documentation just to be able to understand a simple Hello World app with all that amount of useless noise and unnecessary complexity in the markup. Let alone anything more complex.

users who start with Avalonia and then switch to WPF/MAUI

Sorry, WPF is legacy and MAUI is honestly unusable and full of bugs. I personally couldn’t care less about any of that.

Also, as mentioned above, my proposal includes an MSBuildFlag (let’s call it <UseLegacyXaml>True</UseLegacyXaml> if you want / need to use legacy XAML.

cause conflicts if a name of a class exists both

This does not happen in practice, and if it does the compiler should fail to build that specific case, which is 0.00001% compared to the 99.9999% of times I do not have any conflict but still I’m forced to explicitly specify everything manually, which again leads to useless noise.

Improvements should make developing more easier and not just “looks better because less code”.

My proposal makes development substantially easier by avoiding unnecessary details such as namespaces that are totally not relevant when writing, nor maintaining code. This noise results in cognitive load, and cognitive load makes development substantially harder and more painful.

even added a checkbox

Yes. People are free to write legacy code with legacy idioms all they want. I personally want a way forward that doesn’t force me to write code like it was 2006.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I'm sometimes surprised how good looking c# .net xaml ...
I'm sometimes surprised how good looking c# .net xaml apps can be with minimal effort. Here's a small white noise app project I...
Read more >
Best way to improve performance in WPF application
From here, run a copy of the application with an isolated database server (no other clients hitting it to reduce "noise") with the...
Read more >
Optimize your XAML markup - UWP applications
Here are some things you can do to improve XAML markup parse and load time and memory efficiency for your app.
Read more >
global (and implicit) using directives - but for XAML?
As part of my exploration into how XAML files could be made better, I've been looking at whether something similar could be done...
Read more >
Remove Noise from Images in C# .NET (JPG, TIFF, PNG)
Remove noise vigorously with the FxBitonalVigorousDespeckle method of the GdPictureImaging object. This method cleans so vigorously that some data might be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found