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

SpanBytes invalid output in debbuger #1407

Open
torbacz opened this issue Nov 22, 2023 · 2 comments
Open

SpanBytes invalid output in debbuger #1407

torbacz opened this issue Nov 22, 2023 · 2 comments

Comments

@torbacz
Copy link
Contributor

torbacz commented Nov 22, 2023

Tool

Visual Studio extension

Description

When using "Watch" or "Immediate" window SpanByte indexer is returning invalid data (always for first index?).

image

How to reproduce

  var bytes = new byte[] { 10, 20 };
  var spanBytes = new SpanByte(bytes);

  Console.WriteLine($"Array: [0] {bytes[0]} {bytes[1]}");
  Console.WriteLine($"Span: [0] {spanBytes[0]} {spanBytes[1]}");

Place breakpoint on last line and check "watch" window for spanBytes[1] and spanBytes[0]. Both returns "10", but [1] should be 20.

Expected behaviour

SpanBytes should reflect the same values in both console and watch window

Screenshots

No response

Aditional context

No response

@CoryCharlton
Copy link
Member

CoryCharlton commented Nov 22, 2023

I spent some time looking into this. Unfortunately I'm not sure where to find the relevant code so I've been focused on reproducing.

This appears to impact an class with an indexer that doesn't derive from Array. For instance the issue is reproducible with string. Checking test[0], test[1], or test[2] in the immediate/quick watch/etc. will display a (the value at index 0):

var testString = "abc";
Console.WriteLine($"string [0] {testString[0]}, [1] {testString[1]}, [2] {testString[2]}");

This simple test class will always display 0 as well:

public class TestIndexer
{
    public int this[int index] => index;
}

And this class will fail to retrieve a value at all (presumably becase 0 to being passed to the indexer):

public class TestCharIndexer
{
    public char this[char index] => index;
}

Long story short the issue definitely appears to be related with how the indexer is being parsed (or not parsed).

@josesimoes
Copy link
Member

Seems that our debugger is having a hard time figuring out what it the indexer...
At this time it's not clear what is missing, still requires some investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants