コード例 #1
0
ファイル: NCover.cs プロジェクト: cherylhanlon/Tigers
        /// <summary>
        /// Initializes a new instance of the <see cref="NCover"/> class.
        /// </summary>
        public NCover()
        {
            _commandLineExe = string.Empty;
            _commandLineArgs = string.Empty;
            _workingDirectory = string.Empty;
            _coverageFile = "coverage.xml";
            _logLevel = NCoverLogLevel.Normal;   // Since Quiet and Normal are same until Peter fixes bug.
            _logFile = "coverage.log";

            _assemblyList = string.Empty;
            _assemblyFiles = new ITaskItem[0];
            _settingsFile = string.Empty;

            _excludeAttributes = string.Empty;
            _profileIIS = false;
            _profileService = string.Empty;

            _registerProfiler = true;
            _xmlFormat = NCoverXmlFormat.Xml1;
            _profiledProcessModule = string.Empty;
        }
コード例 #2
0
ファイル: NCoverUtilities.cs プロジェクト: jsmithorg/Mvvm
        /// <summary>
        /// Builds the temp settings XML file for NCover.
        /// </summary>
        /// <param name="version">The version.</param>
        /// <param name="ncoverPath">The ncover path.</param>
        /// <param name="settingsFile">The settings file.</param>
        /// <param name="commandLineExe">The command line exe.</param>
        /// <param name="commandLineArgs">The command line args.</param>
        /// <param name="workingDirectory">The working directory.</param>
        /// <param name="assemblyList">The assembly list.</param>
        /// <param name="assemblyFiles">The assembly files.</param>
        /// <param name="coverageFile">The coverage file.</param>
        /// <param name="logLevel">The log level.</param>
        /// <param name="logFile">The log file.</param>
        /// <param name="excludeAttributes">The exclude attributes.</param>
        /// <param name="profileIIS">If set to <c>true</c> profile IIS.</param>
        /// <param name="profileService">The profile service.</param>
        /// <param name="xmlFormat">The XML format to write out (new feature in 1.5.7).</param>
        /// <param name="profiledProcessModule">Name of the profiled process.</param>
        /// <returns>
        /// Command line switch necessary for passing as an argument.
        /// </returns>
        internal static string BuildTempSettingsXmlFileForNCover(
            string version,
            string ncoverPath,
            string settingsFile,
            string commandLineExe,
            string commandLineArgs,
            string workingDirectory,
            string assemblyList,
            string[] assemblyFiles,
            string coverageFile,
            NCoverLogLevel logLevel,
            string logFile,
            string excludeAttributes,
            bool profileIIS,
            string profileService,
            NCoverXmlFormat xmlFormat,
            string profiledProcessModule)
        {
            if (version == null || version.Length == 0)
            {
                version = _ReadNCoverConsoleVersion(ncoverPath);
            }
            int versionNumber = int.Parse(version.Replace(".", ""));

            if (versionNumber < 150)
            {
                _BuildTempSettingsXmlFileForNCover133(
                    settingsFile, commandLineExe, commandLineArgs, workingDirectory,
                    assemblyList, assemblyFiles, coverageFile, logLevel, logFile);
                return "/r";
            }
            else
            {
                _BuildTempSettingsXmlFileForNCover15(
                    versionNumber, settingsFile, commandLineExe, commandLineArgs, workingDirectory,
                    assemblyList, assemblyFiles, coverageFile, logLevel, logFile, excludeAttributes,
                    profileIIS, profileService, xmlFormat, profiledProcessModule);
                return "//r";
            }
        }
コード例 #3
0
ファイル: NCoverUtilities.cs プロジェクト: jsmithorg/Mvvm
        /// <summary>
        /// Build the Xml .ncoversettings file to pass to the NCover.Console executable using NCover 1.5 syntax.
        /// </summary>
        private static void _BuildTempSettingsXmlFileForNCover15(
            int versionNumber,
            string settingsFile,
            string commandLineExe,
            string commandLineArgs,
            string workingDirectory,
            string assemblyList,
            string[] assemblyFiles,
            string coverageFile,
            NCoverLogLevel logLevel,
            string logFile,
            string excludeAttributes,
            bool profileIIS,
            string profileService,
            NCoverXmlFormat xmlFormat,
            string profiledProcessModule)
        {
            using (Stream fileStream = File.Create(settingsFile))
            {
                XmlTextWriter xmlTextWriter = new XmlTextWriter(fileStream, Encoding.UTF8);
                xmlTextWriter.Indentation = 2;
                xmlTextWriter.Formatting = Formatting.Indented;

                xmlTextWriter.WriteStartDocument();
                xmlTextWriter.WriteStartElement("ProfilerSettings");
                xmlTextWriter.WriteElementString("CommandLineExe", commandLineExe);
                if (commandLineArgs != null && commandLineArgs.Length > 0)
                {
                    xmlTextWriter.WriteElementString("CommandLineArgs", commandLineArgs);
                }
                if (workingDirectory != null && workingDirectory.Length >= 0)
                {
                    xmlTextWriter.WriteElementString("WorkingDirectory", workingDirectory);
                }

                // For NCover 1.5.4 onwards we write each assembly file as a separate node.
                _WriteAssemblyNodes(assemblyList, assemblyFiles, xmlTextWriter);

                if (coverageFile != null && coverageFile.Length >= 0)
                {
                    xmlTextWriter.WriteElementString("CoverageXml", coverageFile);
                    if (versionNumber >= 157)
                    {
                        xmlTextWriter.WriteElementString("XmlFormat", xmlFormat.ToString());
                    }
                }
                if (logLevel == NCoverLogLevel.Quiet)
                {
                    if (versionNumber == 154)
                    {
                        // HACK: Setting NoLog to "true" results in NCover hanging in the NCover 1.5.4 release
                        // For now we will just leave at false and always write a log file until Peter fixes it.
                        xmlTextWriter.WriteElementString("LogFile", logFile);
                        xmlTextWriter.WriteElementString("VerboseLog", "false");
                        xmlTextWriter.WriteElementString("NoLog", "false");
                    }
                    else
                    {
                        // NCover 1.5.5 onwards has the fix.
                        xmlTextWriter.WriteElementString("LogFile", string.Empty);
                        xmlTextWriter.WriteElementString("VerboseLog", "false");
                        xmlTextWriter.WriteElementString("NoLog", "true");
                    }
                }
                else
                {
                    xmlTextWriter.WriteElementString("LogFile", logFile);
                    xmlTextWriter.WriteElementString("VerboseLog", (logLevel == NCoverLogLevel.Verbose).ToString().ToLower());
                    xmlTextWriter.WriteElementString("NoLog", "false");
                }
                if (excludeAttributes != null && excludeAttributes.Length > 0)
                {
                    string[] eachExcludeAttributes = excludeAttributes.Split(';');
                    foreach (string excludeAttribute in eachExcludeAttributes)
                    {
                        xmlTextWriter.WriteElementString("ExclusionAttributes", excludeAttribute);
                    }
                }
                if (versionNumber >= 158 && profiledProcessModule.Length > 0)
                {
                    xmlTextWriter.WriteElementString("ProfileProcessModule", profiledProcessModule);
                }
                xmlTextWriter.WriteElementString("ProfileIIS", XmlConvert.ToString(profileIIS));
                if (profileService != null && profileService.Length > 0)
                {
                    xmlTextWriter.WriteElementString("ProfileService", profileService);
                }
                xmlTextWriter.WriteElementString("DumpOnErrorNormal", "false");
                xmlTextWriter.WriteElementString("DumpOnErrorFull", "false");
                // Some NCover 1.5.5 specific features
                if (versionNumber >= 155)
                {
                    xmlTextWriter.WriteElementString("CoverageBinary", "Coverage.bcv");
                    xmlTextWriter.WriteElementString("AutoExclude", "true");
                }

                xmlTextWriter.WriteEndElement(); // ProfilerSettings
                xmlTextWriter.WriteEndDocument();
                xmlTextWriter.Flush();

                fileStream.Close();
            }
        }
コード例 #4
0
ファイル: NCoverTask.cs プロジェクト: cherylhanlon/Tigers
        /// <summary>
        /// Initializes a new instance of the <see cref="NCoverTask"/> class.
        /// </summary>
        public NCoverTask()
        {
            _commandLineExe = string.Empty;
            _commandLineArgs = string.Empty;
            _workingDirectory = string.Empty;
            _coverageFile = "coverage.xml";
            _logLevel = NCoverLogLevel.Normal;
            _logFile = "coverage.log";

            _assemblyFiles = new FileSet();
            _assemblyList = string.Empty;
            _settingsFile = string.Empty;

            _excludeAttributes = string.Empty;
            _profileIIS = false;
            _profileService = string.Empty;

            _registerProfiler = true;
            _xmlFormat = NCoverXmlFormat.Xml1;
            _profiledProcessModule = string.Empty;

            this.ExeName = DefaultApplicationName;
            _programArguments = new StringBuilder();
        }