ForNeVeR / AvaloniaRider

JetBrains Rider plugin for Avalonia development
https://plugins.jetbrains.com/plugin/14839-avaloniarider/
MIT License
453 stars 19 forks source link

Plugin dont show my window #272

Closed CreateLab closed 8 months ago

CreateLab commented 1 year ago
Obtaining AppBuilder instance from LStorageAdmin.Program.BuildAvaloniaApp
Initializing application in design mode
Sending StartDesignerSessionMessage
System.IO.EndOfStreamException: Attempted to read past the end of the stream.
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.ReadExact(Byte[] buffer) in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 59
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.Reader() in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 71
Process terminated with exit code 1"C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.runtimeconfig.json --depsfile C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.deps.json C:\Users\f98f9\.nuget\packages\avalonia\0.10.18\buildTransitive\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll --transport tcp-bson://127.0.0.1:62827/ --method avalonia-remote C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.dll
Obtaining AppBuilder instance from LStorageAdmin.Program.BuildAvaloniaApp
Initializing application in design mode
Sending StartDesignerSessionMessage
System.IO.EndOfStreamException: Attempted to read past the end of the stream.
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.ReadExact(Byte[] buffer) in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 59
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.Reader() in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 71
Process terminated with exit code 1"C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.runtimeconfig.json --depsfile C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.deps.json C:\Users\f98f9\.nuget\packages\avalonia\0.10.18\buildTransitive\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll --transport tcp-bson://127.0.0.1:62839/ --method avalonia-remote C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.dll
Obtaining AppBuilder instance from LStorageAdmin.Program.BuildAvaloniaApp
Initializing application in design mode
Sending StartDesignerSessionMessage
System.IO.EndOfStreamException: Attempted to read past the end of the stream.
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.ReadExact(Byte[] buffer) in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 59
   at Avalonia.Remote.Protocol.BsonStreamTransportConnection.Reader() in /_/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs:line 71
Process terminated with exit code 1"C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.runtimeconfig.json --depsfile C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.deps.json C:\Users\f98f9\.nuget\packages\avalonia\0.10.18\buildTransitive\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll --transport tcp-bson://127.0.0.1:62850/ --method avalonia-remote C:\Users\f98f9\RiderProjects\LStorage\LStorageAdmin\bin\Debug\net7.0\LStorageAdmin.dll
Obtaining AppBuilder instance from LStorageAdmin.Program.BuildAvaloniaApp
Initializing application in design mode
Sending StartDesignerSessionMessage

My Window xaml

<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"
        xmlns:viewModels="clr-namespace:LStorageAdmin.ViewModels"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="LStorageAdmin.Views.ProjectInfoWindow"
        Title="ProjectInfoWindow">
    <Design.DataContext>
        <!-- This only sets the DataContext for the previewer in an IDE,
             to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
        <viewModels:ProjectInfoVM/>
    </Design.DataContext>
    <Grid RowDefinitions="Auto, Auto,*" ColumnDefinitions="*,*">
        <TextBlock Grid.ColumnSpan="2" Margin="30" Text="{Binding ProjectName}" HorizontalAlignment="Stretch"></TextBlock>
        <TextBlock Grid.Row="1"  Margin="5" HorizontalAlignment="Stretch">Пользователи в проекте</TextBlock>
        <ItemsRepeater Grid.Row="2"  Margin="10" ScrollViewer.VerticalScrollBarVisibility="Visible" Items="{Binding UsersInProject}">
            <ItemsRepeater.ItemTemplate>
                <DataTemplate>
                    <Border BorderThickness="0,1" BorderBrush="Black" Margin="2">
                        <Grid ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto">
                            <TextBlock Margin="5" Text="{Binding Name}"></TextBlock>
                            <TextBlock Grid.Column="1" Margin="5" Text="{Binding Role }"></TextBlock>
                            <TextBlock Grid.Column="2" Margin="5" Text="{Binding Email }"></TextBlock>
                            <Button Grid.Column="4" Margin="5" Command="{Binding $parent[Window].DataContext.RemoveUserFromProject}" CommandParameter="{Binding Email}">X</Button>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ItemsRepeater.ItemTemplate>
        </ItemsRepeater>
        <TextBlock Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Stretch">Пользователи вне проекта</TextBlock>
        <ItemsRepeater Grid.Row="2" Grid.Column="1" Margin="10" ScrollViewer.VerticalScrollBarVisibility="Visible" Items="{Binding UsersOutOfProject}">
            <ItemsRepeater.ItemTemplate>
                <DataTemplate>
                    <Border BorderThickness="0,1" BorderBrush="Black" Margin="2">
                        <Grid ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto">
                            <TextBlock Margin="5" Text="{Binding Name}"></TextBlock>
                            <TextBlock Grid.Column="1" Margin="5" Text="{Binding Role }"></TextBlock>
                            <TextBlock Grid.Column="2" Margin="5" Text="{Binding Email }"></TextBlock>
                            <Button Grid.Column="4" Margin="5" Command="{Binding $parent[Window].DataContext.AddUserToProject}" CommandParameter="{Binding Email}"> &lt; </Button>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ItemsRepeater.ItemTemplate>
        </ItemsRepeater>
    </Grid>
</Window>
ForNeVeR commented 1 year ago

What does it show instead of your window?

CreateLab commented 1 year ago

Nothing image

ForNeVeR commented 1 year ago

Could you please prepare MCVE? I find it difficult to reproduce your setup.

CreateLab commented 1 year ago

Cant reproduce it in mvp, send info in private contact.

winterheart commented 1 year ago

Try to temporarily comment out this block in axaml:

    <Design.DataContext>
        <!-- This only sets the DataContext for the previewer in an IDE,
             to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
        <viewModels:ProjectInfoVM/>
    </Design.DataContext>
1MrEnot commented 1 year ago

Reproduces with bulit-in template on avalonia 11.0.2 and .net 7.0.200 Steps to reproduce:

Logs "C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig C:\Users\maxim\RiderProjects\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.runtimeconfig.json --depsfile C:\Users\maxim\RiderProjects\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.deps.json C:\Users\maxim\.nuget\packages\avalonia\11.0.2\buildTransitive\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll --transport tcp-bson://127.0.0.1:63670/ --method avalonia-remote C:\Users\maxim\RiderProjects\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.dll Obtaining AppBuilder instance from AvaloniaApplication1.Program Initializing application in design mode Sending StartDesignerSessionMessage System.IO.EndOfStreamException: Attempted to read past the end of the stream. at Avalonia.Remote.Protocol.BsonStreamTransportConnection.ReadExact(Byte[] buffer) at Avalonia.Remote.Protocol.BsonStreamTransportConnection.Reader() Process terminated with exit code 1"C:\Program Files\dotnet\dotnet.exe" exec --runtimeconfig C:\Users\maxim\RiderProjects\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.runtimeconfig.json --depsfile C:\Users\maxim\RiderProjects\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.deps.json C:\Users\maxim\.nuget\packages\avalonia\11.0.2\buildTransitive\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll --transport tcp-bson://127.0.0.1:63709/ --method avalonia-remote C:\Users\maxim\RiderProjects\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.dll Obtaining AppBuilder instance from AvaloniaApplication1.Program Initializing application in design mode Sending StartDesignerSessionMessage

Before click on "Start previewer" there's still "Application can't be previewed in design view" but only part of logs up to "Sending StartDesignerSessionMessage"

ForNeVeR commented 1 year ago

@1MrEnot, in your case, I see that the preview works correctly.

1MrEnot commented 1 year ago

Do I understand correctly, that these sample apps won't be displayed in preview and it is ok?

image

Avabin commented 1 year ago

@1MrEnot you are missing the point. Previewer will gladly display windows and views, but not 'App' object, as stated in error message. Open any Window or view and see if it displays it or not.

Second. I have the same kind of bug as poster and I'm trying to reproduce his bug in a side project. This is non trivial.

Avabin commented 1 year ago

Once the designer trips in a given project, it cannot be brought back. Still can't put my finger on what is wrong, as designer is working, logs from designer apps are fine (as seen below) but after few hours of code juggling, I've accomplished nothing.

Project was created using .NET 7.0.305 and latest Avalonia (11.0.4). image

This is a repo with this bug. Clone and build to see no window in previewer. https://github.com/Avabin/Vizier

ghost commented 1 year ago

I have the same issue with the plugin.

Reproductions steps:

  1. Create an empty project in Rider IDE using Avalonia MVVM app template.
  2. Open MainWindow view.
  3. Open Previewer.
  4. Build the project as previewer asks.
  5. Click update icon in a previewer.
  6. Open previewer console.

Result: System.IO.EndOfStreamException: Attempted to read past the end of the stream. at Avalonia.Remote.Protocol.BsonStreamTransportConnection.ReadExact(Byte[] buffer) at Avalonia.Remote.Protocol.BsonStreamTransportConnection.Reader()

CalvinWilkinson commented 1 year ago

I am getting this issue as well just like @tastytea-dev mentioned above.

I get the error EndOfStreamException in the log as well whether the previewer is correctly rendering the control and/or window or not.

ForNeVeR commented 1 year ago

@CreateLab, unfortunately, I cannot build your project. You only shared one .csproj of, I assume, several ones.

Please provide a better example to reproduce. Without it, I can't improve anything.

ForNeVeR commented 1 year ago

@Avabin, I'm sorry but your project isn't even available now :(

ForNeVeR commented 1 year ago

@tastyteadev @CalvinWilkinson, your messages don't make it clear what the issue is, unfortunately.

Yes, in earlier builds of the plugin, the previewer process was printing a message about closed socket (because the plugin was closing the socket, no less!) during restart.

This wasn't an error or a problem. Just one program was closing the socket, and another one (Avalonia previewer in this case) decided to print a message about that to the console.

In the modern versions of the plugin, this is no longer the case: according to the advice from the Avalonia team, we force-terminate the previewer process (thanks for mentioning it BTW, I'll add an entry to the changelog about that).

So, if the previewer was working fine, then I believe this is a duplicate of #270, already fixed logging problem (let's call it that).

DefinitelyADev commented 1 year ago

@ForNeVeR I have almost the exact same issue. I have tried:

The error pops before any of the constructors are hit and before the BuildAvaloniaApp method is called inside the Program class.

Here is the same screenshot as above: image

Please let me know if I can provide any more info.

ForNeVeR commented 1 year ago

@DefinitelyADev, a solution where this reproduces would be ideal.

DefinitelyADev commented 1 year ago

Sure, I can share my project! It is still small, and I plan on open sourcing it, so there is no problem.

If it matters my .Net SDK version is 7.0.403, my Rider version is 2023.2.2 and my AvaloniaRider plugin is 1.1.0.

TeamMate.zip

DefinitelyADev commented 1 year ago

@ForNeVeR I forgot to mention. The steps to replicate the error are:

  1. Build the project.
  2. Open the previewer and the previewer console in one of the previewable .axaml files (I used MainWindow.axaml).
  3. Press the reload button on the previewer.
Avabin commented 1 year ago

@Avabin, I'm sorry but your project isn't even available now :(

Sorry, that repo was supposed to be non-public. I will create a small repro project. What I've found overall is that previewer might break when complexity increases, like integrating dependency injection and generic host.

ForNeVeR commented 1 year ago

Most likely, all the mentioned problems are not of the plugin but of the previewer, and I report them upstream as I investigate.

ForNeVeR commented 12 months ago

@DefinitelyADev, could you please clarify what is the issue? I have done the actions you've asked, and I see the preview. Before of after I press the Reload button, it just seems to work.

(not sure how much of your UI I am allowed to publicly share, so I'll only show the header of the panel, to demonstrate the plugin UI state)

image

What do you see in your case?

DefinitelyADev commented 11 months ago

@ForNeVeR the previewer works but if you look at the console it shows an EndOfStreamException

ForNeVeR commented 11 months ago

@DefinitelyADev, what plugin version do you use?

CalvinWilkinson commented 11 months ago

@DefinitelyADev, what plugin version do you use?

I have the same issue.

Plugin Version: v1.1.0 Rider Info:

JetBrains Rider 2023.2.1
Build #RD-232.9559.61, built on August 22, 2023
Licensed to Calvin Wilkinson
Subscription is active until May 19, 2024.
Runtime version: 17.0.8+7-b1000.8 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
.NET Core v7.0.7 x64 (Server GC)
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 20
Registry:
    editor.focus.mode.color.light=6a737d
    ide.editor.tab.selection.animation=true
    ide.animate.toolwindows=true
    documentation.show.toolbar=true
    ide.new.editor.tabs.vertical.borders=true
    ide.experimental.ui=true
    ide.balloon.shadow.size=0
    editor.focus.mode.color.dark=6a737d
    vcs.empty.toolwindow.show=false
    ide.new.project.model.index.case.sensitivity=true
    database.show.search.tab=false

Non-Bundled Plugins:
    GLSL (1.24)
    com.intellij.javafx (1.0.4)
    com.villains.intelij.plugin.newoceantheme (1.2.2)
    com.jetbrains.darkPurpleTheme (1.3)
    com.github.copilot (1.4.0.3748)
    avalonia-rider (1.1.0)
    com.jetbrains.rider.android (232.9559.61)
    nsubstitutecomplete-rider (1.10.0)
    com.markskelton.one-dark-theme (5.9.0)
    fr.socolin.application-insights-debug-log-viewer (1.9.0)
    me.seclerp.rider.plugins.monogame (232.0.0-rc1)
    Abc.MoqComplete.Rider (2023.2.0.1)
    com.intellij.plugin.adernov.powershell (2.3.0)
    com.chrisrm.idea.MaterialThemeUI (8.12.6)
    org.sonarlint.idea (10.0.1.77000)
    com.mallowigi (93.1.0)
ForNeVeR commented 11 months ago

This (I mean, the error message being shown in console) was fixed in 1.2.0 (only Rider 2023.3).

CalvinWilkinson commented 11 months ago

This (I mean, the error message being shown in console) was fixed in 1.2.0 (only Rider 2023.3).

Ok, np. 😀 I will wait until 2023.3 is fully released and I will take advantage of the plugin update then. Thanks for your help and for fixing the issue!!

DefinitelyADev commented 11 months ago

@ForNeVeR my plugin version is 1.1.0, as I mentioned in a previous comment. I will try it during the weekend with EAP version of rider and get back to you. Thanks!

DefinitelyADev commented 11 months ago

@ForNeVeR seems to be fixed. I think you can close the issue. Checked with Rider version 2023.3 EAP 7 and AvaloniaRider Plugin version 1.3.0. Thank you for your time!

ForNeVeR commented 11 months ago

There are still a lot of people reported some random things in the same thread, and I'm still waiting for their answers to distinguish between the issues, open separate issues or diagnose further.

We have already diverged quite a bit from the initial topic of "Plugin dont show my window", though 😅

github-actions[bot] commented 8 months ago

This issue was closed because it has been open for 14 days, but no requested information was received. Please leave a comment if you think this is a mistake.