Esempio n. 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);
        }
        //Logs all the breaking changes in a module as a unit (all cmdlets in the same module appear contigously)
        private void LogBreakingChangesInModule(BreakingChangeAttributesInModule moduleData, TextFileLogger logger)
        {
            string textForBreakingChangesInModule = string.Format(BREAKING_CHANGE_MODUE_HEADER_FORMAT_STRING, Path.GetFileName(moduleData.ModuleName));

            foreach (BreakingChangeAttributesInCmdlet cmdletData in moduleData.CmdletList)
            {
                textForBreakingChangesInModule += string.Format(BREAKING_CHANGE_CMDLET_HEADER_FORMAT_STRING, cmdletData.CmdletName);
                foreach (GenericBreakingChangeAttribute attribute in cmdletData.BreakingChangeAttributes)
                {
                    textForBreakingChangesInModule += attribute.GetBreakingChangeTextFromAttribute(cmdletData.CmdletType, true) + "\n\n";
                }
            }

            //Now that we have the text, add it to the log file
            logger.LogMessage(textForBreakingChangesInModule);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        //Logs all the breaking changes in a module as a unit (all cmdlets in the same module appear contiguously)
        private static void LogBreakingChangesInModule(BreakingChangeAttributesInModule moduleData, TextFileLogger logger)
        {
            var textForBreakingChangesInModule = string.Format(BreakingChangeModuleHeaderFormatString, Path.GetFileName(moduleData.ModuleName));

            foreach (var cmdletData in moduleData.CmdletList)
            {
                textForBreakingChangesInModule += string.Format(BreakingChangeCmdletHeaderFormatString, cmdletData.CmdletName);
// TODO: Remove IfDef code
#if !NETSTANDARD
                foreach (GenericBreakingChangeAttribute attribute in cmdletData.BreakingChangeAttributes)
                {
                    textForBreakingChangesInModule += attribute.GetBreakingChangeTextFromAttribute(cmdletData.CmdletType, true) + "\n\n";
                }
#endif
            }

            //Now that we have the text, add it to the log file
            logger.LogMessage(textForBreakingChangesInModule);
        }