I have a class with the following properties
Public Class PetClass
Public Enum Animal
Bird = 1
Dog = 2
Cat = 3
End Enum
Public MyPetType As Animal = Animal.Cat
Public MyPetName As String = "BigMeow"
End Class
When I declare it like this...
Dim n As New PetClass
... and then hover the mouse over it, I see the following:
I love how it displays the properties, especially the enum to string with the numeric representation in { }.
I would like to be able to print all this info in the debug console.
I don't think that this is possible, so I think I need to re-create this view so that I can then print my custom approach to the debug console.
I have tried to get the properties with the following code found here:
Public Sub DisplayAll(ByVal Someobject)
Dim _type As Type = Someobject.GetType()
Dim properties() As PropertyInfo = _type.GetProperties() 'line 3
For Each _property As PropertyInfo In properties
Console.WriteLine("Name: " + _property.Name + ", Value: " + _property.GetValue(Someobject, Nothing))
Next
End Sub
However, no PropertyInfo is found for my class.
Why?
If that is because of missing Getters / Setters:
Using explicit Getters / Setters is the very last option that I would like to try. There are over 100 properties in my real class, and I have chosen the current design for a reason.
Thank you!
Edit: I have added a new property using Getting / Setters like this:
Public Property SomeTest() As String
Get
Return "foo"
End Get
Set(value As String)
End Set
End Property
This property is listed in "DisplayAll", but as I have explained, I don't want to use getters / setters, and Visual Studio can seemingly also work without it, as it can display the properties just fine: