/// <summary> /// Executes the cleanup rules. /// </summary> /// <param name="options"> /// The options. /// </param> /// <param name="file"> /// The file to process. /// </param> public void Execute(ReadabilityOptions options, ICSharpFile file) { StyleCopTrace.In(options, file); bool dontPrefixCallsWithBaseUnlessLocalImplementationExists = options.SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists; bool codeMustNotContainEmptyStatements = options.SA1106CodeMustNotContainEmptyStatements; bool blockStatementsMustNotContainEmbeddedComments = options.SA1108BlockStatementsMustNotContainEmbeddedComments; bool blockStatementsMustNotContainEmbeddedRegions = options.SA1109BlockStatementsMustNotContainEmbeddedRegions; bool commentsMustContainText = options.SA1120CommentsMustContainText; bool useBuiltInTypeAlias = options.SA1121UseBuiltInTypeAlias; bool useStringEmptyForEmptyStrings = options.SA1122UseStringEmptyForEmptyStrings; bool dontPlaceRegionsWithinElements = options.SA1123DoNotPlaceRegionsWithinElements; bool codeMustNotContainEmptyRegions = options.SA1124CodeMustNotContainEmptyRegions; if (dontPlaceRegionsWithinElements) { this.DoNotPlaceRegionsWithinElements(file.FirstChild); } if (blockStatementsMustNotContainEmbeddedComments) { this.BlockStatementsMustNotContainEmbeddedComments(file.FirstChild); } if (blockStatementsMustNotContainEmbeddedRegions) { this.BlockStatementsMustNotContainEmbeddedRegions(file.FirstChild); } if (codeMustNotContainEmptyStatements) { this.CodeMustNotContainEmptyStatements(file.FirstChild); } if (codeMustNotContainEmptyRegions) { this.CodeMustNotContainEmptyRegions(file.FirstChild); } if (useStringEmptyForEmptyStrings) { ReplaceEmptyStringsWithStringDotEmpty(file.FirstChild); } if (useBuiltInTypeAlias) { SwapToBuiltInTypeAlias(file.FirstChild); } if (commentsMustContainText) { RemoveEmptyComments(file.FirstChild); } if (dontPrefixCallsWithBaseUnlessLocalImplementationExists) { this.DoNotPrefixCallsWithBaseUnlessLocalImplementationExists(file.FirstChild); } StyleCopTrace.Out(); }
/// <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); }