示例#1
0
        public void CreateFormsGrid()
        {
            // Remove excessive underlines from Form and Test links.
            ((DataGridViewLinkColumn)MainWindow.FormsGrid.Columns[0]).LinkBehavior = LinkBehavior.NeverUnderline;
            ((DataGridViewLinkColumn)MainWindow.FormsGrid.Columns[1]).LinkBehavior = LinkBehavior.NeverUnderline;

            var skylinePath      = Path.Combine(MainWindow.ExeDir, "Skyline.exe");
            var skylineDailyPath = Path.Combine(MainWindow.ExeDir, "Skyline-daily.exe");

            skylinePath = File.Exists(skylinePath) ? skylinePath : skylineDailyPath;
            var assembly   = Assembly.LoadFrom(skylinePath);
            var types      = assembly.GetTypes();
            var formLookup = new FormLookup();

            foreach (var type in types)
            {
                if (IsForm(type) && !HasSubclasses(types, type))
                {
                    var typeName = SkylineTesterWindow.Implements(type, "IFormView") && type.DeclaringType != null
                        ? type.DeclaringType.Name + "." + type.Name
                        : type.Name;
                    var test = formLookup.GetTest(typeName);
                    if (test == "*")
                    {
                        continue;
                    }
                    MainWindow.FormsGrid.Rows.Add(typeName, test, 0);
                }
            }

            MainWindow.FormsGrid.Sort(MainWindow.FormsGrid.Columns[0], ListSortDirection.Ascending);
            MainWindow.FormsGrid.ClearSelection();
            MainWindow.FormsGrid.Rows[0].Selected = true;
            UpdateForms();
        }
示例#2
0
        // from http://blogs.msdn.com/b/kirillosenkov/archive/2011/08/10/how-to-get-dte-from-visual-studio-process-id.aspx
        public static DTE GetDTE(string file, string lineNumberText)
        {
            var dte = FindDTE(file);

            if (dte != null)
            {
                return(dte);
            }

            // Couldn't find an instance of Visual Studio with a solution containing this file.
            // Try finding a Skyline solution we can use and open that one.
            var parentDirectory = Path.GetDirectoryName(file);

            while (parentDirectory != null)
            {
                var skylineSln = Path.Combine(parentDirectory, "Skyline.sln");
                var vsExe      = SkylineTesterWindow.GetExistingVsIdeFilePath("devenv.exe");
                if (vsExe != null && File.Exists(skylineSln))
                {
                    System.Diagnostics.Process.Start(vsExe,
                                                     @"{0} {1} /command ""Edit.Goto {2}""".With(skylineSln, file, lineNumberText));
                    return(null);
                }
                parentDirectory = Path.GetDirectoryName(parentDirectory);
            }

            return(null);
        }
示例#3
0
 private static bool IsForm(Type type)
 {
     if (type.IsAbstract)
     {
         return(false);
     }
     if (type.IsSubclassOf(typeof(Form)))
     {
         return(!SkylineTesterWindow.Implements(type, "IMultipleViewProvider"));
     }
     return(SkylineTesterWindow.Implements(type, "IFormView"));
 }
        public static void CreateZipFile(string zipPath)
        {
            zipPath = zipPath ?? string.Empty; // For quiet ReSharper code inspection

            Console.WriteLine();
            Console.WriteLine("# Creating " + Path.GetFileName(zipPath) + "...");
            Console.WriteLine();

            if (File.Exists(zipPath))
            {
                File.Delete(zipPath);
            }

            var exeDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";

            Directory.SetCurrentDirectory(exeDirectory);

            var solutionDirectory = exeDirectory;

            while (!File.Exists(Path.Combine(solutionDirectory, "Skyline.sln")))
            {
                solutionDirectory = Path.GetDirectoryName(solutionDirectory);
                if (string.IsNullOrEmpty(solutionDirectory))
                {
                    throw new ApplicationException("Can't find solution directory");
                }
            }

            using (var zipFile = new ZipFile(zipPath))
            {
                // DotNetZip has a _bug_ which causes an extraction error without this
                // (see http://stackoverflow.com/questions/15337186/dotnetzip-badreadexception-on-extract)
                zipFile.ParallelDeflateThreshold = -1;
                zipFile.AlternateEncodingUsage   = ZipOption.Always;
                zipFile.AlternateEncoding        = System.Text.Encoding.UTF8;

                if ((String.Empty + Path.GetFileName(zipPath)).ToLower() == "skylinenightly.zip")
                {
                    // Add files to top level of zip file.
                    var files = new[]
                    {
                        "SkylineNightlyShim.exe",
                        "SkylineNightly.exe",
                        "SkylineNightly.pdb",
                        "Microsoft.Win32.TaskScheduler.dll",
                        "DotNetZip.dll"
                    };
                    foreach (var file in files)
                    {
                        Console.WriteLine(file);
                        zipFile.AddFile(file);
                    }
                }

                else if ((String.Empty + Path.GetFileName(zipPath)).ToLower() == "bibliospec.zip")
                {
                    // Create a BiblioSpec distro
                    var files = new List <string>
                    {
                        "BlibBuild.exe",
                        "BlibFilter.exe",
                        "MassLynxRaw.dll",
                        "timsdata.dll",
                        "baf2sql_c.dll",
                        "cdt.dll",
                        "modifications.xml",
                        "quantitation_1.xsd",
                        "quantitation_2.xsd",
                        "unimod_2.xsd"
                    };
                    var dir = Directory.GetCurrentDirectory();
                    files.Add(dir.Contains("Debug") ? "msparserD.dll" : "msparser.dll");

                    // Locate BlibToMS2
                    var parent = dir.IndexOf("Skyline\\", StringComparison.Ordinal);
                    if (parent > 0)
                    {
                        dir = dir.Substring(0, parent);
                        var blib2ms2 = dir + "Shared\\BiblioSpec\\obj\\x64\\BlibToMs2.exe";
                        if (File.Exists(blib2ms2)) // Don't worry about this for a 32 bit build, we don't distribute that
                        {
                            files.Add(blib2ms2);
                        }
                    }
                    foreach (var file in files)
                    {
                        Console.WriteLine(file);
                        zipFile.AddFile(file, string.Empty);
                    }
                }

                else
                {
                    // Add SkylineTester at top level of zip file.
                    Console.WriteLine("SkylineTester.exe");
                    zipFile.AddFile("SkylineTester.exe");

                    // Add .skytr files at top level of zip file.
                    var skytrDirectory = Path.Combine(solutionDirectory, @"SkylineTester\Run files");
                    foreach (var skytrFile in Directory.EnumerateFiles(skytrDirectory, "*.skytr"))
                    {
                        AddFile(skytrFile, zipFile, ".");
                    }

                    // Add each subdirectory in the bin directory.
                    foreach (var directory in Directory.EnumerateDirectories("."))
                    {
                        if (Include(directory))
                        {
                            var name = Path.GetFileName(directory) ?? "";
                            Console.WriteLine(Path.Combine(SkylineTesterWindow.SkylineTesterFiles, name));
                            zipFile.AddDirectory(directory, Path.Combine(SkylineTesterWindow.SkylineTesterFiles, name));
                        }
                    }

                    // Add each file in the bin directory.
                    foreach (var file in Directory.EnumerateFiles("."))
                    {
                        if (Include(file))
                        {
                            AddFile(file, zipFile);
                        }
                    }

                    // Add test zip files.
                    var zipFilesList = new List <string>();
                    FindZipFiles(solutionDirectory, zipFilesList);
                    var zipFilesDirectory = Path.Combine(SkylineTesterWindow.SkylineTesterFiles, "TestZipFiles");
                    foreach (var testZipFile in zipFilesList)
                    {
                        var testZipDirectory = Path.GetDirectoryName(testZipFile);
                        if (string.IsNullOrEmpty(testZipDirectory))
                        {
                            continue;
                        }
                        testZipDirectory = Path.Combine(zipFilesDirectory,
                                                        testZipDirectory.Substring(solutionDirectory.Length + 1));
                        AddFile(testZipFile, zipFile, testZipDirectory);
                    }

                    // Add pwiz vendor reader test data
                    var vendorTestData = new List <string>();
                    foreach (TestFilesDir.VendorDir vendorDir in Enum.GetValues(typeof(TestFilesDir.VendorDir)))
                    {
                        FindVendorReaderTestData(TestFilesDir.GetVendorTestData(vendorDir), vendorTestData);
                    }
                    foreach (var file in vendorTestData)
                    {
                        var parentDirectory = Path.GetDirectoryName(file);
                        if (string.IsNullOrEmpty(parentDirectory))
                        {
                            continue;
                        }
                        int relativePathStart = parentDirectory.LastIndexOf('\\',
                                                                            parentDirectory.IndexOf(@"Test.data", StringComparison.InvariantCulture));
                        parentDirectory = parentDirectory.Substring(relativePathStart + 1);
                        AddFile(file, zipFile, Path.Combine(SkylineTesterWindow.SkylineTesterFiles, parentDirectory));
                    }

                    // Add the file that we use to determine which branch this is from
                    AddFile(Path.Combine(solutionDirectory, "..\\..\\pwiz\\Version.cpp"), zipFile);

                    // Add unit testing DLL.
                    const string relativeUnitTestingDll =
                        @"PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll";
                    var unitTestingDll = SkylineTesterWindow.GetExistingVsIdeFilePath(relativeUnitTestingDll);
                    if (unitTestingDll == null)
                    {
                        throw new ApplicationException(string.Format("Can't find {0}", relativeUnitTestingDll));
                    }
                    AddFile(unitTestingDll, zipFile);
                }

                Console.WriteLine();
                Console.WriteLine("# Saving...");
                zipFile.Save();
                Console.WriteLine();
                Console.WriteLine("# {0} size: {1:F1} MB", Path.GetFileName(zipPath), new FileInfo(PathEx.SafePath(zipPath)).Length / (1024.0 * 1024));
                Console.WriteLine("# Done.");
                Console.WriteLine();
            }
        }