Inheritance: DataTypeBase
Example #1
0
        public void ScanFiltersFalseCorrectly()
        {
            // Arrange
            List<FilterBase> filters = new List<FilterBase>() {
                new MockFilter( false )
            };

            string filename = "harry.jpg";
            FileSet fs = new FileSet();
            fs.BaseDirectory = new DirectoryInfo( Path.GetDirectoryName( Assembly.GetExecutingAssembly().GetName().CodeBase.Substring( 8 ) ) ); // Get past file://
            fs.FileNames.Add( filename );

            Restrict restrict = new Restrict( filters, fs );

            // Irrelevant but not unhelpful
            Assert.AreEqual( 1, restrict.NestedFilterCount );

            // Act
            restrict.Scan();

            // Assert
            Assert.IsNotNull( restrict.FileNames );
            if ( restrict.FileNames.Count != 0 ) {
                string[] files = new string[restrict.FileNames.Count];
                restrict.FileNames.CopyTo( files, 0 );
                Assert.Fail( "It should've failed, but we have " + string.Join( ", ", files ) + " selected" );
            }
            Assert.IsTrue( restrict.hasScanned );
        }
Example #2
0
        protected override void SetUp() {
            base.SetUp();

            // create the file set
            _fileSet = new FileSet();
            _fileSet.BaseDirectory = TempDirectory;

            // create some test files to match against
            TempFile.CreateWithContents( 
@"world.peace
world.war
reefer.maddness",
            Path.Combine(TempDirName, "include.list")
            );
            TempFile.Create(Path.Combine(TempDirName, "world.peace"));
            TempFile.Create(Path.Combine(TempDirName, "world.war"));
            TempFile.Create(Path.Combine(TempDirName, "reefer.maddness"));
            TempFile.Create(Path.Combine(TempDirName, "reefer.saddness"));

            string sub1Path = Path.Combine(TempDirName, "sub1");
            Directory.CreateDirectory(sub1Path);
            TempFile.Create(Path.Combine(sub1Path, "sub.one"));
            string sub2Path = Path.Combine(TempDirName, "sub2");
            Directory.CreateDirectory(sub2Path);
        }
        /// <summary>
        /// Executes the task.
        /// </summary>
        protected override void ExecuteTask()
        {
            String baseFolder = this.CreateBaseDir ();
            DocSet docSet = this.CreateDocSet ();
            IEnumerable<Framework> frameworks = this.CreateFrameworks (docSet);

            foreach (var f in frameworks) {
                if (f.source != DocumentOrigin.Doxygen) {
                    continue;
                }

                this.Log(Level.Info, "Copying header files for '{0}'...", f.name);

                FileSet fileSet = new FileSet();
                fileSet.BaseDirectory = new DirectoryInfo(f.path);
                fileSet.Includes.Add("**/*.h");

                CopyTask copyTask = new CopyTask();
                copyTask.Project = this.Project;
                copyTask.FailOnError = true;
                if (docSet != null) {
                    copyTask.ToDirectory = new DirectoryInfo(Path.Combine(baseFolder, docSet.Name, f.name, DocumentType.Source.ToString()));
                } else {
                    copyTask.ToDirectory = new DirectoryInfo(Path.Combine(baseFolder, f.name, DocumentType.Source.ToString()));
                }
                copyTask.CopyFileSet = fileSet;
                copyTask.Filters = this.Filters;
                copyTask.Execute();
            }
        }
Example #4
0
 // Parameter is used for testing
 public Restrict( List<FilterBase> Filters, FileSet Files )
     : this()
 {
     if ( Filters != null ) {
         this.filters.AddRange( Filters );
     }
     this.Files = Files;
 }
Example #5
0
 public void CaseSensitive () {
     FileSet fileSet = new FileSet ();
     Assert.AreEqual (PlatformHelper.IsUnix, fileSet.CaseSensitive, "#1");
     fileSet.CaseSensitive = true;
     Assert.IsTrue (fileSet.CaseSensitive, "#2");
     fileSet.CaseSensitive = false;
     Assert.IsFalse (fileSet.CaseSensitive, "#3");
 }
Example #6
0
        public void InitFindsProperties()
        {
            FileSet fs = new FileSet();
            Restrict restrict = new Restrict( fs );
            // Init didn't throw, ASSUME we win

            // Irrelevant but not unhelpful
            Assert.AreEqual( 0, restrict.NestedFilterCount );
        }
        public static int Count(FileSet[] fileSets)
        {
            Ensure.ArgumentIsNotNull(fileSets, "fileSets");

            int count = 0;
            foreach (FileSet assemblies in fileSets)
            {
                count += assemblies.FileNames.Count;
            }

            return count;
        }
        public static IEnumerable<string> Flatten(FileSet[] fileSets)
        {
            Ensure.ArgumentIsNotNull(fileSets, "fileSets");

            foreach (FileSet assemblySet in fileSets)
            {
                foreach (string fileName in assemblySet.FileNames)
                {
                    yield return fileName;
                }
            }
        }
Example #9
0
        public void NestedFilitersInited()
        {
            // Arrange
            MockNestedFilter mock = new MockNestedFilter( true );
            List<FilterBase> filters = new List<FilterBase>() {
                mock
            };
            FileSet fs = new FileSet();

            Restrict restrict = new Restrict( filters, fs );

            // Irrelevant but not unhelpful
            Assert.AreEqual( 1, restrict.NestedFilterCount );

            // Act
            restrict.Scan();

            // Assert
            Assert.AreEqual( true, mock.NestedInitializeCalled );
        }
Example #10
0
        public void BaseDirIsFilesBaseDir()
        {
            // Arrange
            List<FilterBase> filters = new List<FilterBase>() {
                new MockFilter( false )
            };

            string filename = "somefile";
            FileSet fs = new FileSet();
            fs.BaseDirectory = new DirectoryInfo( Path.GetDirectoryName( Assembly.GetExecutingAssembly().GetName().CodeBase.Substring( 8 ) ) ); // Get past file://
            fs.FileNames.Add( filename );

            Restrict restrict = new Restrict( filters, fs );

            // Act
            // Nothing to do, it should be set already

            // Assert
            Assert.AreEqual( restrict.BaseDirectory, fs.BaseDirectory );
        }
Example #11
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="fs"></param>
 public FileSet(FileSet fs)
 {
     fs.CopyTo((FileSet)this);
 }
Example #12
0
 /// <summary>
 /// Copy constructor for <see cref="FileSet" />. Required in order to
 /// assign references of <see cref="FileSet" /> type where
 /// <see cref="DirSet" /> is used.
 /// </summary>
 /// <param name="fs">A <see cref="FileSet" /> instance to create a <see cref="DirSet" /> from.</param>
 public DirSet(FileSet fs) : base(fs)
 {
 }
Example #13
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="fs"></param>
 public FileSet(FileSet fs)
 {
     fs.CopyTo((FileSet)this);
 }
		void RunSpecifications(FileSet[] assemblies, ISpecificationRunner runner)
		{
			Ensure.ArgumentIsNotNull(assemblies, "assemblies");
			Ensure.ArgumentIsNotNull(runner, "runner");

			foreach (string fileName in FileSetHelper.Flatten(assemblies))
			{
				RunSpecificationAssembly(fileName, runner);
			}
		}
Example #15
0
        /// <summary>
        /// Determines if a VB project needs to be recompiled by comparing the timestamp of 
        /// the project's files and references to the timestamp of the last built version.
        /// </summary>
        /// <param name="projectFile">The file name of the project file.</param>
        /// <returns>
        /// <see langword="true" /> if the project should be compiled; otherwise,
        /// <see langword="false" />.
        /// </returns>
        protected bool ProjectNeedsCompiling(string projectFile)
        {
            // return true as soon as we know we need to compile
            FileSet sources = new FileSet();
            FileSet references = new FileSet();

            string basedir = Path.GetDirectoryName(projectFile);
            if (basedir != "" ) {
                sources.BaseDirectory = new DirectoryInfo(Path.GetDirectoryName( projectFile ) );
                references.BaseDirectory = sources.BaseDirectory;
            }

            string outputFile = ParseProjectFile(projectFile, sources, references);

            FileInfo outputFileInfo = new FileInfo(OutDir != null ? Path.Combine(OutDir.FullName, outputFile) : outputFile);
            if (!outputFileInfo.Exists) {
                Log(Level.Info, "Output file '{0}' does not exist, recompiling.",
                    outputFileInfo.FullName);
                return true;
            }
            // look for a changed project file.
            string fileName = FileSet.FindMoreRecentLastWriteTime( projectFile, outputFileInfo.LastWriteTime);
            if (fileName != null) {
                Log(Level.Info, "{0} is out of date, recompiling.", fileName);
                return true;
            }
            // check for a changed source file
            fileName = FileSet.FindMoreRecentLastWriteTime(sources.FileNames, outputFileInfo.LastWriteTime);
            if (fileName != null) {
                Log(Level.Info, "{0} is out of date, recompiling.", fileName);
                return true;
            }
            // check for a changed reference
            if (CheckReferences) {
                fileName = FileSet.FindMoreRecentLastWriteTime(references.FileNames, outputFileInfo.LastWriteTime);
                if (fileName != null) {
                    Log(Level.Info, "{0} is out of date, recompiling.", fileName);
                    return true;
                }
            }
            return false;
        }
Example #16
0
 protected virtual void SetBuildParameters()
 {
     this.TaskEngine.CompressionType = this.CompressionType;
     this.TaskEngine.DeleteSourceFiles = this.DeleteSourceFiles;
     this.TaskEngine.EncodingType = this.EncodingType;
     this.TaskEngine.LineBreakPosition = this.LineBreakPosition;
     this.TaskEngine.LoggingType = this.LoggingType;
     this.TaskEngine.OutputFile = this.OutputFile;
     var fileSpecs = new List<FileSpec>();
     if (this.SourceFiles == null)
     {
         return;
     }
     foreach (var sourceFile in this.SourceFiles.Includes)
     {
         fileSpecs.Add(new FileSpec(sourceFile, string.Empty));
     }
     this.TaskEngine.SourceFiles = fileSpecs.ToArray();
 }
Example #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NDoc2Task"/> class.
        /// </summary>
        public NDoc2Task()
        {
            _assemblies = new FileSet();
            _summaries = new FileSet();
            _referencePaths = new DirSet();

            _programArguments = new StringBuilder();

            _configName = DefaultConfigName;
            ExeName = DefaultApplicationName;
        }
Example #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NCoverExplorerTask"/> class.
        /// </summary>
        public NCoverExplorerTask()
        {
            _coverageFiles = new FileSet();
            _configName = string.Empty;
            _satisfactoryCoverage = 100;
            _minimumCoverage = 100;
            _reportType = CoverageReportType.ModuleSummary;
            _treeSortStyle = TreeSortStyle.Name;
            _treeFilterStyle = TreeFilterStyle.None;

            _programArguments = new StringBuilder();
            _coverageExclusions = new CoverageExclusionCollection();
            _moduleThresholds = new ModuleThresholdCollection();

            ExeName = DefaultApplicationName;
        }
Example #19
0
        public void Test_NewestFile() {
            string file1 = this.CreateTempFile("testfile1.txt", "hellow");
            string file2 = this.CreateTempFile("testfile2.txt", "hellow");
            string file3 = this.CreateTempFile("testfile3.txt", "hellow");
            string file4 = this.CreateTempFile("testfile4.txt", "hellow");

            //file1 was created first, but we will set the time in the future.
            FileInfo f1 = new FileInfo(file1);
            f1.LastWriteTime = DateTime.Now.AddDays(2);

            FileSet fs = new FileSet();
            fs.Includes.Add(file1);
            fs.Includes.Add(file2);
            fs.Includes.Add(file3);
            fs.Includes.Add(file4);

            FileInfo newestfile = fs.MostRecentLastWriteTimeFile;

            Assert.IsTrue(f1.FullName == newestfile.FullName, "Most Recent File should be '{0}', but was '{1}'", f1.Name, newestfile.Name);
        }
        private void ProcessPlatform(XmlNode platformNode)
        {
            // process platform task assemblies
            if (!ScannedTasks) {
                FileSet platformTaskAssemblies = new FileSet();
                platformTaskAssemblies.BaseDirectory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
                platformTaskAssemblies.Project = Project;
                platformTaskAssemblies.NamespaceManager = NamespaceManager;
                platformTaskAssemblies.Parent = Project; // avoid warnings by setting the parent of the fileset
                platformTaskAssemblies.ID = "platform-task-assemblies"; // avoid warnings by assigning an id
                XmlNode taskAssembliesNode = platformNode.SelectSingleNode(
                    "nant:task-assemblies", NamespaceManager);
                if (taskAssembliesNode != null) {
                    platformTaskAssemblies.Initialize(taskAssembliesNode,
                        Project.Properties, null);
                }

                // scan platform extensions assemblies
                LoadTasksTask loadTasks = new LoadTasksTask();
                loadTasks.Project = Project;
                loadTasks.NamespaceManager = NamespaceManager;
                loadTasks.Parent = Project;
                loadTasks.TaskFileSet = platformTaskAssemblies;
                loadTasks.FailOnError = false;
                loadTasks.Threshold = (Project.Threshold == Level.Debug) ?
                    Level.Debug : Level.Warning;
                loadTasks.Execute();

                // scan NAnt.Core
                TypeFactory.ScanAssembly(Assembly.GetExecutingAssembly(), loadTasks);
            }

            // process the framework nodes of the current platform
            ProcessFrameworks(platformNode);

            // process runtime framework task assemblies
            if (!ScannedTasks) {
                LoadTasksTask loadTasks = new LoadTasksTask();
                loadTasks.Project = Project;
                loadTasks.NamespaceManager = NamespaceManager;
                loadTasks.Parent = Project;
                loadTasks.TaskFileSet = Project.RuntimeFramework.TaskAssemblies;
                loadTasks.FailOnError = false;
                loadTasks.Threshold = (Project.Threshold == Level.Debug) ?
                    Level.Debug : Level.Warning;
                loadTasks.Execute();

                // ensure we don't scan task assemblies for the current
                // runtime framework and platform again
                ScannedTasks = true;
            }
        }
Example #21
0
        protected FrameworkInfo(SerializationInfo info, StreamingContext context)
        {
            _name = info.GetString("Name");
            _family = info.GetString("Family");
            _description = info.GetString("Description");
            _status = (InitStatus) info.GetValue("Status", typeof(InitStatus));
            _clrType = (ClrType) info.GetValue("ClrType", typeof(ClrType));
            _version = (Version) info.GetValue("Version", typeof(Version));
            _clrVersion = (Version) info.GetValue("ClrVersion", typeof(Version));
            _vendor = (VendorType) info.GetValue("Vendor", typeof(VendorType));
            if (_status != InitStatus.Valid) {
                return;
            }

            _frameworkDirectory = (DirectoryInfo) info.GetValue("FrameworkDirectory", typeof(DirectoryInfo));
            _sdkDirectory = (DirectoryInfo) info.GetValue("SdkDirectory", typeof(DirectoryInfo));
            _frameworkAssemblyDirectory = (DirectoryInfo) info.GetValue("FrameworkAssemblyDirectory", typeof(DirectoryInfo));
            _runtime = (Runtime) info.GetValue("Runtime", typeof(Runtime));
            _project = (Project) info.GetValue("Project", typeof(Project));
            _taskAssemblies = (FileSet) info.GetValue("TaskAssemblies", typeof(FileSet));
            _referenceAssemblies = (FileSet[]) info.GetValue("ReferenceAssemblies", typeof(FileSet[]));
            _toolPaths = (string[]) info.GetValue("ToolPaths", typeof(string[]));
        }
Example #22
0
        private void CountLines(FileSet TargetFileSet, string label)
        {
            _lineCount = 0;
            _commentLineCount = 0;
            _emptyLinesCount = 0;
            _fileNames = new ArrayList();
            _fileNames.Capacity = TargetFileSet.FileNames.Count;

            FileCodeCountInfo fileInfo;

            foreach(string file in TargetFileSet.FileNames) {
                fileInfo = CountFile(file);
                _lineCount += fileInfo.LineCount;
                _emptyLinesCount += fileInfo.EmptyLineCount;
                _commentLineCount += fileInfo.CommentLineCount;
                _fileNames.Add(fileInfo);
            }

            _fileNames.TrimToSize();
            Log(Level.Info, "Totals:\t[{0}] \t[T] {1}\t[C] {2}\t[E] {3}",
                label, _lineCount, _commentLineCount, _emptyLinesCount);
        }
Example #23
0
 /// <summary>
 /// Creates a shallow copy of the <see cref="FileSet" />.
 /// </summary>
 /// <returns>
 /// A shallow copy of the <see cref="FileSet" />.
 /// </returns>
 public virtual object Clone()
 {
     FileSet clone = new FileSet();
     CopyTo(clone);
     return clone;
 }
 private static FileSet CreateFileSet(string fileName)
 {
     var fileSet = new FileSet();
     fileSet.FileNames.Add(fileName);
     return fileSet;
 }
Example #25
0
        /// <summary>
        /// Copies all instance data of the <see cref="FileSet" /> to a given
        /// <see cref="FileSet" />.
        /// </summary>
        protected void CopyTo(FileSet clone)
        {
            base.CopyTo(clone);

            clone._asis = StringUtils.Clone(_asis);
            if (_baseDirectory != null) {
                clone._baseDirectory = new DirectoryInfo(_baseDirectory.FullName);
            }
            clone._defaultExcludes = _defaultExcludes;
            clone._failOnEmpty = _failOnEmpty;
            clone._hasScanned = _hasScanned;
            clone._pathFiles = _pathFiles.Clone();
            clone._scanner = (DirectoryScanner) _scanner.Clone();
        }
Example #26
0
        /// <summary>
        /// Parses a VB project file and extracts the source files, reference files, and 
        /// the name of the compiled file for the project.
        /// </summary>
        /// <param name="projectFile">The filename of the project file.</param>
        /// <param name="sources">
        /// A fileset representing the source files of the project, which will
        /// populated by the method.
        /// </param>
        /// <param name="references">
        /// A fileset representing the references of the project, which will
        /// populated by the method.
        /// </param>
        /// <returns>A string containing the output file name for the project.</returns>
        private string ParseProjectFile(string projectFile, FileSet sources, FileSet references)
        {
            if (!File.Exists(Project.GetFullPath(projectFile))) {
                throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                    "Visual Basic project file '{0}' does not exist.", projectFile),
                    Location);
            }

            string outputFile = null;
            string fileLine = null;
            string projectName = null;
            string projectType = null;

            //# Modified each regular expressioni to properly parse the project references in the vbp file #
            // Regexp that extracts INI-style "key=value" entries used in the VBP
            Regex keyValueRegEx = new Regex(@"(?<key>\w+)\s*=\s*(?<value>.*($^\.)*)\s*$");

            // Regexp that extracts source file entries from the VBP (Class=,Module=,Form=,UserControl=)
            Regex codeRegEx = new Regex(@"(Class|Module)\s*=\s*\w*;\s*(?<filename>.*($^\.)*)\s*$");

            // Regexp that extracts reference entries from the VBP (Reference=)
            Regex referenceRegEx = new Regex(@"(Object|Reference)\s*=\s*({|\*\\G{)(?<tlbguid>[0-9\-A-Fa-f]*($^\.)*)}\#(?<majorver>[0-9a-fA-F($^\.)]*)\.(?<minorver>[0-9a-fA-F($^\.)]*)\#(?<lcid>[0-9]($^\.)*)(;|\#)(?<tlbname>[^\#\n\r]*)");

            string key = String.Empty;
            string keyValue = String.Empty;

            Match match = null;
            using (StreamReader reader = new StreamReader(Project.GetFullPath(projectFile), Encoding.ASCII)) {
                while ((fileLine = reader.ReadLine()) != null) {
                    match = keyValueRegEx.Match(fileLine);
                    if (!match.Success) {
                        continue;
                    }

                    key = match.Groups["key"].Value;
                    keyValue = match.Groups["value"].Value;

                    switch (key) {
                        case "Class":
                        case "Module":
                            // This is a class or module source file - extract the file name and add it to the sources fileset
                            // The entry is of the form "Class=ClassName;ClassFile.cls"
                            match = codeRegEx.Match(fileLine);
                            if (match.Success) {
                                sources.Includes.Add(match.Groups["filename"].Value);
                            }
                            break;
                        case "Designer":
                        case "Form":
                        case "UserControl":
                        case "PropertyPage":
                        case "ResFile32":
                            // This is a form, control, or property page source file - add the file name to the sources fileset
                            // The entry is of the form "Form=Form1.frm"
                            sources.Includes.Add(keyValue.Trim('"'));
                            break;
                        case "Object":
                        case "Reference":
                            // This is a source file - extract the reference name and add it to the references fileset
                            match = referenceRegEx.Match(fileLine);
                            if (!match.Success) {
                                break;
                            }

                            string tlbName = match.Groups["tlbname"].Value;
                            if (File.Exists(tlbName)) {
                                references.Includes.Add(tlbName);
                            } else {
                                // the tlb filename embedded in the VBP file is just
                                // a hint about where to look for it. If the file isn't
                                // at that location, the typelib ID is used to lookup
                                // the file name

                                string temp = match.Groups["majorver"].Value;
                                ushort majorVer = 0;
                                if (key == "Object") {
                                    // for OCX's major is a decimal value
                                    majorVer = ushort.Parse(temp, CultureInfo.InvariantCulture);
                                } else {
                                    // for dll's major is a hex value
                                    majorVer = (ushort) Convert.ToUInt16(temp, 16);
                                }

                                // minor is considered a hex value
                                temp = match.Groups["minorver"].Value;
                                ushort minorVer16 = Convert.ToUInt16(temp, 16);

                                temp = match.Groups["lcid"].Value;
                                uint lcid = 0;

                                if (temp.Length != 0) {
                                    lcid = (uint) double.Parse(temp, CultureInfo.InvariantCulture);
                                }

                                string tlbGuid = match.Groups["tlbguid"].Value;
                                Guid guid = new Guid(tlbGuid);

                                // find the type library file
                                tlbName = VB6GetTypeLibFile(guid, majorVer, minorVer16, lcid);
                                if (tlbName == null) {
                                    Log(Level.Warning, "Type library '{0}' version {1}.{2:x} could not be found.",
                                        guid, match.Groups["majorver"].Value, match.Groups["minorver"].Value);
                                } else {
                                    if (File.Exists(tlbName)) {
                                        references.Includes.Add(tlbName);
                                    } else {
                                        Log(Level.Warning, "Type library file '{0}' does not exist.", tlbName);
                                    }
                                }
                            }
                            break;
                        case "ExeName32":
                            // Store away the built file name so that we can check against it later
                            // If the project was never built in the IDE, or the project file wasn't saved
                            // after the build occurred, this setting won't exist. In that case, VB uses the
                            // ProjectName as the DLL/EXE name
                            outputFile = keyValue.Trim('"');
                            break;
                        case "Type":
                            // Store away the project type - we may need it to construct the built
                            // file name if ExeName32 doesn't exist
                            projectType = keyValue;
                            break;
                        case "Name":
                            // Store away the project name - we may need it to construct the built
                            // file name if ExeName32 doesn't exist
                            projectName = keyValue.Trim('"');
                            break;
                    }
                }
                reader.Close();
            }

            if (outputFile == null) {
                // The output file name wasn't specified in the project file, so
                // We need to figure out the output file name from the project name and type
                if (projectType == "Exe" || projectType == "OleExe") {
                    outputFile = Path.ChangeExtension(projectName, ".exe");
                } else if (projectType == "OleDll") {
                    outputFile = Path.ChangeExtension(projectName, ".dll");
                } else if (projectType == "Control") {
                    outputFile = Path.ChangeExtension(projectName, ".ocx");
                }
            }

            return outputFile;
        }
Example #27
0
 /// <summary>
 /// Copy constructor for <see cref="FileSet" />. Required in order to 
 /// assign references of <see cref="FileSet" /> type where 
 /// <see cref="DirSet" /> is used.
 /// </summary>
 /// <param name="fs">A <see cref="FileSet" /> instance to create a <see cref="DirSet" /> from.</param>
 public DirSet(FileSet fs) : base(fs) {
 }
 private void CountLines(FileSet TargetFileSet, string label)
 {
     this._lineCount = 0;
     this._commentLineCount = 0;
     this._emptyLinesCount = 0;
     this._fileNames = new ArrayList();
     this._fileNames.Capacity = TargetFileSet.FileNames.Count;
     StringEnumerator enumerator1 = TargetFileSet.FileNames.GetEnumerator();
     while (enumerator1.MoveNext())
     {
         string text1 = enumerator1.Current;
         IsmCodeStatsTask.FileCodeCountInfo info1 = this.CountFile(text1);
         this._lineCount += info1.LineCount;
         this._emptyLinesCount += info1.EmptyLineCount;
         this._commentLineCount += info1.CommentLineCount;
         this._fileNames.Add(info1);
     }
     this._fileNames.TrimToSize();
     this.Log(Level.Info, "Totals:\t[{0}] \t[T] {1}\t[C] {2}\t[E] {3}", new object[] { label, this._lineCount, this._commentLineCount, this._emptyLinesCount });
 }
Example #29
0
        /// <summary>
        /// Create a .nunit project file listing the test assemblies.
        /// </summary>
        /// <param name="nunitProjectFileName">Full filename of the .nunit file.</param>
        /// <param name="testFileSet">Fileset containing the test assemblies.</param>
        /// <param name="appConfig">Optional path to App.Config file to include in project.</param>
        /// <param name="appBase">Optional path to the nunit app base, when included full paths to each assembly (relative to the appbase) are included</param>
        private void _CreateNUnitProjectFile(string nunitProjectFileName, FileSet testFileSet, string appConfig, string appBase)
        {
            XmlTextWriter writer = null;
            try
            {
                // Delete any existing .nunit project file
                if (File.Exists(nunitProjectFileName))
                {
                    File.Delete(nunitProjectFileName);
                }

                // Determine if we're going to use appbase
                bool useAppBase = (appBase != null && appBase.Length > 0);

                // Get the directory info for the app base
                DirectoryInfo appBaseDirectory = null;
                if (useAppBase)
                {
                    appBaseDirectory = new DirectoryInfo(appBase);
                }

                // Create a new .nunit project file (which has xml format).
                writer = new XmlTextWriter(nunitProjectFileName, Encoding.Default);
                writer.Formatting = Formatting.Indented;

                //<NUnitProject>
                writer.WriteStartElement("NUnitProject");

                //	<Settings activeconfig="Debug" appbase="C:\Projects\TestProject" />
                writer.WriteStartElement("Settings");
                writer.WriteAttributeString("activeConfig", "Debug");
                if (useAppBase)
                {
                    writer.WriteAttributeString("appbase", appBase);
                }
                writer.WriteEndElement();

                //  <Config name="Debug" configfile="App.config" binpathtype="Auto">
                writer.WriteStartElement("Config");
                writer.WriteAttributeString("name", "Debug");
                if (appConfig != null && appConfig.Length > 0)
                {
                    writer.WriteAttributeString("configfile", appConfig);
                }
                writer.WriteAttributeString("binpathtype","Auto");

                // Now iterate through each of the test assemblies.
                foreach (string pathName in testFileSet.FileNames)
                {
                    FileInfo testAssemblyInfo = new FileInfo(pathName);
                    if (testAssemblyInfo.Exists)
                    {
                        //    <assembly path="Bin\MyApplication.Testing.Business.dll" />
                        writer.WriteStartElement("assembly");
                       if (useAppBase)
                        {
                            writer.WriteAttributeString("path", testAssemblyInfo.FullName.Substring(appBaseDirectory.FullName.Length + 1));
                        }
                        else
                        {
                            writer.WriteAttributeString("path", testAssemblyInfo.Name);
                        }
                        writer.WriteEndElement();
                    }
                }

                //  </Config>
                writer.WriteEndElement();

                //  <Config name="Release" binpathtype="Auto" />
                writer.WriteStartElement("Config");
                writer.WriteAttributeString("name", "Release");
                writer.WriteAttributeString("binpathtype","Auto");
                writer.WriteEndElement();

                //</NUnitProject>
                writer.WriteEndElement();
            }
            catch (Exception ex)
            {
                Log(Level.Error, ex.Message);
                string errorMessage = string.Format(CultureInfo.InvariantCulture,
                    "An error occurred while creating file: {0}", nunitProjectFileName);

                throw new BuildException(errorMessage, Location, ex);
            }
            finally
            {
                if (writer != null)
                {
                    writer.Flush();
                    writer.Close();
                }
            }
        }
Example #30
0
        public void EmailMessageFromFileTest()
        {
            string methodName = "EmailMessageFromFileTest()";
            FileSet fileSet = new FileSet();
            fileSet.FileNames.AddRange(_files.ToArray());

            MailTask mailTask = new MailTask();
            mailTask.Project = CreateEmptyProject();

            mailTask.Mailhost = _mailHost;
            mailTask.Port = _port;
            mailTask.From = _fromEmail;
            mailTask.ToList = CreateEmailListString(_twoEmails);
            mailTask.Subject = String.Format(_subjectText, methodName);
            mailTask.Files = fileSet;

            mailTask.Execute();

            Assert.AreEqual(1, _smtpServer.ReceivedEmailCount);
        }
Example #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolutionTask" /> class.
 /// </summary>
 public SolutionTask()
 {
     _customproperties = new ArrayList();
     _projects = new FileSet();
     _referenceProjects = new FileSet();
     _excludeProjects = new FileSet();
     _assemblyFolders = new FileSet();
     _webMaps = new WebMapCollection();
     _projectFactory = ProjectFactory.Create(this);
     _solutionFactory = SolutionFactory.Create();
     _configuration = new Configuration ();
 }
Example #32
0
 public PeVerifyTask()
 {
     Assemblies= new FileSet();
 }