src/VisualStudio/Core/Def/Implementation/InheritanceMargin/InheritanceMarginHelpers.cs
/// <summary>
/// Create the view models for the inheritance targets of a single member.
/// There are two cases:
/// 1. If all the targets have the same inheritance relationship. It would be an array of TargetViewModel
/// e.g.
/// Target1ViewModel
/// Target2ViewModel
/// Target3ViewModel
///
/// 2. If targets belongs to different inheritance group. It would be grouped.
/// e.g.
/// Header1ViewModel
/// Target1ViewModel
/// Target2ViewModel
/// Header2ViewModel
/// Target1ViewModel
/// Target2ViewModel
/// </summary>
Create the view models for the inheritance targets of a single member.
There are two cases:
1. If all the targets have the same inheritance relationship. It would be an array of TargetViewModel
e.g.

2. If targets belongs to different inheritance group. It would be grouped.
Create the view models for the inheritance targets of a single member . There are two cases : 1 . If all the targets have the same inheritance relationship . It would be an array of TargetViewModel e . g . 2 . If targets belongs to different inheritance group . It would be grouped .
public static ImmutableArray<InheritanceMenuItemViewModel> CreateMenuItemViewModelsForSingleMember(ImmutableArray<InheritanceTargetItem> targets)
        {
            var targetsByRelationship = targets.OrderBy(target => target.DisplayName).GroupBy(target => target.RelationToMember)
                .ToImmutableDictionary(
                    keySelector: grouping => grouping.Key,
                    elementSelector: grouping => grouping);
            if (targetsByRelationship.Count == 1)
            {
                var (_, targetItems) = targetsByRelationship.Single();
                return targetItems.SelectAsArray(target => TargetMenuItemViewModel.Create(target, indent: false)).CastArray<InheritanceMenuItemViewModel>();
            }
            else
            {
                return targetsByRelationship.SelectMany(kvp => CreateMenuItemsWithHeader(kvp.Key, kvp.Value)).ToImmutableArray();
            }
        }
public static ImmutableArray < InheritanceMenuItemViewModel > CreateMenuItemViewModelsForSingleMember ( ImmutableArray < InheritanceTargetItem > targets ) { var targetsByRelationship = targets . OrderBy ( target => target . DisplayName ) . GroupBy ( target => target . RelationToMember ) . ToImmutableDictionary ( keySelector : grouping => grouping . Key , elementSelector : grouping => grouping ) ; if ( targetsByRelationship . Count == 1 ) { var ( _ , targetItems ) = targetsByRelationship . Single ( ) ; return targetItems . SelectAsArray ( target => TargetMenuItemViewModel . Create ( target , indent : false ) ) . CastArray < InheritanceMenuItemViewModel > ( ) ; } else { return targetsByRelationship . SelectMany ( kvp => CreateMenuItemsWithHeader ( kvp . Key , kvp . Value ) ) . ToImmutableArray ( ) ; } }
Create the view models for the inheritance targets of a single member.
Create the view models for the inheritance targets of a single member .
// If all targets have one relationship. // e.g. interface IBar { void Bar(); } // class A : IBar { void Bar() {} } // class B : IBar { void Bar() {} } // for 'IBar', the margin would be I↓. So header is not needed. // Otherwise, it means these targets has different relationship, // these targets would be shown in group, and a header should be shown as the first item to indicate the relationship to user.
targets
ImmutableArray<InheritanceTargetItem>