Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Click event to a button in axaml file disables preview update #257

Closed
JenyaRostov opened this issue Jan 8, 2023 · 13 comments
Closed
Assignees
Labels
kind:bug Something isn't working

Comments

@JenyaRostov
Copy link

JenyaRostov commented Jan 8, 2023

Describe the bug
After adding Click event to any button live preview update in rider disables (no further updates whatsoever)

To Reproduce

Create a new cross-platform application (avalonia.xplat)
Add and a Click event to it
Live preview no longer updates

Expected behavior
I expect preview to update

Screenshots

Before adding click

After adding click event

Desktop (please complete the following information):

Windows 10
Rider 2022.3.1
AvaloniaRider 1.0.2
Avalonia 11.0.0-preview

I didn't notice this issue before so i'm open to suggestions why this might have happened

@ForNeVeR
Copy link
Owner

ForNeVeR commented Jan 8, 2023

Check the logs from the previewer process, do they contain any errors?

@ForNeVeR ForNeVeR added the kind:bug Something isn't working label Jan 8, 2023
@JenyaRostov
Copy link
Author

Yes they do, but they always has this error

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

@ForNeVeR
Copy link
Owner

ForNeVeR commented Jan 8, 2023

This means that a socket connection was terminated, perhaps by the IDE process. Are there any error messages from the IDE? In the IDE logs, perhaps?

@JenyaRostov
Copy link
Author

Thanks for quick response! I found this

2023-01-09 23:49:57,502 [7155995]   WARN - #me.fornever.avaloniarider.idea.editor.BitmapPreviewEditorComponent - XAML update error: XamlLoadException at 24:51: Unable to find suitable setter or adder for property Click of type Avalonia.Controls:Avalonia.Controls.Button for argument System.Private.CoreLib:System.String, available setter parameter lists are:
System.EventHandler`1[[Avalonia.Interactivity.RoutedEventArgs, Avalonia.Base, Version=11.0.0.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]] Line 24, position 51.
XamlX.XamlLoadException: Unable to find suitable setter or adder for property Click of type Avalonia.Controls:Avalonia.Controls.Button for argument System.Private.CoreLib:System.String, available setter parameter lists are:
System.EventHandler`1[[Avalonia.Interactivity.RoutedEventArgs, Avalonia.Base, Version=11.0.0.0, Culture=neutral, PublicKeyToken=c8d484a7012f9a8b]] Line 24, position 51.
   at XamlX.Transform.Transformers.ConvertPropertyValuesToAssignmentsTransformer.<>c__DisplayClass0_3.<Transform>g__CreateAssignment|1(<>c__DisplayClass0_0& , <>c__DisplayClass0_1& , <>c__DisplayClass0_2& ) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Transform/Transformers/ConvertPropertyValuesToAssignmentsTransformer.cs:line 117
   at XamlX.Transform.Transformers.ConvertPropertyValuesToAssignmentsTransformer.Transform(AstTransformationContext context, IXamlAstNode node) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Transform/Transformers/ConvertPropertyValuesToAssignmentsTransformer.cs:line 126
   at XamlX.Transform.AstTransformationContext.Visitor.Visit(IXamlAstNode node) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Transform/AstTransformationContext.cs:line 58
   at XamlX.Ast.XamlAstNode.Visit(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 56
   at XamlX.Ast.XamlAstNode.VisitList[T](IList`1 list, IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 74
   at XamlX.Ast.XamlAstObjectNode.VisitChildren(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Xaml.cs:line 78
   at XamlX.Ast.XamlAstNode.Visit(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 60
   at XamlX.Ast.XamlAstNode.VisitList[T](IList`1 list, IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 74
   at XamlX.Ast.XamlPropertyAssignmentNode.VisitChildren(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Clr.cs:line 218
   at XamlX.Ast.XamlAstNode.Visit(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 60
   at XamlX.Ast.XamlAstNode.VisitList[T](IList`1 list, IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 74
   at XamlX.Ast.XamlManipulationGroupNode.VisitChildren(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Clr.cs:line 317
   at XamlX.Ast.XamlAstNode.Visit(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 60
   at XamlX.Ast.XamlAstNode.VisitList[T](IList`1 list, IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 74
   at XamlX.Ast.XamlAstObjectNode.VisitChildren(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Xaml.cs:line 78
   at XamlX.Ast.XamlAstNode.Visit(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 60
   at XamlX.Ast.XamlAstNode.VisitList[T](IList`1 list, IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 74
   at XamlX.Ast.XamlPropertyAssignmentNode.VisitChildren(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Clr.cs:line 218
   at XamlX.Ast.XamlAstNode.Visit(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 60
   at XamlX.Ast.XamlAstNode.VisitList[T](IList`1 list, IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 74
   at XamlX.Ast.XamlAstObjectNode.VisitChildren(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Xaml.cs:line 78
   at XamlX.Ast.XamlAstNode.Visit(IXamlAstVisitor visitor) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Ast/Common.cs:line 60
   at XamlX.Compiler.XamlCompiler`2.Transform(XamlDocument doc, Boolean strict) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/xamlil.github/src/XamlX/Compiler/XamlCompiler.cs:line 71
   at Avalonia.Markup.Xaml.XamlIl.CompilerExtensions.AvaloniaXamlIlCompiler.ParseAndCompile(String xaml, String baseUri, IFileSource fileSource, IXamlTypeBuilder`1 tb, IXamlType overrideRootType) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/AvaloniaXamlIlCompiler.cs:line 146
   at Avalonia.Markup.Xaml.XamlIl.AvaloniaXamlIlRuntimeCompiler.LoadSreCore(String xaml, Assembly localAssembly, Object rootInstance, Uri uri, Boolean isDesignMode) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs:line 198
   at Avalonia.Markup.Xaml.XamlIl.AvaloniaXamlIlRuntimeCompiler.LoadSre(String xaml, Assembly localAssembly, Object rootInstance, Uri uri, Boolean isDesignMode) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs:line 158
   at Avalonia.Markup.Xaml.XamlIl.AvaloniaXamlIlRuntimeCompiler.Load(Stream stream, Assembly localAssembly, Object rootInstance, Uri uri, Boolean isDesignMode) in /_/src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs:line 261
   at Avalonia.Designer.HostApp.DesignXamlLoader.Load(Stream stream, Assembly localAsm, Object o, Uri baseUri, Boolean designMode) in /_/src/tools/Avalonia.Designer.HostApp/DesignXamlLoader.cs:line 13
   at Avalonia.DesignerSupport.DesignWindowLoader.LoadDesignerWindow(String xaml, String assemblyPath, String xamlFileProjectPath) in /_/src/Avalonia.DesignerSupport/DesignWindowLoader.cs:line 33
   at Avalonia.DesignerSupport.Remote.RemoteDesignerEntryPoint.<>c__DisplayClass17_0.<OnTransportMessage>b__0() in /_/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs:line 237

@ForNeVeR ForNeVeR self-assigned this Jan 10, 2023
@ForNeVeR
Copy link
Owner

ForNeVeR commented Jan 10, 2023

I would guess that the compiled assembly doesn't contain the method in question, and that's why the previewer breaks (it cannot resolve a method and thus trying to resolve a property with a string parameter, which also fails).

Anyway, this is likely to be an upstream previewer issue, but I'll have to check how other previewers handle this.

@JenyaRostov
Copy link
Author

Thank you for your suggestion. Building both Avalonia.Desktop and main Avalonia projects solved the issue
But i would like for it to work without doing that :3

@ForNeVeR
Copy link
Owner

Building both Avalonia.Desktop and main Avalonia projects solved the issue

I can't see how it is supposed to help anything. I am very confused now.

@JenyaRostov
Copy link
Author

You said that compiled assembly doesn't contain the method in question but after building it now does so it helps i guess?

@ForNeVeR
Copy link
Owner

How would building of Avalonia.Desktop, a library assembly, help you to get a method in your DLL? I am genuinely confused.

@JenyaRostov
Copy link
Author

Honestly, i have no idea.
In my designer i have Avalonia.Desktop project chosen (from cross-platform solution), and building it after adding new event method to MainView.axaml.cs helps

rider64_fZ9yAj0fIL.mp4

@ForNeVeR
Copy link
Owner

Ah, so it is not Avalonia.Desktop, but some of your libraries. Yes, this makes sense.

@ForNeVeR
Copy link
Owner

I have investigated the issue, and, yeah, it is not an AvaloniaRider problem: AvaloniaVS behaves the same.

This is because of a fundamental problem: it's impossible to apply any XAML changes that require DLL update on-the-fly.

I would recommend using MVVM command binding instead, it should work much better.

You can, of course, open an issue in the upstream repository, but honestly I doubt it's solvable.

@ForNeVeR ForNeVeR closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2023
@ForNeVeR
Copy link
Owner

I have thought about that more, and opened #262 to track further progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants