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

Code before:
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Wpf;
using Microsoft.CodeAnalysis.InheritanceMargin;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.Imaging.Interop;
using Microsoft.VisualStudio.LanguageServices.Implementation.InheritanceMargin.MarginGlyph;
using Roslyn.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.InheritanceMargin;

internal static class InheritanceMarginHelpers
{
    private static readonly ObjectPool<MultiDictionary<string, InheritanceTargetItem>> s_pool = new(() => []);

    /// <summary>
    /// Strips punctuation from a string for comparison purposes. Used to identify when two display names
    /// are essentially the same but differ only in punctuation (e.g., "IAliasSymbol.Target" vs "IAliasSymbolTarget").
    /// </summary>
    private static string StripPunctuation(string text)
    {
        if (string.IsNullOrEmpty(text))
            return text;

        var builder = new StringBuilder(text.Length);
        foreach (var c in text)
        {
            if (!char.IsPunctuation(c))
                builder.Append(c);
        }
        return builder.ToString();
    }

    private static readonly ImmutableArray<InheritanceRelationship> s_relationships_Shown_As_I_Up_Arrow
        =
        [
            InheritanceRelationship.ImplementedInterface,
            InheritanceRelationship.InheritedInterface,
            InheritanceRelationship.ImplementedMember,
        ];

    private static readonly ImmutableArray<InheritanceRelationship> s_relationships_Shown_As_I_Down_Arrow
        = [InheritanceRelationship.ImplementingType, InheritanceRelationship.ImplementingMember];

    private static readonly ImmutableArray<InheritanceRelationship> s_relationships_Shown_As_O_Up_Arrow
        = [InheritanceRelationship.BaseType, InheritanceRelationship.OverriddenMember];

    private static readonly ImmutableArray<InheritanceRelationship> s_relationships_Shown_As_O_Down_Arrow
        = [InheritanceRelationship.DerivedType, InheritanceRelationship.OverridingMember];


Review comment (suggestion):
@copilot 

```suggestion
        using var _ = new PooledStringBuilder(out var builder);
```

Code after:
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor.Wpf;
using Microsoft.CodeAnalysis.InheritanceMargin;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.Imaging.Interop;
using Microsoft.VisualStudio.LanguageServices.Implementation.InheritanceMargin.MarginGlyph;
using Roslyn.Utilities;

namespace Microsoft.VisualStudio.LanguageServices.Implementation.InheritanceMargin;

internal static class InheritanceMarginHelpers
{
    private static readonly ObjectPool<MultiDictionary<string, InheritanceTargetItem>> s_pool = new(() => []);

    /// <summary>
    /// Strips punctuation from a string for comparison purposes. Used to identify when two display names
    /// are essentially the same but differ only in punctuation (e.g., "IAliasSymbol.Target" vs "IAliasSymbolTarget").
    /// </summary>
    private static string StripPunctuation(string text)
    {
        using var _ = PooledStringBuilder.GetInstance(out var builder);
        var hasPunctuation = false;
        foreach (var c in text)
        {
            if (char.IsPunctuation(c))
            {
                hasPunctuation = true;
            }
            else
            {
                builder.Append(c);
            }
        }

        return hasPunctuation ? builder.ToString() : text;
    }

    private static readonly ImmutableArray<InheritanceRelationship> s_relationships_Shown_As_I_Up_Arrow
        =
        [
            InheritanceRelationship.ImplementedInterface,
            InheritanceRelationship.InheritedInterface,
            InheritanceRelationship.ImplementedMember,
        ];

    private static readonly ImmutableArray<InheritanceRelationship> s_relationships_Shown_As_I_Down_Arrow
        = [InheritanceRelationship.ImplementingType, InheritanceRelationship.ImplementingMember];

    private static readonly ImmutableArray<InheritanceRelationship> s_relationships_Shown_As_O_Up_Arrow
        = [InheritanceRelationship.BaseType, InheritanceRelationship.OverriddenMember];