9

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. How can I 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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
chafnan
  • 457
  • 1
  • 7
  • 13
  • I have Resharper 6.1.37.86 with default settings for formatting. I used Resharper's 'Cleanup Code...' functionality with all presets and got just the normal behavior (what you show in the first sample). Are you sure you don't have any other VS extensions that might mess up formatting? – Cristian Lupascu Jan 11 '12 at 17:39
  • Is your clean up profile using "Reformat Code" option under the C# section? – chafnan Jan 11 '12 at 18:34
  • @chafnan Yes, I even tried 'Full Cleanup' which has pretty much everything turned on – Cristian Lupascu Jan 11 '12 at 19:02

2 Answers2

9

Make sure ReSharper → OptionsCode EditingC#Formatting StyleLine Breaks and Wrapping"Wrap Long Lines" is turned off.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
9

Use Line Breaks and WrappingPreserve Existing FormattingKeep existing line breaks.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jura Gorohovsky
  • 9,886
  • 40
  • 46