Can't get my ImageMoniker to work in an ImageElement

Viewed 37

If I create an ImageElement from the KnowMoniker like this:

_imageElement = new ImageElement(new ImageId(KnownMonikers.BlankFile.Guid, KnownMonikers.BlankFile.Id));

And then use it later when I create a CompletionContext like so:

var completionItems = result.Items.Where(i => !string.IsNullOrWhiteSpace(i.InsertText));
if (completionItems.Any())
{
    return new CompletionContext(
        ImmutableArray.Create(
            completionItems.Select(i => new CompletionItem(i.InsertText, this, _imageElement, _filters)).ToArray()));
}

It works perfectly. When I try to use my custom Moniker though, it never works. I have an imagemanifest file like so (with "Build Action" set to "Content" and "Include in VSIX" set to true, at the root of the project):

<?xml version="1.0" encoding="utf-8"?>
<!-- This file was generated by the ManifestFromResources tool.-->
<!-- Version: 17.0.0.4 -->
<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="/MyExtension.VS2022;Component/Resources" />
    <Guid Name="AssetsGuid" Value="{da3183aa-7930-45b7-b58e-fd8f0d1908ea}" />
      <ID Name="Logo" Value="0" />
      <ID Name="Bug" Value="1" />
    </Symbols>
    <Images>
      <Image Guid="$(AssetsGuid)" ID="$(Logo)">
        <Source Uri="$(Resources)/Logo.png">
          <Size Value="14" />
        </Source>
      </Image>
      <Image Guid="$(AssetsGuid)" ID="$(Bug)">
        <Source Uri="$(Resources)/Bug.png">
          <Size Value="16" />
        </Source>
      </Image>
    </Images>
  <ImageLists />
</ImageManifest>

My PNGs are in a "Resources" folder and are set to "Resource" build action.

Finally, I have an generated ImageIds and MyMoniker class like so:

public static class ImagesIds
{
    {
        public const string AssetsGuidString = "{da3183aa-7930-45b7-b58e-fd8f0d1908ea}";
        public static readonly Guid AssetsGuid = new Guid(AssetsGuidString);

        public const int Logo = 0;
        public const int Bug = 1;
    }
}
public static class MyMonikers
{
    public static ImageMoniker Logo { get { return new ImageMoniker { Guid = ImagesIds.AssetsGuid, Id = ImagesIds.Logo }; } }
    public static ImageMoniker Bug { get { return new ImageMoniker { Guid = ImagesIds.AssetsGuid, Id = ImagesIds.Bug }; } }
}

If I create my ImageElement like this instead though, I don't see the icon:

_imageElement = new ImageElement(new ImageId(MyMonikers.Bug.Guid, MyMonikers.Bug.Id));

Any idea what's missing?

0 Answers
Related