/// <summary>
        /// Determines if the specified item's children should be reorganized.
        /// </summary>
        /// <param name="parent">The parent item.</param>
        /// <returns>True if the parent's children should be reorganized, otherwise false.</returns>
        private bool ShouldReorganizeChildren(BaseCodeItemElement parent)
        {
            // Enumeration values should never be reordered.
            if (parent is CodeItemEnum)
            {
                return(false);
            }

            var parentAttributes = parent.Attributes;

            if (parentAttributes != null)
            {
                // Some attributes indicate that order is critical and should not be reordered.
                var attributesToIgnore = new[]
                {
                    "System.Runtime.InteropServices.ComImportAttribute",
                    "System.Runtime.InteropServices.StructLayoutAttribute"
                };

                if (parentAttributes.OfType <CodeAttribute>().Any(x => attributesToIgnore.Contains(x.FullName)))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Generates metadata strings for the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>The metadata strings.</returns>
        private IEnumerable <string> GenerateMetadataStrings(BaseCodeItemElement element)
        {
            var strings = new List <string>();

            if (element.IsStatic)
            {
                strings.Add(UseExtendedStrings ? "static" : "s");
            }

            return(strings);
        }
        /// <summary>
        /// Creates the inlines for the type.
        /// </summary>
        /// <param name="codeItemElement">The code item element.</param>
        /// <returns>The inlines representing the type.</returns>
        private IEnumerable <Inline> CreateInlinesForType(BaseCodeItemElement codeItemElement)
        {
            var inlines = new List <Inline>();

            var formattedTypeString = TypeFormatHelper.Format(codeItemElement.TypeString);

            if (!string.IsNullOrWhiteSpace(formattedTypeString))
            {
                inlines.Add(CreateTypeRun(" : "));
                inlines.Add(CreateTypeRun(formattedTypeString));
            }

            return(inlines);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets an access string from the specified code item.
        /// </summary>
        /// <param name="codeItem">The code item.</param>
        /// <returns>The access string, otherwise an empty string.</returns>
        private static string GetAccessString(BaseCodeItemElement codeItem)
        {
            if (codeItem == null)
            {
                return(string.Empty);
            }

            switch (codeItem.Access)
            {
            case vsCMAccess.vsCMAccessProject:
            case vsCMAccess.vsCMAccessAssemblyOrFamily: return("_Friend");

            case vsCMAccess.vsCMAccessPrivate: return("_Private");

            case vsCMAccess.vsCMAccessProjectOrProtected:
            case vsCMAccess.vsCMAccessProtected: return("_Protected");

            case vsCMAccess.vsCMAccessPublic: return(string.Empty);

            default: return(string.Empty);
            }
        }
        /// <summary>
        /// Determines if the specified item's children should be reorganized.
        /// </summary>
        /// <param name="parent">The parent item.</param>
        /// <returns>True if the parent's children should be reorganized, otherwise false.</returns>
        private bool ShouldReorganizeChildren(BaseCodeItemElement parent)
        {
            // Enumeration values should never be reordered.
            if (parent is CodeItemEnum)
            {
                return false;
            }

            var parentAttributes = parent.Attributes;
            if (parentAttributes != null)
            {
                // Some attributes indicate that order is critical and should not be reordered.
                var attributesToIgnore = new[]
                {
                    "System.Runtime.InteropServices.ComImportAttribute",
                    "System.Runtime.InteropServices.StructLayoutAttribute"
                };

                if (parentAttributes.OfType<CodeAttribute>().Any(x => attributesToIgnore.Contains(x.FullName)))
                {
                    return false;
                }
            }

            return true;
        }
        /// <summary>
        /// Gets an access string from the specified code item.
        /// </summary>
        /// <param name="codeItem">The code item.</param>
        /// <returns>The access string, otherwise an empty string.</returns>
        private static string GetAccessString(BaseCodeItemElement codeItem)
        {
            if (codeItem == null) return string.Empty;

            switch (codeItem.Access)
            {
                case vsCMAccess.vsCMAccessProject:
                case vsCMAccess.vsCMAccessAssemblyOrFamily: return "_Friend";
                case vsCMAccess.vsCMAccessPrivate: return "_Private";
                case vsCMAccess.vsCMAccessProjectOrProtected:
                case vsCMAccess.vsCMAccessProtected: return "_Protected";
                case vsCMAccess.vsCMAccessPublic: return string.Empty;
                default: return string.Empty;
            }
        }
        /// <summary>
        /// Generates metadata strings for the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>The metadata strings.</returns>
        private IEnumerable<string> GenerateMetadataStrings(BaseCodeItemElement element)
        {
            var strings = new List<string>();

            if (element.IsStatic)
            {
                strings.Add(UseExtendedStrings ? "static" : "s");
            }

            return strings;
        }