/// <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);
        }
Exemple #2
0
        /// <summary>
        /// The Execute method.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <param name="file">
        /// The file.
        /// </param>
        public void Execute(LayoutOptions options, ICSharpFile file)
        {
            StyleCopTrace.In(options, file);

            Param.RequireNotNull(options, "options");
            Param.RequireNotNull(file, "file");

            bool curlyBracketsForMultiLineStatementsMustNotShareLine = options.SA1500CurlyBracketsForMultiLineStatementsMustNotShareLine;
            bool openingCurlyBracketsMustNotBePrecededByBlankLine = options.SA1509OpeningCurlyBracketsMustNotBePrecededByBlankLine;
            bool chainedStatementBlocksMustNotBePrecededByBlankLine = options.SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine;
            bool whileDoFooterMustNotBePrecededByBlankLine = options.SA1511WhileDoFooterMustNotBePrecededByBlankLine;
            bool singleLineCommentsMustNotBeFollowedByBlankLine = options.SA1512SingleLineCommentsMustNotBeFollowedByBlankLine;
            bool closingCurlyBracketMustBeFollowedByBlankLine = options.SA1513ClosingCurlyBracketMustBeFollowedByBlankLine;
            bool elementDocumentationHeadersMustBePrecededByBlankLine = options.SA1514ElementDocumentationHeaderMustBePrecededByBlankLine;
            bool singleLineCommentsMustBeProceededByBlankLine = options.SA1515SingleLineCommentMustBeProceededByBlankLine;

            if (singleLineCommentsMustBeProceededByBlankLine)
            {
                this.CommentsMustBePreceededByBlankLine(file.FirstChild);
            }

            if (singleLineCommentsMustNotBeFollowedByBlankLine)
            {
                this.CommentsMustNotBeFollowedByBlankLine(file.FirstChild);
            }

            if (closingCurlyBracketMustBeFollowedByBlankLine)
            {
                ClosingCurlyBracketMustBeFollowedByBlankLine(file.FirstChild);
            }

            if (whileDoFooterMustNotBePrecededByBlankLine)
            {
                this.WhileDoFooterMustNotBePrecededByBlankLine(file.FirstChild);
            }

            if (chainedStatementBlocksMustNotBePrecededByBlankLine)
            {
                this.ChainedStatementBlocksMustNotBePrecededByBlankLine(file.FirstChild);
            }

            if (openingCurlyBracketsMustNotBePrecededByBlankLine)
            {
                this.OpeningCurlyBracketsMustNotBePrecededByBlankLine(file.FirstChild);
            }

            if (elementDocumentationHeadersMustBePrecededByBlankLine)
            {
                this.ElementDocumentationHeadersMustBePrecededByBlankLine(file.FirstChild);
            }

            if (curlyBracketsForMultiLineStatementsMustNotShareLine)
            {
                this.CurlyBracketsForMultiLineStatementsMustNotShareLine(file.FirstChild);
            }

            StyleCopTrace.Out();
        }