Resharper将代码格式化为单行

时间:2012-01-11 17:22:18

标签: c# resharper code-formatting

我遇到使用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));

这种格式也是不可取的。

2 个答案:

答案 0 :(得分:9)

换行和换行&gt;保留现有格式&gt;保持现有的换行符?

答案 1 :(得分:9)

确保Resharper&gt;选项&gt;代码编辑&gt; C#&gt;格式化样式&gt;换行和换行&gt; “Wrap Long Lines”已关闭