dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.99k stars 1.72k forks source link

Add XAML analyzers to avoid common pitfalls #13368

Open jonathanpeppers opened 1 year ago

jonathanpeppers commented 1 year ago

Description

Public API Changes

n/a

Intended Use-Case

Warn users about certain MAUI pitfalls via code analyzers.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

dersia commented 1 year ago

This should only apply to collectionview that order items in vertical direction.

We use a model like this to have multiple collection views underneath each other which use a horizontal item layout.

<ScrollView>
    <VerticalStackLayout>
        <Collectionview ItemLayout="Horizontal" />
        <Collectionview ItemLayout="Horizontal" />
        <Collectionview ItemLayout="Horizontal" />
        <Collectionview ItemLayout="Horizontal" />
    </VerticalStackLayout>
</ScrollView>

So the analyzer should not get this as a false positive.

jonathanpeppers commented 1 year ago

Another idea is an example like in: https://github.com/dotnet/maui/issues/7066

<Button ImageSource="button.svg"/>

In this case button.svg is wrong and you should put button.png. But it happens to work on Android, because MAUI trims the file extension away and loads an AndroidResource named button.

xcaptain commented 2 months ago

Come from the svg ImageButton issue, 2 years passed, still can't use .svg extension, has to use .png even if the resource is a svg. any progress?