Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete debugger story for ReadOnlySequence #25178

Closed
pakrym opened this issue Feb 24, 2018 · 6 comments
Closed

Complete debugger story for ReadOnlySequence #25178

pakrym opened this issue Feb 24, 2018 · 6 comments
Assignees
Milestone

Comments

@pakrym
Copy link
Contributor

pakrym commented Feb 24, 2018

We need to add implementation for ReadOnlySequence<char> same as in Span<char> and Memory<char>.

We also need a better way to display positions - with masks removed, possibly segments visualized.

/cc @ahsonkhan @davidfowl @KrzysztofCwalina

@pakrym pakrym self-assigned this Feb 24, 2018
@benaadams
Copy link
Member

You've got two separate issues here; want to move

We need to add implementation for ReadOnlySequence same as in Span and Memory.

To a different issue as it will currently break for char; however have fixes; and handling for string additionally in dotnet/corefx#27455

@benaadams
Copy link
Member

Code for

// IMemoryList<Byte>[90] 10 .. 100
// OwnedMemory<Byte>[100] 0 .. 100
// Char[8] 10 .. 18
// "Hello"

image

[DebuggerDisplay("{DebuggerDisplay,nq}")]
public readonly partial struct ReadOnlySequence<T>
{
    private string DebuggerDisplay
    {
        // Output:
        // IMemoryList<Byte>[90] 10 .. 100
        // OwnedMemory<Byte>[100] 0 .. 100
        // Char[8] 10 .. 18
        get
        {
            if (_sequenceStart.Segment == null)
            {
                return "(default)";
            }

            GetTypeAndIndices(_sequenceStart.Index, _sequenceEnd.Index, out SequenceType type, out var startIndex, out var endIndex);
            if (type == SequenceType.String)
            {
                return "\"" + ((string)_sequenceStart.Segment).Substring(startIndex, endIndex - startIndex) + "\"";
            }
            string typeName;
            if (type == SequenceType.Array)
            {
                typeName = $"{typeof(T).Name}[{Length}]";
            }
            else
            {
                typeName = $"{type}<{typeof(T).Name}>[{Length}]";
            }
            string range;
            if (type == SequenceType.IMemoryList)
            {

                var start = (IMemoryList<T>)_sequenceStart.Segment;
                var end = (IMemoryList<T>)_sequenceEnd.Segment;
                range = $"{start.RunningIndex + startIndex} .. {end.RunningIndex + endIndex}";
            }
            else
            {
                range = $"{startIndex} .. {endIndex}";
            }

            return $"{typeName} {range}";
        }
    }
}

@muratg
Copy link

muratg commented Mar 7, 2018

@joshfree removing @pakrym until we are done with preview2.

@joshfree
Copy link
Member

joshfree commented Apr 3, 2018

related dotnet/corefx#27338

@joshfree
Copy link
Member

@pakrym can this issue be closed now?

@karelz
Copy link
Member

karelz commented Apr 25, 2018

@pakrym was it fully addressed in dotnet/corefx#28857 or were there additional changes for this? (double checking that all necessary parts made it into 2.1)

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants