当前位置 : 主页 > 网络编程 > net编程 >

VS2022之DebuggerVisualizer

来源:互联网 收集:自由互联 发布时间:2023-09-03
在Debug程序时,面对一些大集合,之前是这样查看的,如下图,这样看起来不直观,集合中的数据只能一个一个实体查看: VS2022预览版带来一个新功能,集合表格可视化,比如下面这样

  在Debug程序时,面对一些大集合,之前是这样查看的,如下图,这样看起来不直观,集合中的数据只能一个一个实体查看:

VS2022之DebuggerVisualizer_DebuggerVisualizer

   VS2022预览版带来一个新功能,集合表格可视化,比如下面这样一段代码:

using Bogus;
using System.Text.Unicode;

var addressFaker = new Faker<Address>()
.RuleFor(x => x.PostCode, x => x.Address.ZipCode())
.RuleFor(x => x.Province, x => x.Address.State())
.RuleFor(x => x.City, x => x.Address.City())
.RuleFor(x => x.Area, x => x.Address.StreetAddress());

var personFaker = new Faker<Member>()
.RuleFor(x => x.ID, x => x.Random.Guid())
.RuleFor(x => x.NO, x => x.Random.Long(100000000000, 999999999999))
.RuleFor(x => x.Name, x => x.Person.LastName + x.Person.FirstName)
.RuleFor(x => x.Sex, x => x.Random.Enum<Sex>())
.RuleFor(x => x.Email, x => x.Person.Email)
.RuleFor(x => x.Phone, x => x.Person.Phone)
.RuleFor(x => x.Age, x => x.Random.Int(0, 120))
.RuleFor(x => x.Balance, x => x.Finance.Amount(0, 1000))
.RuleFor(x => x.CreateOn, x => x.Date.Past(1))
.RuleFor(x => x.Addresses, x => addressFaker.Generate(5).ToList());

var members=personFaker.Generate(20).ToList();

Console.WriteLine(members.Count);

enum Sex
{
男,

}
class Member
{
public Guid ID { get; set; }
public long NO { get; set; }
public string? Name { get; set; }
public Sex Sex { get; set; }
public int Age { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public decimal Balance { get; set; }
public DateTime CreateOn { get; set; }

public List<Address>? Addresses { get; set; }
}

class Address
{
public string? PostCode { get; set; }
public string? Province { get; set; }
public string? City { get; set; }
public string? Area { get; set; }
}

  在Debug时,选中集合,点“查看”,有一个IEnumerable Visualizer的菜单,点击:

VS2022之DebuggerVisualizer_DebuggerVisualizer_02

   会弹出一个表格,这样的数据就直观多了,这个表格可以排序,隐藏列,展开列(比如这里的性别列),还可以把数据导出成Excel,以方便核对,可以说比之前人性化很多。

VS2022之DebuggerVisualizer_DebuggerVisualizer_03

   想要更快更方便的了解相关知识,可以关注微信公众号 

VS2022之DebuggerVisualizer_DebuggerVisualizer_04


【本文转自:韩国服务器 http://www.558idc.com/kt.html提供,感谢支持】
上一篇:WinForm混合Blazor(下)
下一篇:没有了
网友评论