I have an no named object created in a "with block".
With Factory.CreateSomeObject()
.SomeProp = someValue
...
End With
My question is: how can I inspect the object when the debugger is in break mode?
I have an no named object created in a "with block".
With Factory.CreateSomeObject()
.SomeProp = someValue
...
End With
My question is: how can I inspect the object when the debugger is in break mode?
I think this is not possible, but you can use an additional line:
Dim someObj As Object = Factory.CreateSomeObject()
With someObj
.SomeProp = someValue
End With
With this solution you can inspect on the first line.
Some additional information on StackOverflow (similar question).
When I set a breakpoint on a line within a With
block, The object returned from the function shows up in the Locals window. This is using VS2015. Further, if I right click on the function name on the With
line and choose "Add Watch", the object is visible in the watch window.
My code:
Module Module1
Sub Main()
With FunctionThatCreatesAnA()
Console.WriteLine("{0}, {1}", .SomeString, .SomeInteger)
End With
Console.ReadLine()
End Sub
Function FunctionThatCreatesAnA() As ClassA
Return New ClassA With {.SomeString = "Blah Blah", .SomeInteger = 42}
End Function
End Module
Public Class ClassA
Public Property SomeString() As String
Public Property SomeInteger() As Integer
End Class
Locals window:
Watch window: