MDbgValue
There dosen't seem to be a very handy way of Getting and Setting the Value of the MDbgValue
Here is some code I use to Get the Value
Private Function ExtractValueType(ByVal val As MDbgValue) As String
'This is a bit of a hack to get the value out.
'because mdbg doesn't seem to provide a nice interface
'to get the boxed value from the mdbgvalue
Dim res As String = val.GetStringValue(True)
Dim iret As Integer = res.IndexOf(vbLf)
If iret > 0 Then
res = res.Substring(0, iret)
End If
Dim valst As Integer = res.IndexOf("<"c) + 1
Dim valfn As Integer = res.IndexOf(">"c)
If valst > 0 AndAlso valfn > 0 Then
Return res.Substring(valst, valfn - valst)
End If
Return String.Empty
End Function
Are you talking specifically about boxed values? or are you talking in general with any possible type?
Check out "set" and "print" commands in mdbgcommands.cs to see examples of setting and getting mdbg values.
MdbgValue (for better or worse) is a high level wrapper over CorValue (which corresponds roughly to the raw unmanaged ICorDebugValue interface). MDbgValue tends to autoderefernce (and auto-unbox) to get to the "real" object. (see MDbgValue.InternalGetValue). The ICorDebugValue interface is complicated and I'm sure we can definitely make the wrappers more intuitive.
You can always use MDbgValue.CorValue to get the underlying CorValue (ICorDebugValue) object and then do full manipulation on that. To unbox that:
CorBoxValue boxVal = value.CastToBoxValue();
if(boxVal!=null) { value = boxVal.GetObject(); }