Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - debug huge list of objects

I'm debugging an application and in some moment, I have a list with amount of items, which prevent me watch each element step by step. I wanted to check what value is inside property Layer of element with PropertyName = "XXX". Is there any simple way to do that?

Screenshot

Outer piece of code:

var metadata = FieldsConfigurationProvider.GetAllFieldsConfiguration();
RequestDocumentTypeModel model = new RequestDocumentTypeModel()
{
    Requester = CurrentUser.Login,
    MetadataItems = metadata.Where(f => !f.IsSystemGenerated).Select(f => new RequestDocumentMetadataItem(f.DocumentModelPropertyName, f.DisplayName, false, f.Layer)).ToList()
};

// BREAKPOINT HERE
// # MORE CODE #

Of course I can't use Immediate Window and LINQ, because LINQ isn't allowed. I'm using Visual Studio 2010, but as far as I know, other versions have the same "problem".

like image 987
Fka Avatar asked Jan 08 '23 08:01

Fka


2 Answers

If you need to check the whole list at once, try DebuggerDisplayAttribute on the RequestDocumentMetadataItem in MetadataItems

[DebuggerDisplay("DisplayName = {DisplayName} PropertyName = {PropertyName}")]

like image 56
Eric Avatar answered Jan 16 '23 05:01

Eric


I wanted to check what value is inside property Layer of element with PropertyName = "XXX". Is there any simple way to do that?

Yes, you can specify a breakpoint condition. Then it stops only when the condition is met.

In your case:

PropertyName == "XXX"

How to: Specify a Breakpoint Condition

Remember that you never specify a condition like PropertyName = "XXX" since that changes the variable value silently.

like image 20
Tim Schmelter Avatar answered Jan 16 '23 04:01

Tim Schmelter