Repository: dotnet/roslyn
File: src/VisualStudio/Core/Def/Shared/VisualStudioImageIdService.cs (C#)

Code before:

    private readonly IThreadingContext _threadingContext = threadingContext;
    private readonly IVsImageService2 _imageService = (IVsImageService2)serviceProvider.GetService(typeof(SVsImageService));
    private readonly Lazy<ImageId> _copilotGlyph = new(() => KnownMonikers.SparkleNoColor.ToImageId());

    // We have to keep the image handles around to keep the compound glyph alive.
    private readonly List<CompositeImage> _compositeImages = [];

    public bool TryGetImageId(ImmutableArray<string> tags, out ImageId imageId)
    {
        _threadingContext.ThrowIfNotOnUIThread();

        imageId = GetImageId(tags);
        return imageId != default;
    }

    private ImageId GetImageId(ImmutableArray<string> tags)
    {
        var glyph = tags.GetFirstGlyph();
        switch (glyph)
        {
            case Glyph.AddReference:
                return GetCompositedImageId(
                    CreateLayer(Glyph.Reference.GetImageMoniker(), virtualXOffset: 1, virtualYOffset: 2),
                    CreateLayer(KnownMonikers.PendingAddNode, virtualWidth: 7, virtualXOffset: -1, virtualYOffset: -2));
            case Glyph.Copilot:
                return _copilotGlyph.Value;
        }

        return glyph.GetImageId();
    }

    private static ImageCompositionLayer CreateLayer(
        ImageMoniker imageMoniker,
        int virtualWidth = 16,
        int virtualYOffset = 0,
        int virtualXOffset = 0)
    {
        return new ImageCompositionLayer
        {
            VirtualWidth = virtualWidth,
            VirtualHeight = 16,
            ImageMoniker = imageMoniker,
            HorizontalAlignment = (uint)_UIImageHorizontalAlignment.IHA_Left,
            VerticalAlignment = (uint)_UIImageVerticalAlignment.IVA_Top,
            VirtualXOffset = virtualXOffset,
            VirtualYOffset = virtualYOffset,
        };
    }

    private ImageId GetCompositedImageId(params ImageCompositionLayer[] layers)

Review comment (suggestion):
Instead of this, the `SparkleNoColor` imageId should likely be added here - https://github.com/dotnet/roslyn/blob/main/src/LanguageServer/Protocol/Extensions/Extensions.KnownImageIds.cs#L15

Then https://github.com/dotnet/roslyn/blob/main/src/LanguageServer/Protocol/Extensions/Extensions.cs#L354 can be updated to map the glyph to the right imageid, and shouldn't need any changes to this file

Code after:

    private readonly IThreadingContext _threadingContext = threadingContext;
    private readonly IVsImageService2 _imageService = (IVsImageService2)serviceProvider.GetService(typeof(SVsImageService));

    // We have to keep the image handles around to keep the compound glyph alive.
    private readonly List<CompositeImage> _compositeImages = [];

    public bool TryGetImageId(ImmutableArray<string> tags, out ImageId imageId)
    {
        _threadingContext.ThrowIfNotOnUIThread();

        imageId = GetImageId(tags);
        return imageId != default;
    }

    private ImageId GetImageId(ImmutableArray<string> tags)
    {
        var glyph = tags.GetFirstGlyph();
        switch (glyph)
        {
            case Glyph.AddReference:
                return GetCompositedImageId(
                    CreateLayer(Glyph.Reference.GetImageMoniker(), virtualXOffset: 1, virtualYOffset: 2),
                    CreateLayer(KnownMonikers.PendingAddNode, virtualWidth: 7, virtualXOffset: -1, virtualYOffset: -2));
        }

        return glyph.GetImageId();
    }

    private static ImageCompositionLayer CreateLayer(
        ImageMoniker imageMoniker,
        int virtualWidth = 16,
        int virtualYOffset = 0,
        int virtualXOffset = 0)
    {
        return new ImageCompositionLayer
        {
            VirtualWidth = virtualWidth,
            VirtualHeight = 16,
            ImageMoniker = imageMoniker,
            HorizontalAlignment = (uint)_UIImageHorizontalAlignment.IHA_Left,
            VerticalAlignment = (uint)_UIImageVerticalAlignment.IVA_Top,
            VirtualXOffset = virtualXOffset,
            VirtualYOffset = virtualYOffset,
        };
    }

    private ImageId GetCompositedImageId(params ImageCompositionLayer[] layers)
    {
        _threadingContext.ThrowIfNotOnUIThread();