/// <summary> /// Get default setting for given profile type. /// </summary> /// <param name="profile"> /// The code cleanup profile to use. /// </param> /// <param name="profileType"> /// Determine if it is a full or reformat <see cref="CodeCleanup.DefaultProfileType"/>. /// </param> public void SetDefaultSetting(CodeCleanupProfile profile, CodeCleanup.DefaultProfileType profileType) { // Default option are set in the constructors. OrderingOptions orderingOptions = new OrderingOptions(); profile.SetSetting(OrderingDescriptor, orderingOptions); LayoutOptions layoutOptions = new LayoutOptions(); profile.SetSetting(LayoutDescriptor, layoutOptions); DocumentationOptions documentationOptions = new DocumentationOptions(); profile.SetSetting(DocumentationDescriptor, documentationOptions); SpacingOptions spacingOptions = new SpacingOptions(); profile.SetSetting(SpacingDescriptor, spacingOptions); ReadabilityOptions readabilityOptions = new ReadabilityOptions(); profile.SetSetting(ReadabilityDescriptor, readabilityOptions); MaintainabilityOptions maintainabilityOptions = new MaintainabilityOptions(); profile.SetSetting(MaintainabilityDescriptor, maintainabilityOptions); }
/// <summary> /// Implement the Execute method. /// </summary> /// <param name="options"> /// The options. /// </param> /// <param name="file"> /// The file to use. /// </param> public void Execute(SpacingOptions options, ICSharpFile file) { StyleCopTrace.In(options, file); Param.RequireNotNull(options, "options"); Param.RequireNotNull(file, "file"); bool commasMustBeSpacedCorrectly = options.SA1001CommasMustBeSpacedCorrectly; bool singleLineCommentsMustBeginWithSingleSpace = options.SA1005SingleLineCommentsMustBeginWithSingleSpace; bool preprocessorKeywordsMustNotBePrecededBySpace = options.SA1006PreprocessorKeywordsMustNotBePrecededBySpace; bool negativeSignsMustBeSpacedCorrectly = options.SA1021NegativeSignsMustBeSpacedCorrectly; bool positiveSignsMustBeSpacedCorrectly = options.SA1022PositiveSignsMustBeSpacedCorrectly; bool codeMustNotContainMultipleWhitespaceInARow = options.SA1025CodeMustNotContainMultipleWhitespaceInARow; if (codeMustNotContainMultipleWhitespaceInARow) { this.CodeMustNotContainMultipleWhitespaceInARow(file.ToTreeNode().FirstChild); } if (commasMustBeSpacedCorrectly) { this.CommasMustBeSpacedCorrectly(file.ToTreeNode().FirstChild); } if (singleLineCommentsMustBeginWithSingleSpace) { this.SingleLineCommentsMustBeginWithSingleSpace(file.ToTreeNode().FirstChild); } if (preprocessorKeywordsMustNotBePrecededBySpace) { this.PreprocessorKeywordsMustNotBePrecededBySpace(file.ToTreeNode().FirstChild); } if (negativeSignsMustBeSpacedCorrectly) { this.NegativeAndPositiveSignsMustBeSpacedCorrectly(file.ToTreeNode().FirstChild, CSharpTokenType.MINUS); } if (positiveSignsMustBeSpacedCorrectly) { this.NegativeAndPositiveSignsMustBeSpacedCorrectly(file.ToTreeNode().FirstChild, CSharpTokenType.PLUS); } StyleCopTrace.Out(); }