Home
Options

Exclude cyclic references from dump

edited January 28

Hi,

I don't think this is possible at the moment, but is there an easy way to exclude cyclic reference properties from dump output and, without having to resort to ToDump or manipulating the html?

For example this contrived code:

void Main()
{
    var houses = new List<House>();
    for (int h = 0; h < 3; h++)
    {
        var house = new House() { Number = 1 };
        house.Rooms = new List<Room>();
        for (int r = 0; r < 3; r++)
        {
            var room = new Room() { Name = $"Room{r}" };
            room.ContainingHouse = house;
            room.Chairs = new List<Chair>();
            for (int c = 0; c < 3; c++)
            {
                var chair = new Chair()
                {
                    ComfortLevel = c,
                    ContainingHouse = house,
                    ContainingRoom = room
                };
                room.Chairs.Add(chair);
            }
            house.Rooms.Add(room);
        }
        houses.Add(house);
    }
    houses.Dump();  
}

public class House
{
    public int Number { get; set; }
    public List<Room> Rooms { get; set; }
}

public class Room
{
    public string Name { get; set; }
    public House ContainingHouse { get; set; }
    public List<Chair> Chairs { get; set; }
}

public class Chair
{
    public House ContainingHouse { get; set; }
    public Room ContainingRoom { get; set; }
    public int ComfortLevel { get; set; }
}

...outputs like this:

but is it possible to prevent all cyclic reference properties, wherever they appear in the heirarchy, from being output at all?

Best regards

John

Comments

  • Options

    For now, I've reduced the space occupied by cyclic references in the latest beta, so the output will be less cluttered.

  • Options

    Excellent! Thank you. That's less ink which is great.

    I've added this to be even more muted, but it's really just an excuse to try out :has which works very nicely in LINQPad 8

    td.typeheader:has(> a.typeheader > .cyclic){
        background-color: #e9e9e9;
        color: #848484;
     }
     a.typeheader:has(> .cyclic){
        color: #848484;
     }
     table.limit {
        border: 1px #848484;
    }
    

    Thank you.

Sign In or Register to comment.