4

I am using GhostDoc to create my XML comments and I am very happy with the format. I use the following format (c#)

    /// <summary>
    /// Creates new client.
    /// </summary>
    /// <param name="uri">The URI.</param>
    /// <param name="param">The param.</param>
    /// <returns></returns>

Using the code cleanup from R# 7.1.1 it reformats my xml comments, it even inserts new xml comments where there were missing, its really annoying. Is there a way to stop this.

I have created my own profiles for code cleanup and DISABLED everything (even the stylecop settings too) and I do a code cleanup and sure enough it wants to reformat my xml comments and place new ones where they were missing..

Anyone know how to get around this?

Thanks

Martin
  • 23,844
  • 55
  • 201
  • 327

4 Answers4

2

Most likely you are doing something wrong or you've hit a bug either in ReSharper or in StyleCop. You should:

  1. Try to disable StyleCop completely.
  2. Double check that you've disabled C# | Reformat embedded XML doc comments in your custom profile.
  3. Double check that you are indeed selecting this custom profile when invoking code cleanup.
  4. Create a sample solution where problem can be reproduced and contact ReSharper support. See http://www.jetbrains.com/support/resharper/
Dmitry Osinovskiy
  • 9,999
  • 1
  • 47
  • 38
  • Regarding "Try to disable StyleCop completely", do you have any suggestions beyond what the OP tried? [A related search](http://www.bing.com/search?q=turn+off+StyleCop&go=&qs=n&form=QBRE&pq=turn+off+stylecop&sc=3-17&sp=-1&sk=) leads me to think disabling all StyleCop rules (which is what I take the OP's description to mean) would do it. Maybe uninstalling StyleCop to help in the process of elimination would be best? Otherwise it occurs to me that of course the right level of StyleCop settings (i.e. all of them) would need to be disabled. – J0e3gan Apr 27 '13 at 06:51
  • 1
    @J0e3gan I'm not an expert on StyleCop, unfortunately, but I've dealt with certain "strange ReSharper bugs" that were in fact caused by StyleCop. It's not that StyleCop is bad, but everybody can make an error and I need to be certain that it is in fact my error. That's why rule number one when dealing with formatting errors for me is to ask user to temporary get rid of StyleCop completely. Disabling rules is not enough. Maybe there is an option to temporary unload StyleCop (for ReSharper you can go to Tools -> Options -> ReSharper -> Suspend) or maybe OP needs to temporary uninstall StyleCop. – Dmitry Osinovskiy Apr 28 '13 at 08:03
  • 1
    Understood - completely makes sense. I am not a StyleCop expert either, but I found a `csproj` file change to disable it in a given project - helpful for this kind of troubleshooting and other situations that warrant disabling StyleCop at a project level. An old MSKB [article](http://support.microsoft.com/kb/969475?wa=wsignin1.0) explains that adding `false` to the global config section of a project file will disable StyleCop for the project. I checked it out (using StyleCop 4.7), and it works great. – J0e3gan Apr 28 '13 at 17:30
  • Note that `false` affects [project _builds_ with integrated StyleCop analysis](http://blogs.msdn.com/b/sourceanalysis/archive/2008/05/24/source-analysis-msbuild-integration.aspx); but running StyleCop against a project on-demand (i.e. the usual way), it still generates warnings. The fix is to add `RulesEnabledByDefault` to the project's `Settings.StyleCop` file as outlined in [another SO answer](http://stackoverflow.com/a/15473696/1810429). `RulesEnabledByDefault` disables all rules regardless how StyleCop analysis of the project is run. – J0e3gan Apr 28 '13 at 19:55
1

I was having a similar problem. I used GhostDoc and R# Code Cleanup kept turning this

/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">The arguments.</param>

into this

/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">
/// The arguments.
/// </param>

It was infuriating because I had Reformat embedded XML doc comments deselected. I finally found the offending setting at ReSharper->Options->Code Cleanup->StyleCop->1611: Element Parameters Must Be Documented. I unchecked that, and it stopped screwing up my formatting.

You should be able to follow a similar approach with your own issues, substituting "Parameters" with whatever your problem is.

Travis
  • 1,044
  • 1
  • 17
  • 36
1

As another option,

Under Resharper > Options > Tools > StyleCop > Headers

select "Use single lines for declaration headers"

Luke Schoen
  • 674
  • 6
  • 23
0

RESHARPER > Options > StyleCop

Turn off Headers > Insert text into documentation and file headers

bipinkarms
  • 2,059
  • 2
  • 13
  • 6