Visual Studio - debugging a huge list of objects

I am debugging the application, and at some point I have a list with the number of elements, which prevents me from following each element step by step. I wanted to check what value is inside the Layer property of an element with PropertyName = "XXX". Is there an easy way to do this?

Screen shot

External 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 cannot use Immediate Window and LINQ because LINQ is not allowed. I am using Visual Studio 2010, but as far as I know, other versions have the same "problem".

+4
source share
6 answers

I wanted to check what value is inside the property. Element layer with PropertyName = "XXX". Is there an easy way to do this?

, . .

:

PropertyName == "XXX"

, PropertyName = "XXX", .

+3

, DebuggerDisplayAttribute RequestDocumentMetadataItem MetadataItems

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

+2

List []. :

public class ComplexType
{
    public string PropertyName { get; set; }
    public string Layer { get; set; }
    public string DisplayName { get; set; }
}

public class DebuggableList : List<ComplexType>
{
    public ComplexType this[string key]
    {
        get
        {
            return this.FirstOrDefault(i => i.PropertyName == key);
        }
    }
}

class Program
{
    static void Main(string[] args)
    {
        var myList= new DebuggableList();

        myList.Add(new ComplexType { DisplayName = "XXX", Layer = "YYY", PropertyName = "ZZZ" });
        myList.Add(new ComplexType { DisplayName = "AAA", Layer = "BBB", PropertyName = "CCC" });
        myList.Add(new ComplexType { DisplayName = "DDD", Layer = "EEE", PropertyName = "FFF" });
    }
}

myList["XXX"], PropertyName == "XXX".

+1

, , ,

enter image description here

. , - , .

+1

You can write a static debugging class with helper functions for debugging. There are extensions that help debug VS itself, but I think that none of them are free.

0
source

Source: https://habr.com/ru/post/1589379/


All Articles