Repository: dotnet/roslyn
File: src/Compilers/Test/Core/Metadata/ILBuilderVisualizer.cs (C#)

Code before:
            }

            return sb.ToString();
        }

        internal static string LocalSignatureToString(
            ILBuilder builder,
            Func<Cci.ILocalDefinition, LocalInfo>? mapLocal = null)
        {
            Debug.Assert(builder.LocalSlotManager != null);

            var sb = new StringBuilder();

            if (mapLocal == null)
            {
                mapLocal = local => new LocalInfo(local.Name, local.Type, local.IsPinned, local.IsReference);
            }

            var locals = builder.LocalSlotManager.LocalsInOrder().SelectAsArray(mapLocal);
            var visualizer = new ILBuilderVisualizer(builder.module);

            visualizer.VisualizeHeader(sb, -1, -1, locals);
            return sb.ToString();
        }

        private static void DumpBlockIL(ILBuilder.BasicBlock block, StringBuilder sb)
        {
            if (block is ILBuilder.SwitchBlock switchBlock)
            {
                DumpSwitchBlockIL(switchBlock, sb);
            }
            else
            {
                DumpBasicBlockIL(block, sb);
            }
        }

        private static void DumpBasicBlockIL(ILBuilder.BasicBlock block, StringBuilder sb)
        {
            var instrCnt = block.RegularInstructionsLength;
            if (instrCnt != 0)
            {
                var il = block.RegularInstructions.ToImmutableArray();
                new ILBuilderVisualizer(block.builder.module).DumpILBlock(il, instrCnt, sb, Array.Empty<ILVisualizer.HandlerSpan>(), block.Start);
            }

            if (block.BranchCode != ILOpCode.Nop)
            {
                sb.Append(string.Format("  IL_{0:x4}:", block.RegularInstructionsLength + block.Start));
                sb.Append(string.Format("  {0,-10}", GetInstructionName(block.BranchCode)));


Review comment (bug):
>used for debugger display of BasicBlock via reflection [](http://example.com/codeflow?start=66&length=54)

I didn't follow this. Could you elaborate how/when this is used? #Closed

Code after:
            }

            return sb.ToString();
        }

        internal static string LocalSignatureToString(
            ILBuilder builder,
            Func<Cci.ILocalDefinition, LocalInfo>? mapLocal = null)
        {
            Debug.Assert(builder.LocalSlotManager != null);

            var sb = new StringBuilder();

            if (mapLocal == null)
            {
                mapLocal = local => new LocalInfo(local.Name, local.Type, local.IsPinned, local.IsReference);
            }

            var locals = builder.LocalSlotManager.LocalsInOrder().SelectAsArray(mapLocal);
            var visualizer = new ILBuilderVisualizer(builder.module);

            visualizer.VisualizeHeader(sb, -1, -1, locals);
            return sb.ToString();
        }

#pragma warning disable IDE0051 // Remove unused private members, used for debugger display of BasicBlock via reflection
        private static string BasicBlockToString(ILBuilder.BasicBlock block)
#pragma warning restore IDE0051 // Remove unused private members
        {
            StringBuilder sb = new StringBuilder();
            DumpBlockIL(block, sb);
            return sb.ToString();
        }

        private static void DumpBlockIL(ILBuilder.BasicBlock block, StringBuilder sb)
        {
            if (block is ILBuilder.SwitchBlock switchBlock)
            {
                DumpSwitchBlockIL(switchBlock, sb);
            }
            else
            {
                DumpBasicBlockIL(block, sb);
            }
        }

        private static void DumpBasicBlockIL(ILBuilder.BasicBlock block, StringBuilder sb)
        {
            var instrCnt = block.RegularInstructionsLength;
            if (instrCnt != 0)
            {