You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to read the elements of an InlineArray decorated type through the dotnet debugger produces incorrect results. The value read by the debugger will appear to have it's latter elements zeroed- as though it had been incompletely copied.
Reproduction
The issue can be reproduced by creating an instance of an InlineArray decorated type, then inspecting it's value with the debugger. This simple test program reproduces the issue. The type ILATest is a minimal InlineArray type —representing perhaps a vector. Our Main function simply constructs an ILATest and prints it’s contents.
using System;using System.Runtime.CompilerServices;publicclassProgram{[InlineArray(4)]privatestructILATest{privateintv;publicreadonlyintX=>this[0];publicreadonlyintY=>this[1];publicreadonlyintZ=>this[2];publicreadonlyintW=>this[3];publicvoidDeconstruct(outintx,outinty,outintz,outintw)=>(x, y, z, w)=(X, Y, Z, W);publicILATest(intx,inty,intz,intw){this[0]=x;this[1]=y;this[2]=z;this[3]=w;}publicreadonlyoverridestringToString(){return$"({this[0]}{this[1]}{this[2]}{this[3]})";}}publicstaticvoidMain(){ILATestv=new(3,2,1,0);var(x, y, z, w)= v;
Console.WriteLine(((ReadOnlySpan<int>)v).SequenceEqual([3,2,1,0]));
Console.WriteLine(v);// Place a breakpoint here, and inspect the value of v}}
Result
True
(3 2 1 0)
The program produces correct output, but any attached debugger will display the value of v incorrectly and inconsistently. In most functions, the latter elements (all but the first) will be displayed as zeroed, while direct attempts to access the variable's fields may sometimes display them correctly.
Visual studio immediate output
Attempting to evaluate the object in the debugger will display an incorrect value. v should display as (3 2 1 0) —matching console output— but instead the latter elements are displayed as zeros. In addition, we can see that the properties as read by the debugger appear to have incorrect values.
Despite this, directly accessing the properties and implied InlineArray indexer produces correct results. Worse than simply incorrect, this behavior is inconsistent.
In addition I have tested this test program in Visual Studio Code, which produced the exact same (incorrect) behavior, confirming that the problem is upstream of the GUI/IDE —e.g. the debugger.
Conclusions
The debugger cannot consistently read the elements of InlineArray types, frequently retrieving zeroes instead of the actual values. The fact that it is consistently the latter fields which get 'zeroed' suggests that the debugger is somehow executing an incomplete copy of the structure, or something like it.
The text was updated successfully, but these errors were encountered:
dotnet --version 8.0.403
Summary
Attempting to read the elements of an
InlineArray
decorated type through the dotnet debugger produces incorrect results. The value read by the debugger will appear to have it's latter elements zeroed- as though it had been incompletely copied.Reproduction
The issue can be reproduced by creating an instance of an
InlineArray
decorated type, then inspecting it's value with the debugger. This simple test program reproduces the issue. The typeILATest
is a minimalInlineArray
type —representing perhaps a vector. Our Main function simply constructs anILATest
and prints it’s contents.Result
The program produces correct output, but any attached debugger will display the value of
v
incorrectly and inconsistently. In most functions, the latter elements (all but the first) will be displayed as zeroed, while direct attempts to access the variable's fields may sometimes display them correctly.Visual studio immediate output
Attempting to evaluate the object in the debugger will display an incorrect value.
v
should display as(3 2 1 0)
—matching console output— but instead the latter elements are displayed as zeros. In addition, we can see that the properties as read by the debugger appear to have incorrect values.Despite this, directly accessing the properties and implied
InlineArray
indexer produces correct results. Worse than simply incorrect, this behavior is inconsistent.In addition I have tested this test program in Visual Studio Code, which produced the exact same (incorrect) behavior, confirming that the problem is upstream of the GUI/IDE —e.g. the debugger.
Conclusions
The debugger cannot consistently read the elements of
InlineArray
types, frequently retrieving zeroes instead of the actual values. The fact that it is consistently the latter fields which get 'zeroed' suggests that the debugger is somehow executing an incomplete copy of the structure, or something like it.The text was updated successfully, but these errors were encountered: