I am working on a Language Extension (for Visual Studio 2022) to provide custom data for code completion. I have 1 VS Extension Package (UI and so on) that includes another VSIX Project as MEF Component (Contains code that interacts with completion API). The Moniker imagemanifest is part of Extension Package.
When working with completions, I can provide an ImageElement with the Moniker GUID and ID (as ImageId). But my image is not displayed, am I doing something wrong?
PackageImageIds.cs contains the Moniker Guid and Image Id.
Here is my current solution for the problem:
Symbol declaration in VSCT (I switched the real name and id for MyMonikerGuid and MyImageId):
<GuidSymbol name="Moniker" value="MyMonikerGuid">
<IDSymbol name="Image" value="MyImageId" />
</GuidSymbol>
ImageManifest:
<?xml version="1.0" encoding="utf-8"?>
<ImageManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/VisualStudio/ImageManifestSchema/2014">
<Symbols>
<String Name="Resources" Value="/MyAssembly;Component/Resources" />
<Guid Name="Moniker" Value="MyMonikerGuid" />
<ID Name="Image" Value="MyImageId" />
</Symbols>
<Images>
<Image Guid="$(Moniker)" ID="$(Image)">
<Source Uri="$(Resources)/image16.png">
<Size Value="16" />
</Source>
<Source Uri="$(Resources)/image32.png">
<Size Value="32" />
</Source>
</Image>
</Images>
<ImageLists />
</ImageManifest>
Its BuildAction is "Content" and "Included in VSIX" is true (I also checked it, the imagemanifest is correctly deployed)
ImageElement (again some values are switched for showcase, they are correct in my code):
private static readonly ImageElement Image = new ImageElement(new ImageId(PackageImageIds.MyMonikerGuid, PackageImageIds.MyImageId), "Automation name");
This ImageElement is provided when returning my CompletionItems
new CompletionItem(e.DisplayText, this, Image, ...)
According to some sources I found, this should work perfectly fine, but all these sources relate to earlier versions of Visual Studio, so maybe Visual Studio 2022 has a different approach? I also noticed that there were some major changes in the visual Studio SDK so maybe the issue lies in there.
Custom images in VS extensions via imagemanifest are broken in recent Visual Studio versions. Please see my report here: https://developercommunity.visualstudio.com/t/VSSDKCPSExtensibility:-Image-Loading-i/10525678
In Visual Studio 2022, a new pattern is required for specifying the Resources key in the imagemanifest which includes the assembly version and the public key token:
Previously:
<String Name="Resources" Value="/$rootnamespace$;Component/" />
Now needed:
<String Name="Resources" Value="/$rootnamespace$;v$assemblyversion$;$publickeytoken$;Component/" />