JaneySprings / DotNet.Meteor

A VSCode extension that can run and debug .NET apps (Xamarin, MAUI, Avalonia)
https://marketplace.visualstudio.com/items?itemName=nromanov.dotnet-meteor
MIT License
268 stars 10 forks source link

[HotReload]: An item with the same key has already been added. Key: CommonStates #114

Closed ziomek64 closed 2 months ago

ziomek64 commented 2 months ago

Hello, An error in the title happens on some of my pages. I think it might be related to the fact that I use this in my page:

                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup Name="CommonStates">
                                        <VisualState Name="Selected">
                                            <VisualState.Setters>
                                                <Setter Property="BackgroundColor" Value="Transparent" />
                                            </VisualState.Setters>
                                        </VisualState>
                                    </VisualStateGroup>
JaneySprings commented 2 months ago

Hi, can you try to change this code to:

<VisualStateManager.VisualStateGroups>
    <VisualStateGroupList> <!-- add this -->
        <VisualStateGroup Name="CommonStates">
            <VisualState Name="Selected">
                <VisualState.Setters>
                    <Setter Property="BackgroundColor" Value="Transparent" />
                </VisualState.Setters>
            </VisualState>
         </VisualStateGroup>
    </VisualStateGroupList> <!-- add this -->
</VisualStateManager.VisualStateGroups>

I can't even run the app without it.

ziomek64 commented 2 months ago

Hi, can you try to change this code to:

<VisualStateManager.VisualStateGroups>
    <VisualStateGroupList> <!-- add this -->
        <VisualStateGroup Name="CommonStates">
            <VisualState Name="Selected">
                <VisualState.Setters>
                    <Setter Property="BackgroundColor" Value="Transparent" />
                </VisualState.Setters>
            </VisualState>
         </VisualStateGroup>
    </VisualStateGroupList> <!-- add this -->
</VisualStateManager.VisualStateGroups>

I can't even run the app without it.

Hello, I still get an error. To give you idea what I'm doing:

                <CollectionView
                    BackgroundColor="Transparent"
                    HeightRequest="120"
                    IsVisible="{Binding Animes, Converter={StaticResource IsListNotNullOrEmptyConverter}}"
                    ItemsLayout="HorizontalList"
                    ItemsSource="{Binding Animes}"
                    Margin="0,10,0,0"
                    SelectedItem="{Binding SelectedAnimeMedia}"
                    SelectionMode="None"
                    x:Name="CollectionView1">
                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <StackLayout
                                IsClippedToBounds="True"
                                Orientation="Horizontal"
                                Padding="0">
                                <Frame
                                    BackgroundColor="Transparent"
                                    BorderColor="Transparent"
                                    CornerRadius="5"
                                    Margin="15,0,0,0"
                                    Padding="0">
                                    <Frame.GestureRecognizers>
                                        <TapGestureRecognizer Command="{Binding BindingContext.ChangeSelectedAnimeCommand, Source={x:Reference Name=Pagee2}}" CommandParameter="{Binding .}" />
                                    </Frame.GestureRecognizers>
                                    <Image
                                        Aspect="AspectFill"
                                        Source="{Binding CoverImage.Large}"
                                        WidthRequest="80" />
                                </Frame>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup Name="CommonStates">
                                        <VisualState Name="Selected">
                                            <VisualState.Setters>
                                                <Setter Property="BackgroundColor" Value="Transparent" />
                                            </VisualState.Setters>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                            </StackLayout>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>

It happens when trying to save and hot reload of course.

JaneySprings commented 2 months ago

I still can't reproduce it ( .NET Meteor version: 5.2.5 Workloads: maui 9.0.0-preview.5.24307.10/9.0.100-preview.5

https://github.com/user-attachments/assets/ad8764b1-e988-4f8f-9981-4e87952c09f4

I attached this example: MyExample.zip

ziomek64 commented 2 months ago

Not sure what's going on, should I give whole page? It happens only on the one when I have these. I'm using stable .net 8 latest one

JaneySprings commented 2 months ago

Have you been able to reproduce this problem on the project that I sent to you?

ziomek64 commented 2 months ago

Have you been able to reproduce this problem on the project that I sent to you?

Sorry I haven't seen it, but to be honest no. I wasn't able to reproduce it. I had to modify csproj a bit, add android sdk and jdk directories, remove all platforms except android. Not that it makes a difference I think

What should I provide you from my project? It's too big and unnecessary to give you the whole thing, so whole page?

JaneySprings commented 2 months ago

Can you extract this problem page in the separate working project (to reproduce the problem)? You can remove all of your data and replace it to simple strings.

ziomek64 commented 2 months ago

Can you extract this problem page in the separate working project (to reproduce the problem)? You can remove all of your data and replace it to simple strings.

I actually don't know what's going on. I've completely re-implemented this page to be standalone but I'm just not running into it. I will attach it but I don't know to be honest. Is there any way I can check exactly what's going on but in my full project?

TescikMaui.zip

JaneySprings commented 2 months ago

I think you can try to disable (comment) some parts of your application and check the result.

ziomek64 commented 2 months ago

I think you can try to disable (comment) some parts of your application and check the result.

I'll try to investigate in free time, but could be hard to find.

Is this a bug in meteor? Any other hot reloads work.

JaneySprings commented 2 months ago

Maybe... but I can't reproduce it. If this is not an important issue for you (if you can comment VisualStateManager temporary), you can close this issue and don't waste your time =)

ziomek64 commented 2 months ago

Maybe... but I can't reproduce it. If this is not an important issue for you (if you can comment VisualStateManager temporary), you can close this issue and don't waste your time =)

It is working now, which is honestly weird why. I don't even want to know why. If I stumble across the reason I will drop it here