C# · 12月 25, 2021

c#将Resharper格式化代码转换成一行

我有一个与Resharper格式化代码的问题.我已经禁用包装线的选项.使用此选项,以下代码将格式化为单行.有没有人有一个想法如何让Resharper不格式化以下代码? Mapper.CreateMap<CountryEntity,Country>() .ForMember(dest => dest.CreatedBy,map => map.MapFrom(src => src.CreatedBy)) .ForMember(dest => dest.DateCreated,map => map.MapFrom(src => src.DateCreated)) .ForMember(dest => dest.Id,map => map.MapFrom(src => src.Id)) .ForMember(dest => dest.Name,map => map.MapFrom(src => src.Name)) .ForMember(dest => dest.CountryCodeChar2,map => map.MapFrom(src => src.CountryCodeChar2)) .ForMember(dest => dest.CountryCodeChar3,map => map.MapFrom(src => src.CountryCodeChar3));

如果我启用换行,格式化的代码将会像这样出来:

Mapper.CreateMap<CountryEntity,Country>().ForMember( dest => dest.CreatedBy,map => map.MapFrom(src => src.CreatedBy)).ForMember( dest => dest.DateCreated,map => map.MapFrom(src => src.DateCreated)).ForMember( dest => dest.Id,map => map.MapFrom(src => src.Id)).ForMember( dest => dest.Name,map => map.MapFrom(src => src.Name)).ForMember( dest => dest.CountryCodeChar2,map => map.MapFrom(src => src.CountryCodeChar2)).ForMember( dest => dest.CountryCodeChar3,map => map.MapFrom(src => src.CountryCodeChar3));

这种格式也是不合需要的.

解决方法 换行和包装>保留现有格式>保留现有换行符?