diff --git a/src/StyleCop.ReSharper/CodeCleanup/StyleCopCodeCleanupModule.cs b/src/StyleCop.ReSharper/CodeCleanup/StyleCopCodeCleanupModule.cs
index b391dc2..14299a5 100644
--- a/src/StyleCop.ReSharper/CodeCleanup/StyleCopCodeCleanupModule.cs
+++ b/src/StyleCop.ReSharper/CodeCleanup/StyleCopCodeCleanupModule.cs
@@ -47,7 +47,8 @@ public class StyleCopCodeCleanupModule : ICodeCleanupModule
///
/// StyleCop descriptor.
///
- public static readonly StyleCopDescriptor Descriptor = new StyleCopDescriptor();
+ public static readonly FixViolationsDescriptor FIX_VIOLATIONS = new FixViolationsDescriptor();
+ public static readonly CreateXmlDocStubsDescriptor CREATE_XML_DOC_STUB = new CreateXmlDocStubsDescriptor ();
///
/// Gets the collection of option descriptors.
@@ -59,7 +60,7 @@ public ICollection Descriptors
{
get
{
- return new CodeCleanupOptionDescriptor[] { Descriptor };
+ return new CodeCleanupOptionDescriptor[] { FIX_VIOLATIONS, CREATE_XML_DOC_STUB };
}
}
@@ -138,15 +139,14 @@ public void Process(
return;
}
- StyleCopCodeCleanupOptions options = profile.GetSetting(Descriptor);
- if (!options.FixViolations)
+ if (!profile.GetSetting (FIX_VIOLATIONS))
{
return;
}
var services = solution.GetPsiServices();
- services.Transactions.Execute("Code cleanup", () => this.InternalProcess(projectFile.ToProjectFile(), file, options.CreateXmlDocStubs));
+ services.Transactions.Execute("Code cleanup", () => this.InternalProcess(projectFile.ToProjectFile(), file, profile.GetSetting(CREATE_XML_DOC_STUB)));
StyleCopTrace.Out();
}
@@ -162,7 +162,8 @@ public void Process(
///
public void SetDefaultSetting(CodeCleanupProfile profile, CodeCleanup.DefaultProfileType profileType)
{
- profile.SetSetting(Descriptor, new StyleCopCodeCleanupOptions());
+ profile.SetSetting(FIX_VIOLATIONS, value: true);
+ profile.SetSetting(CREATE_XML_DOC_STUB, value: false);
}
///
diff --git a/src/StyleCop.ReSharper/CodeCleanup/StyleCopDescriptor.cs b/src/StyleCop.ReSharper/CodeCleanup/StyleCopDescriptor.cs
index ecf4909..b81c9ef 100644
--- a/src/StyleCop.ReSharper/CodeCleanup/StyleCopDescriptor.cs
+++ b/src/StyleCop.ReSharper/CodeCleanup/StyleCopDescriptor.cs
@@ -11,117 +11,28 @@ namespace StyleCop.ReSharper.CodeCleanup
{
using System;
using System.ComponentModel;
- using System.Globalization;
- using System.Text;
- using System.Xml;
using JetBrains.ReSharper.Feature.Services.CodeCleanup;
- using JetBrains.Util;
- ///
- /// The style cop descriptor.
- ///
- [DisplayName("Fix StyleCop violations")]
- [Category(CSharpCategory)]
- [TypeConverter(typeof(ExpandableObjectConverter))]
- public class StyleCopDescriptor : CodeCleanupOptionDescriptor
+ [Category (CSharpCategory)]
+ [DisplayName ("Fix StyleCop violations")]
+ [DefaultValue (true)]
+ public class FixViolationsDescriptor : CodeCleanupBoolOptionDescriptor
{
- ///
- /// Initializes a new instance of the class.
- ///
- public StyleCopDescriptor()
- : base("StyleCop")
+ public FixViolationsDescriptor ()
+ : base ("FixViolations")
{
}
-
- ///
- /// Summarize the options for the Code Cleanup dialog
- ///
- ///
- /// The selected profile
- ///
- ///
- /// A string that summarizes the options
- ///
- public override string Present(CodeCleanupProfile profile)
- {
- return profile.GetSetting(this).ToString();
- }
-
- ///
- /// Save the options
- ///
- ///
- /// The parent XML element to add the options to
- ///
- ///
- /// The options to save
- ///
- public override void Save(XmlElement element, StyleCopCodeCleanupOptions value)
- {
- element.CreateLeafElementWithValue(
- "FixViolations",
- value.FixViolations.ToString(CultureInfo.InvariantCulture));
- element.CreateLeafElementWithValue(
- "CreateXmlDocStubs",
- value.CreateXmlDocStubs.ToString(CultureInfo.InvariantCulture));
- }
-
- ///
- /// Load the options
- ///
- ///
- /// The parent XML element
- ///
- ///
- /// A loaded instance of the options
- ///
- public override StyleCopCodeCleanupOptions Load(XmlElement element)
- {
- return new StyleCopCodeCleanupOptions
- {
- FixViolations = bool.Parse(XmlUtil.ReadLeafElementValue(element, "FixViolations")),
- CreateXmlDocStubs = bool.Parse(XmlUtil.ReadLeafElementValue(element, "CreateXmlDocStubs"))
- };
- }
}
- ///
- /// Options for code cleanup
- ///
- public class StyleCopCodeCleanupOptions
+ [Category (CSharpCategory)]
+ [DisplayName ("Create XML doc stubs")]
+ [DefaultValue (false)]
+ public class CreateXmlDocStubsDescriptor : CodeCleanupBoolOptionDescriptor
{
- ///
- /// Option to fix StyleCop violations
- ///
- [DisplayName("Fix StyleCop violations")]
- public bool FixViolations { get; set; }
-
- ///
- /// Options to generate XML doc stubs
- ///
- [DisplayName("Create XML doc stubs")]
- public bool CreateXmlDocStubs { get; set; }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public StyleCopCodeCleanupOptions()
- {
- this.FixViolations = true;
-
- // TODO: What's the best default?
- // I like the argument that we shouldn't blindly create XML docs, but set
- // them properly, but it's nice to be able to fix up everything we can...
- this.CreateXmlDocStubs = false;
- }
-
- public override string ToString()
+ public CreateXmlDocStubsDescriptor ()
+ : base ("CreateXmlDocStubs")
{
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.Append(this.FixViolations ? "Yes" : "No");
- stringBuilder.Append(this.CreateXmlDocStubs ? " (create XML doc stubs)" : " (do not create XML doc stubs)");
- return stringBuilder.ToString();
}
}
}
\ No newline at end of file
diff --git a/src/StyleCop.ReSharper/Options/CodeStyleOptions.cs b/src/StyleCop.ReSharper/Options/CodeStyleOptions.cs
index ee8e59a..4baf79d 100644
--- a/src/StyleCop.ReSharper/Options/CodeStyleOptions.cs
+++ b/src/StyleCop.ReSharper/Options/CodeStyleOptions.cs
@@ -341,7 +341,8 @@ public static void CodeStyleOptionsReset(IContextBoundSettingsStore settingsStor
SetCodeCleanupProfileSetting(styleCopProfile, "CSReorderTypeMembers", null, true);
- styleCopProfile.SetSetting(StyleCopCodeCleanupModule.Descriptor, new StyleCopCodeCleanupOptions());
+ styleCopProfile.SetSetting(StyleCopCodeCleanupModule.FIX_VIOLATIONS, value: true);
+ styleCopProfile.SetSetting(StyleCopCodeCleanupModule.CREATE_XML_DOC_STUB, value: false);
codeCleanupSettings.SetProfiles(profiles, settingsStore);
codeCleanupSettings.SetSilentCleanupProfileName(settingsStore, styleCopProfile.Name);
@@ -1406,8 +1407,9 @@ public static bool CodeStyleOptionsValid(IContextBoundSettingsStore settingsStor
return false;
}
- StyleCopCodeCleanupOptions options = styleCopProfile.GetSetting(StyleCopCodeCleanupModule.Descriptor);
- if (!options.FixViolations || options.CreateXmlDocStubs)
+ var fixViolations = styleCopProfile.GetSetting(StyleCopCodeCleanupModule.FIX_VIOLATIONS);
+ var createXmlDocStubs = styleCopProfile.GetSetting (StyleCopCodeCleanupModule.CREATE_XML_DOC_STUB);
+ if (!fixViolations || createXmlDocStubs)
{
return false;
}