コード例 #1
0
        /// <summary>
        /// Get cmdlets from the given assembly
        /// </summary>
        /// <param name="assmeblyPath"></param>
        /// <returns></returns>
        public BreakingChangeAttributesInModule GetModuleBreakingChangeAttributes(string assemblyPath)
        {
            var results = new List <BreakingChangeAttributesInCmdlet>();

            try
            {
                var assembly = Assembly.LoadFrom(assemblyPath);
                foreach (var type in assembly.GetCmdletTypes())
                {
                    var cmdlet = type.GetAttribute <CmdletAttribute>();
// TODO: Remove IfDef code
#if !NETSTANDARD
                    var attributes = type.GetAttributes <GenericBreakingChangeAttribute>();

                    if (attributes != null && (attributes.Count() > 0))
                    {
                    }
#endif
                    var cmdletMetadata = new BreakingChangeAttributesInCmdlet
                    {
                        CmdletType = type,
                        CmdletName = cmdlet.VerbName + "-" + cmdlet.NounName,
// TODO: Remove IfDef code
#if !NETSTANDARD
                        BreakingChangeAttributes = attributes.ToList()
#endif
                    };

                    results.Add(cmdletMetadata);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (!results.Any())
            {
                return(null);
            }

            var attributesInTheModule = new BreakingChangeAttributesInModule
            {
                ModuleName = assemblyPath, CmdletList = results
            };

            return(attributesInTheModule);
        }
コード例 #2
0
        /// <summary>
        /// Get cmdlets from the given assembly
        /// </summary>
        /// <param name="assmeblyPath"></param>
        /// <returns></returns>
        public BreakingChangeAttributesInModule GetModuleBreakingChangeAttributes(string assemblyPath)
        {
            List <BreakingChangeAttributesInCmdlet> results = new List <BreakingChangeAttributesInCmdlet>();

            try
            {
                var assembly = Assembly.LoadFrom(assemblyPath);
                foreach (var type in assembly.GetCmdletTypes())
                {
                    var cmdlet     = type.GetAttribute <CmdletAttribute>();
                    var attributes = type.GetAttributes <GenericBreakingChangeAttribute>();

                    if (attributes != null && (attributes.Count() > 0))
                    {
                    }
                    var cmdletMetadata = new BreakingChangeAttributesInCmdlet
                    {
                        CmdletType = type,
                        CmdletName = cmdlet.VerbName + "-" + cmdlet.NounName,
                        BreakingChangeAttributes = attributes.ToList()
                    };

                    results.Add(cmdletMetadata);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (results.Count() > 0)
            {
                var attributesInTheModule = new BreakingChangeAttributesInModule();

                attributesInTheModule.ModuleName = assemblyPath;
                attributesInTheModule.CmdletList = results;
                return(attributesInTheModule);
            }
            else
            {
                return(null);
            }
        }