コード例 #1
0
        /// <summary>
        /// Creates a summary for the property.
        /// </summary>
        /// <param name="propertyDeclaration">
        /// The property declaration.
        /// </param>
        /// <returns>
        /// A String summary of the property.
        /// </returns>
        public static string CreateSummaryDocumentationForProperty(IPropertyDeclaration propertyDeclaration)
        {
            if (!StyleCopOptions.Instance.InsertTextIntoDocumentation)
            {
                return string.Empty;
            }

            IAccessor getter = propertyDeclaration.Getter();
            IAccessor setter = propertyDeclaration.Setter();
            string summaryText = string.Empty;

            string midText = Utils.IsPropertyBoolean(propertyDeclaration) ? "a value indicating whether " : string.Empty;

            if (getter != null)
            {
                summaryText = "Gets {0}{1}.";
            }

            if (setter != null)
            {
                AccessRights setterAccessRight = setter.GetAccessRights();

                if ((setterAccessRight == AccessRights.PRIVATE && propertyDeclaration.GetAccessRights() == AccessRights.PRIVATE)
                    || setterAccessRight == AccessRights.PUBLIC || setterAccessRight == AccessRights.PROTECTED || setterAccessRight == AccessRights.PROTECTED_OR_INTERNAL
                    || setterAccessRight == AccessRights.INTERNAL)
                {
                    if (string.IsNullOrEmpty(summaryText))
                    {
                        summaryText = "Sets {0}{1}.";
                    }
                    else
                    {
                        summaryText = "Gets or sets {0}{1}.";
                    }
                }
            }

            return string.Format(summaryText, midText, propertyDeclaration.DeclaredName);
        }
コード例 #2
0
        /// <summary>
        /// Creates a summary for the property.
        /// </summary>
        /// <param name="propertyDeclaration">
        /// The property declaration.
        /// </param>
        /// <returns>
        /// A String summary of the property.
        /// </returns>
        public static string CreateSummaryDocumentationForProperty(IPropertyDeclaration propertyDeclaration)
        {
            IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, propertyDeclaration.GetSolution());
            if (!settingsStore.GetValue((StyleCopOptionsSettingsKey key) => key.InsertTextIntoDocumentation))
            {
                return string.Empty;
            }

            IAccessor getter = propertyDeclaration.Getter();
            IAccessor setter = propertyDeclaration.Setter();
            string summaryText = string.Empty;

            string midText = IsPropertyBoolean(propertyDeclaration) ? "a value indicating whether " : string.Empty;

            if (getter != null)
            {
                summaryText = "Gets {0}{1}.";
            }

            if (setter != null)
            {
                AccessRights setterAccessRight = setter.GetAccessRights();

                if ((setterAccessRight == AccessRights.PRIVATE && propertyDeclaration.GetAccessRights() == AccessRights.PRIVATE)
                    || setterAccessRight == AccessRights.PUBLIC || setterAccessRight == AccessRights.PROTECTED || setterAccessRight == AccessRights.PROTECTED_OR_INTERNAL
                    || setterAccessRight == AccessRights.INTERNAL)
                {
                    if (string.IsNullOrEmpty(summaryText))
                    {
                        summaryText = "Sets {0}{1}.";
                    }
                    else
                    {
                        summaryText = "Gets or sets {0}{1}.";
                    }
                }
            }

            return string.Format(summaryText, midText, propertyDeclaration.DeclaredName);
        }