AvaloniaUI/AvaloniaVSCode

AvaloniaLanguageServer passing `string` to `GetForTargetAssembly` where `IAssemblyProvider` is expected

Opened this issue · 0 comments

Describe the bug

I'm in the middle of writing a patch for this.
By the way, only repo admins can assign issues to users.
cannotAssign


AvaloniaLanguageServer does not compile.
It's passing a string to a method that expects an IAssemblyProvider. It used to have mostly-correct behavior.
return _metadataReader.GetForTargetAssembly(new AvaloniaCompilationAssemblyProvider(intermediateOutputPath));

But it was missing something. It was passing the raw intermediateOutputPath.
AvaloniaDesigner.xaml.cs contains a private function showing how the path is supposed to be transformed:
https://github.com/AvaloniaUI/AvaloniaVS/blob/9568ba154fd6a808d78548fef8f0bbb9e4238f5a/AvaloniaVS.Shared/Views/AvaloniaDesigner.xaml.cs#L522-L540

This is one of the many pitfalls of Avalonia.Ide.CompletionEngine's poorly documented API. Here are some others:
Where the constructor of AvaloniaCompilationAssemblyProvider takes a string parameter named path, it's actually expecting the path to a text file containing a newline-separate array of directory paths.
https://github.com/AvaloniaUI/AvaloniaVS/blob/9568ba154fd6a808d78548fef8f0bbb9e4238f5a/CompletionEngine/Avalonia.Ide.CompletionEngine/AssemblyMetadata/AvaloniaCompilationAssemblyProvider.cs#L22
https://github.com/AvaloniaUI/AvaloniaVS/blob/9568ba154fd6a808d78548fef8f0bbb9e4238f5a/CompletionEngine/Avalonia.Ide.CompletionEngine.DnlibMetadataProvider/DnlibMetadataProvider.cs#L13-L25

To Reproduce

dotnet build ./src/AvaloniaLSP/AvaloniaLanguageServer/AvaloniaLanguageServer.csproj

Avalonia for VS Code

since 0f777aa

Avalonia version

No response

VS Code version

No response

Relevant log output

__ __

Additional context

No response