Resharper formatting code into a single line

夙愿已清 提交于 2019-12-18 21:26:12

问题


I am having an issue with formatting code with Resharper. I have disabled the option for wrapping lines. With this option, the following code will be formatted to a single line. Does anyone have an idea how to have Resharper not format the following code?

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));

If I enable line wrapping, the formatted code will come out like this:

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));

This formatting is also undesirable.


回答1:


Line Breaks and Wrapping > Preserve Existing Formatting > Keep existing line breaks?




回答2:


Make sure Resharper > Options > Code Editing > C# > Formatting Style > Line Breaks and Wrapping > "Wrap Long Lines" is turned OFF



来源:https://stackoverflow.com/questions/8823719/resharper-formatting-code-into-a-single-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!