protected override void CollectBlockSpans(
            RegionDirectiveTriviaSyntax regionDirective,
            ref TemporaryArray <BlockSpan> spans,
            BlockStructureOptionProvider optionProvider,
            CancellationToken cancellationToken)
        {
            var match = regionDirective.GetMatchingDirective(cancellationToken);

            if (match != null)
            {
                // Always auto-collapse regions for Metadata As Source. These generated files only have one region at
                // the top of the file, which has content like the following:
                //
                //   #region Assembly System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
                //   // C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Runtime.dll
                //   #endregion
                //
                // For other files, auto-collapse regions based on the user option.
                var autoCollapse = optionProvider.IsMetadataAsSource || optionProvider.GetOption(
                    BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp);

                spans.Add(new BlockSpan(
                              isCollapsible: true,
                              textSpan: TextSpan.FromBounds(regionDirective.SpanStart, match.Span.End),
                              type: BlockTypes.PreprocessorRegion,
                              bannerText: GetBannerText(regionDirective),
                              autoCollapse: autoCollapse,
                              isDefaultCollapsed: !optionProvider.IsMetadataAsSource));
            }
        }
        protected override void CollectBlockSpans(
            SyntaxToken previousToken,
            DocumentationCommentTriviaSyntax documentationComment,
            ref TemporaryArray <BlockSpan> spans,
            BlockStructureOptionProvider optionProvider,
            CancellationToken cancellationToken)
        {
            var startPos = documentationComment.FullSpan.Start;

            // The trailing newline is included in XmlDocCommentSyntax, so we need to strip it.
            var endPos = documentationComment.SpanStart + documentationComment.ToString().TrimEnd().Length;

            var span = TextSpan.FromBounds(startPos, endPos);

            var bannerLength = optionProvider.GetOption(BlockStructureOptions.MaximumBannerLength, LanguageNames.CSharp);
            var bannerText   = CSharpSyntaxFacts.Instance.GetBannerText(
                documentationComment, bannerLength, cancellationToken);

            spans.Add(new BlockSpan(
                          isCollapsible: true,
                          textSpan: span,
                          type: BlockTypes.Comment,
                          bannerText: bannerText,
                          autoCollapse: true));
        }