AvaloniaVSCode icon indicating copy to clipboard operation
AvaloniaVSCode copied to clipboard

`axaml` code completion not available when `UseArtifactsOutput` is used; incomplete otherwise

Open just-ero opened this issue 1 year ago • 3 comments

Describe the bug

It appears that when using UseArtifactsOutput (new addition in .NET 8), Avalonia is incapable of finding the build artifacts, such that the Build the project pop-up appears even after building the project.

When not using UseArtifactsOutput, completion is still incomplete, only suggesting the closing tag for the root element (e.g. </Application>). This may be caused due to being on an Avalonia version above the suggested 11.0.2, but I'm not sure (the README only mentions that the previewer will not work).

To Reproduce

  1. Create or open any Avalonia project in Visual Studio Code.
  2. Clear (dotnet clean) or remove the bin/ and obj/ directories for the test project.
  3. Create (dotnet new buildprops) or open a Directory.build.props file in the root of the workspace.
  4. Add a <UseArtifactsOutput>true</UseArtifactsOutput> element.
  5. Attempt to receive code completions in any axaml files.

Avalonia for VS Code

v0.0.31

Avalonia version

11.0.6

VS Code version

1.87.0

Relevant log output

None.

Additional context

No response

just-ero avatar Mar 07 '24 11:03 just-ero

https://github.com/AvaloniaUI/AvaloniaVSCode/blob/7e167c75df8953cb0c3a7a94ea25886c4df7cc2c/src/AvaloniaLSP/AvaloniaLanguageServer/Models/ProjectInfo.cs#L52-L74 This Path.Combine(ProjectDirectory, "bin", "Debug") is incompatible with projects using artifacts path. IsAssemblyExist will be always false for them.

https://github.com/AvaloniaUI/AvaloniaVSCode/blob/7e167c75df8953cb0c3a7a94ea25886c4df7cc2c/src/AvaloniaLSP/AvaloniaLanguageServer/Handlers/CompletionHandler.cs#L80-L83 And this check on IsAssemblyExist will prevent completion engine from being initialized.

I have to put fake zero byte .dll file to allow completion to kick in.

PetSerAl avatar Feb 09 '25 05:02 PetSerAl

Could we get some info on this? It's entirely impossible for me to use Avalonia in VSCode due to this problem.

Where might one start working on fixing this? How can we get the IntermediateOutputPath from the project?

just-ero avatar May 14 '25 10:05 just-ero

When we improved the MSBuild property resolution in this fork, we noticed that similar issues have been resolved. You might want to try it out.

lextm avatar Aug 22 '25 04:08 lextm