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

User Story 1556891: [MIEngine Natvis] Support multi-dimensional arrays #1346

Merged
merged 13 commits into from
Sep 9, 2022
6 changes: 5 additions & 1 deletion src/MIDebugEngine/Natvis.Impl/Natvis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,10 @@ private IVariableInformation[] ExpandVisualized(IVariableInformation variable)
string expressionValue = GetExpressionValue(item.Rank, variable, visualizer.ScopedNames);
rank = Int32.Parse(expressionValue, CultureInfo.InvariantCulture);
}
if (rank <= 0)
{
throw new Exception("Invalid rank value");
gregg-miskelly marked this conversation as resolved.
Show resolved Hide resolved
}
dimensions = new uint[rank];
gc46 marked this conversation as resolved.
Show resolved Hide resolved
for (int idx = 0; idx < rank; idx++)
{
Expand Down Expand Up @@ -655,7 +659,7 @@ private IVariableInformation[] ExpandVisualized(IVariableInformation variable)
for (uint index = 0; index < requestedSize; ++index)
{
string displayName = (startIndex + index).ToString(CultureInfo.InvariantCulture);
if (rank > 0)
if (rank > 1)
{
displayName = GetDisplayNameFromArrayIndex(index, rank, dimensions, isForward);
}
Expand Down
4 changes: 2 additions & 2 deletions test/CppTests/Tests/NatvisTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public void TestArrayItems(ITestSettings settings)
Assert.Equal("51", ll.GetVariable("[More...]").GetVariable("[51]").Value);

// Multi-dimensional array
var c = currentFrame.GetVariable("c");
Assert.Equal("3", c.GetVariable("[1,1]").Value);
var matrix = currentFrame.GetVariable("matrix");
Assert.Equal("3", matrix.GetVariable("[1,1]").Value);
}

runner.Expects.ExitedEvent(exitCode: 0).TerminatedEvent().AfterContinue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class C
class SimpleMatrix
{
public:
int m_size1;
int m_size2;
bool m_fUseSize1;
int* m_pData;

C(int size1, int size2, bool fUseSize1)
SimpleMatrix(int size1, int size2, bool fUseSize1)
{
m_size1 = size1;
m_size2 = size2;
Expand Down
4 changes: 2 additions & 2 deletions test/CppTests/debuggees/natvis/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "SimpleVector.h"
#include "SimpleArray.h"
#include "SimpleClass.h"
#include "C.h"
#include "SimpleMatrix.h"

class SimpleDisplayObject
{
Expand Down Expand Up @@ -46,7 +46,7 @@ int main(int argc, char** argv)
SimpleClass* simpleClass = nullptr;
simpleClass = new SimpleClass();

C c(5, 8, false);
SimpleMatrix matrix(5, 8, false);

return 0;
}