private Dictionary <string, string> CollectOutputDirectories(SolutionBuild2 sb, Action <string> msgOutput) { var outputPaths = new Dictionary <string, string>(); foreach (BuildDependency dep in sb.BuildDependencies) { msgOutput($"### CollectOutputDirectories: Propertes of project '{dep.Project.Name}'"); LogInfo($"### CollectOutputDirectories: Propertes of project '{dep.Project.Name}'"); if (!IsCSharpProject(dep.Project)) { msgOutput($"Only C# projects are supported project! ProjectName = {dep.Project.Name} Language = {dep.Project.CodeModel.Language}"); LogInfo($"Only C# projects are supported project! ProjectName = {dep.Project.Name} Language = {dep.Project.CodeModel.Language}"); continue; } var outputDir = GetFullOutputPath(dep.Project); if (string.IsNullOrEmpty(outputDir)) { continue; } msgOutput($"OutputFullPath = {outputDir}"); LogInfo($"OutputFullPath = {outputDir}"); outputPaths[dep.Project.FullName] = outputDir; } return(outputPaths); }
private void AdjustSolConfMatrix() { SolutionBuild2 solBuild = (SolutionBuild2)Globals.dte.Solution.SolutionBuild; AdjustSolConfMatrixRow(solBuild, "Debug [ChartPoints]"); AdjustSolConfMatrixRow(solBuild, "Release [ChartPoints]"); }
private bool AddMutationAnalysisToUnitTestProject(List <GeneratedMutant> generatedUnitTestMutants, EnvDTE.Project unitTestProject) { var selfUsing = SyntaxFactory.UsingDirective( SyntaxFactory.IdentifierName("SourceCodeProjectMutants")); selfUsing = selfUsing.WithUsingKeyword( selfUsing.UsingKeyword.WithTrailingTrivia( SyntaxFactory.Whitespace(" "))); Usings.Add(selfUsing); var unitTestCompilationUnit = SyntaxFactory.CompilationUnit() .WithUsings(SyntaxFactory.List(Usings.ToArray())) .WithMembers( SyntaxFactory.SingletonList <MemberDeclarationSyntax>( SyntaxFactory.NamespaceDeclaration( SyntaxFactory.IdentifierName("UnitTestProjectMutants")) .WithMembers( SyntaxFactory.SingletonList <MemberDeclarationSyntax>( SyntaxFactory.ClassDeclaration("FirstUnitTestMutant") .WithModifiers( SyntaxFactory.TokenList( SyntaxFactory.Token(SyntaxKind.PublicKeyword))))))) .NormalizeWhitespace(); var unitTestCompilationUnitRoot = unitTestCompilationUnit.SyntaxTree.GetRoot() as CompilationUnitSyntax; var unitTestMutantsNameSpace = unitTestCompilationUnitRoot.DescendantNodes().OfType <NamespaceDeclarationSyntax>().First(); var firstUnitTestMutant = unitTestMutantsNameSpace.DescendantNodes().OfType <ClassDeclarationSyntax>().First(); var unitTestCompilationUnitSyntaxTree = unitTestCompilationUnitRoot .InsertNodesAfter(firstUnitTestMutant, generatedUnitTestMutants.Select(p => p.MutatedCodeRoot)); var unitTestTree = CSharpSyntaxTree.ParseText(unitTestCompilationUnitSyntaxTree.ToFullString()); UnitTestsMutantsCodePath = Path.Combine(Path.GetDirectoryName(unitTestProject.FullName), "UnitTestMutants.cs"); File.WriteAllText(UnitTestsMutantsCodePath, unitTestTree.GetRoot().ToFullString()); unitTestProject.ProjectItems.AddFromFile(UnitTestsMutantsCodePath); unitTestProject.Save(); SolutionBuild2 solutionBuild2 = (SolutionBuild2)unitTestProject.DTE.Solution.SolutionBuild; solutionBuild2.BuildProject(solutionBuild2.ActiveConfiguration.Name, unitTestProject.UniqueName, true); bool unitTestCompiledOK = (solutionBuild2.LastBuildInfo == 0); return(unitTestCompiledOK); }
private bool AddMutationAnalysisToSourceCodeProject(SourceCodeMutationResult sourceCodeMutationResult, EnvDTE.Project sourceCodeProject) { var sourceCodeUsings = sourceCodeMutationResult.Usings .GroupBy(u => u.ToFullString()).Select(iu => iu.First()).ToList(); var unitTestUsings = Usings.GroupBy(u => u.ToFullString()).Select(iu => iu.First()).ToList(); var sourceCodeCompilationUnit = SyntaxFactory.CompilationUnit() .WithUsings(SyntaxFactory.List(sourceCodeUsings.ToArray())) .WithMembers( SyntaxFactory.SingletonList <MemberDeclarationSyntax>( SyntaxFactory.NamespaceDeclaration( SyntaxFactory.IdentifierName("SourceCodeProjectMutants")) .WithMembers( SyntaxFactory.SingletonList <MemberDeclarationSyntax>( SyntaxFactory.ClassDeclaration("FirstSourceCodeMutant") .WithModifiers( SyntaxFactory.TokenList( SyntaxFactory.Token(SyntaxKind.PublicKeyword))))))) .NormalizeWhitespace(); var sourceCodeCompilationUnitRoot = sourceCodeCompilationUnit.SyntaxTree.GetRoot() as CompilationUnitSyntax; var sourceCodeMutantsNameSpace = sourceCodeCompilationUnitRoot.DescendantNodes().OfType <NamespaceDeclarationSyntax>().First(); var firstSourceCodeMutant = sourceCodeMutantsNameSpace.DescendantNodes().OfType <ClassDeclarationSyntax>().First(); var sourceCodeCompilationUnitSyntaxTree = sourceCodeCompilationUnitRoot .InsertNodesAfter(firstSourceCodeMutant, sourceCodeMutationResult.GeneratedMutants.Select(p => p.MutatedCodeRoot)); var sourceCodeTree = CSharpSyntaxTree.ParseText(sourceCodeCompilationUnitSyntaxTree.ToFullString()); SourceCodeMutantsCodePath = Path.Combine(Path.GetDirectoryName(sourceCodeProject.FullName), "SourceCodeMutants.cs"); File.WriteAllText(SourceCodeMutantsCodePath, sourceCodeTree.GetRoot().ToFullString()); //add source code mutation analysis to sc project sourceCodeProject.ProjectItems.AddFromFile(SourceCodeMutantsCodePath); sourceCodeProject.Save(); //recompile the source code project SolutionBuild2 sourceCodeSolutionBuild2 = (SolutionBuild2)sourceCodeProject.DTE.Solution.SolutionBuild; sourceCodeSolutionBuild2.BuildProject(sourceCodeSolutionBuild2.ActiveConfiguration.Name, sourceCodeProject.UniqueName, true); bool sourceCodeCompiledOK = (sourceCodeSolutionBuild2.LastBuildInfo == 0); return(sourceCodeCompiledOK); }
private void AdjustSolConfMatrixRow(SolutionBuild2 solBuild, string confName) { foreach (SolutionConfiguration solConf in solBuild.SolutionConfigurations) { if (solConf.Name.Contains(confName)) { foreach (SolutionContext context in solConf.SolutionContexts) { context.ConfigurationName = confName; } } } }
public bool RemoveSolutionConfigurations() { SolutionBuild2 solBuild = (SolutionBuild2)Globals.dte.Solution.SolutionBuild; IEnumerable <SolutionConfiguration> solConfs = ((IEnumerable <SolutionConfiguration>)solBuild.SolutionConfigurations.GetEnumerator()).Where( sc => (sc.Name.Contains("|ChartPoints"))); foreach (var sc in solConfs) { sc.Delete(); } return(true); }
public bool InitSolutionConfigurations() { SolutionBuild2 solBuild = (SolutionBuild2)Globals.dte.Solution.SolutionBuild; CheckAndAddSolConf(ref solBuild, "Debug"); CheckAndAddSolConf(ref solBuild, "Release"); AdjustSolConfMatrix(); Globals.dte.Events.BuildEvents.OnBuildProjConfigBegin += OnBuildProjConfigBegin; Globals.dte.Events.BuildEvents.OnBuildProjConfigDone += OnBuildProjConfigDone; debugEvents = Globals.dte.Events.DebuggerEvents; debugEvents.OnEnterRunMode += new _dispDebuggerEvents_OnEnterRunModeEventHandler(DebuggerEventsOnOnEnterRunMode); debugEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(DebugEventsOnOnEnterDesignMode); return(true); }
private void CheckAndAddSolConf(ref SolutionBuild2 solBuild, string confType) { bool needAdd = true; foreach (SolutionConfiguration solConf in solBuild.SolutionConfigurations) { if (solConf.Name == confType + " [ChartPoints]") { needAdd = false; } } if (needAdd) { SolutionConfiguration cpConf = solBuild.SolutionConfigurations.Add(confType + " [ChartPoints]", confType, false /*true*/); } }
private void ExcludeProjectFromBuildProcess(EnvDTE.Project project) { Solution2 solution = dte.Solution as Solution2; SolutionBuild2 solutionBuild = (SolutionBuild2)solution.SolutionBuild; foreach (SolutionConfiguration solutionConfiguration in solutionBuild.SolutionConfigurations) { foreach (SolutionContext solutionContext in solutionConfiguration.SolutionContexts) { if (solutionContext.ProjectName.IndexOf(project.Name) > -1) { Log("ExcludeProjectFromBuildProcess: Setting build to false for project " + solutionContext.ProjectName + " within the " + solutionConfiguration.Name + " configuration"); solutionContext.ShouldBuild = false; } } } }
private Project GetStartupProject(CrestronMonoDebuggerPackage package) { ThreadHelper.ThrowIfNotOnUIThread(); var dte = Package.GetGlobalService(typeof(SDTE)) as DTE2; if (dte?.Solution == null) { package.OutputWindowWriteLine("Unable to locate the solution."); throw new InvalidOperationException("Unable to locate the solution."); } SolutionBuild2 sb = (SolutionBuild2)dte.Solution.SolutionBuild; List <string> startupProjects = ((Array)sb.StartupProjects).Cast <string>().ToList(); try { var projects = Projects(dte.Solution); foreach (var project in projects) { if (startupProjects.Contains(project.UniqueName)) { if (IsCSharpProject(package, project)) { // We are only support one C# project at once return(project); } else { package.DebugWriteLine($"Only C# projects are supported as startup project! ProjectName = {project.Name} Language = {project.CodeModel.Language}"); } } } } catch (ArgumentException aex) { package.OutputWindowWriteLine($"No startup project extracted! The parameter StartupProjects = '{string.Join(",", startupProjects.ToArray())}' is incorrect."); package.DebugWriteLine(aex); throw new ArgumentException($"No startup project extracted! The parameter StartupProjects = '{string.Join(",", startupProjects.ToArray())}' is incorrect.", aex); } package.OutputWindowWriteLine($"No startup project found! Checked projects in StartupProjects = '{string.Join(",", startupProjects.ToArray())}'"); throw new ArgumentException($"No startup project found! Checked projects in StartupProjects = '{string.Join(",", startupProjects.ToArray())}'"); }
public Project GetStartupProject() { //Get the first startup project SolutionBuild2 buildInfo = (SolutionBuild2)_dte.Solution.SolutionBuild; if (buildInfo.StartupProjects == null) { return(null); } string firstStartupProject = ((Array)buildInfo.StartupProjects).Cast <string>().First(); //Find the actual project Projects projectList = _dte.Solution.Projects; IEnumerator list = projectList.GetEnumerator(); while (list.MoveNext()) { Project proj = list.Current as Project; if (proj == null) { continue; } if (proj.Kind == ProjectKinds.vsProjectKindSolutionFolder) //Check if the project is a solution folder, not an actual project { Project find = EnumerateSubprojects(proj, firstStartupProject); if (find != null) { return(find); } } else { if (proj.UniqueName == firstStartupProject) { return(proj); } } } return(null); }
public virtual bool Build() { try { // _applicationObject.ExecuteCommand("Build.BuildSelection", ""); Project = (Project)((Array)Dte.ActiveSolutionProjects).GetValue(0); VsProject = ((VSProject2)(Project.Object)); if (!ExecuteBeforeBuild()) { return(false); } Solution = (Solution2)Dte.Solution; SolutionBuild = (SolutionBuild2)Solution.SolutionBuild; //sb2.BuildProject(sb2.ActiveConfiguration.Name, prj.UniqueName, true); SolutionBuild.Build(true); //_dte.ExecuteCommand("Build.RebuildSolution"); if (SolutionBuild.LastBuildInfo != 0) { return(false); } if (!BuildManifest()) { return(false); } ExecuteAfterRelease(); return(true); } catch (Exception ex) { OutputMessage(ex.Message); Logger.WriteExceptionLog(ex.Message + Environment.NewLine + ex.StackTrace); MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace, Common.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
// This method is called after the project is created. public void RunFinished() { if (dte == null) { NuGetWizard.RunFinished(); } // if solution if (dte != null) { // set startup project try { // get startup project var project = dte.GetProjects().First(p => p.UniqueName.Contains(safesolutionname + ".Client.Domain.Test")); // set startup project SolutionBuild2 sb = (SolutionBuild2)dte.Solution.SolutionBuild; sb.StartupProjects = new object[] { project.UniqueName }; } catch { } // collapse projects try { dte.CollapseAll(exlusionList: ProjectFolder); } catch { } // copy lib try { var directory = Path.GetDirectoryName(dte.GetProjects().First().FullName); directory = Path.Combine(directory, @"..\.."); //directory.CreateLib(Resources, true); //directory.UnpackZipToLib(ResourceArchives); } catch { } } }
private Project GetStartUpProject() { DTE2 dte2 = GetDTE2(); SolutionBuild2 sb = (SolutionBuild2)dte2.Solution.SolutionBuild; if (sb.StartupProjects != null) { string name = ""; foreach (String s in (Array)sb.StartupProjects) { name += s; } if (string.IsNullOrEmpty(name)) { return(null); } return(dte2.Solution.Item(name)); } return(null); }
private Dictionary <string, string> CollectOutputDirectories(SolutionBuild2 sb, Action <string> msgOutput) { ThreadHelper.ThrowIfNotOnUIThread(); var outputPaths = new Dictionary <string, string>(); foreach (BuildDependency dep in sb.BuildDependencies) { try { msgOutput($"### CollectOutputDirectories: Propertes of project '{dep.Project.Name}'"); Logger.Info($"### CollectOutputDirectories: Propertes of project '{dep.Project.Name}'"); if (!IsCSharpProject(dep.Project)) { msgOutput($"Only C# projects are supported project! ProjectName = {dep.Project.Name} Language = {dep.Project.CodeModel.Language}"); Logger.Info($"Only C# projects are supported project! ProjectName = {dep.Project.Name} Language = {dep.Project.CodeModel.Language}"); continue; } var outputDir = GetFullOutputPath(dep.Project); if (string.IsNullOrEmpty(outputDir)) { continue; } msgOutput($"OutputFullPath = {outputDir}"); Logger.Info($"OutputFullPath = {outputDir}"); outputPaths[dep.Project.FullName] = outputDir; } catch (Exception ex) { msgOutput($"### CollectOutputDirectories: unsupported project - error was: '{ex.Message}'"); Logger.Info($"### CollectOutputDirectories: unsupported project - error was: '{ex.Message}'"); } } return(outputPaths); }
public static List <string> GetPlatformNames(DTE dte) { List <string> platformNames = new List <string>(); SolutionBuild2 solutionBuild = GetSolutionBuild2(dte); if (solutionBuild != null) { try { foreach (SolutionConfiguration2 solutionConfiguration in solutionBuild.SolutionConfigurations) { platformNames.Add(solutionConfiguration.PlatformName); } platformNames = platformNames.Distinct().ToList(); } catch (Exception e) { Logging.Logging.LogError("Exception: " + e.Message); } } return(platformNames); }
/// <summary> /// Launches the active or first runnable project /// </summary> public void ExecLaunch() { // get the name of the startup project and then search it by iterating through the project // for web projects its not so easy as the StartupProject.Name is not the same as the project.Name - therefore we will fallback to the first IsRunnable project in case we dont find a match string startupProjectName = ""; Project startupProject = null; //NavigateSolution(); SolutionBuild2 solutionBuilder = (SolutionBuild2)_applicationObject.DTE.Solution.SolutionBuild; startupProjectName = (string)_applicationObject.DTE.Solution.Properties.Item("StartupProject").Value; context.log(Context.LOG_INFO + "Startup project name: " + startupProjectName); // traverse projects of solution to get startup project // (aware of Solution Folders; see comment on http://msdn.microsoft.com/en-us/library/ms228782.aspx) // (http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/36adcd56-5698-43ca-bcba-4527daabb2e3) try { startupProject = _applicationObject.DTE.Solution.Projects.Item(startupProjectName); } catch (Exception) { // ArgumentException -> traverse Solution Folders startupProject = GetStartupProject(_applicationObject.DTE.Solution); } if (startupProject != null) { logProject(startupProject); } else { context.log(Context.LOG_ERROR + "startup project is null"); } Project firstRunnable = null; if (IsRunnable(startupProject)) { firstRunnable = startupProject; } else { List <Project> projects = GetProjects(_applicationObject.DTE.Solution); foreach (Project proj in projects) { if (IsRunnable(proj)) { firstRunnable = proj; break; } } } if (firstRunnable != null) { try { if (BuildBeforeLaunch) { _applicationObject.DTE.Solution.SolutionBuild.Build(true); } // start project switch (GetProjectLaunchType(firstRunnable)) { case LaunchType.WebSite: LaunchWebSiteProject(firstRunnable); break; case LaunchType.WebApplication: LaunchWebApplicationProject(firstRunnable); break; case LaunchType.Assembly: LaunchProject(firstRunnable); break; case LaunchType.Unknown: System.Windows.Forms.MessageBox.Show("Unable to launch project, unsupported project type", "dynaTrace Launcher", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); break; } } catch (Exception launchExp) { context.log(Context.LOG_ERROR + "LaunchException: " + launchExp.Message + "\nSource: " + launchExp.Source + "\nStack: " + launchExp.StackTrace); if (_applicationObject.DTE.Debugger.DebuggedProcesses.Count == 0) { System.Windows.Forms.MessageBox.Show("Message: " + launchExp.Message + "\nSource: " + launchExp.Source + "\nStack: " + launchExp.StackTrace, "dynaTrace Launcher", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } else { System.Windows.Forms.MessageBox.Show("dynaTrace Launcher can not start your project if it is already running in debug mode and 'Build Solution before launch' option is checked."); } } } else { System.Windows.Forms.MessageBox.Show("dynaTrace Launcher requires an open solution with an active launchable project.", "dynaTrace Launcher", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } }
protected override void OnExecute() { var dte = Package.GetDTE(); SolutionBuild2 sb = (SolutionBuild2)dte.Solution.SolutionBuild; // get the name of the active project string startupProjectUniqueName = (string)((Array)sb.StartupProjects).GetValue(0); var results = new List <Project>(); foreach (EnvDTE.Project project in dte.Solution.Projects) { GetAllProjectsFromProject(project, results); } results.ToDebugPrint(); // find the start up project var startupProject = results.Where(x => !string.IsNullOrEmpty(x.Name) && string.Equals(x.UniqueName, startupProjectUniqueName)); if (!startupProject.Any()) { // no startup project found return; } // try to figure out the build outputs of the project var outputGroups = startupProject.First().ConfigurationManager.ActiveConfiguration.OutputGroups.OfType <EnvDTE.OutputGroup>(); var builtGroup = outputGroups.First(x => x.CanonicalName == "Built"); var fileUrls = ((object[])builtGroup.FileURLs).OfType <string>(); var executables = fileUrls.Where(x => x.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)); if (!executables.Any()) { return; } string activeProjectExePath = new Uri(executables.First(), UriKind.Absolute).LocalPath; string activeExePath = Path.GetFileName(activeProjectExePath); CleanupProcWatcher(); _procWatcher = new ProcessWatcher(activeExePath); _procWatcher.ProcessCreated += ProcWatcher_ProcessCreated; _procWatcher.ProcessDeleted += ProcWatcher_ProcessDeleted; _procWatcher.Start(); dte.ExecuteCommand("Debug.StartWithoutDebugging"); // this will get all the build output paths for the active project var outputFolders = new List <string>(); foreach (var strUri in fileUrls) { var uri = new Uri(strUri, UriKind.Absolute); var filePath = uri.LocalPath; var folderPath = Path.GetDirectoryName(filePath); outputFolders.Add(folderPath.ToLower()); } }
public static void OpenSolution(object sender, DoWorkEventArgs e) { bwAsync = sender as BackgroundWorker; EnvDTE80.DTE2 dte = null; Dictionary <string, IUMLElement> listElements = new Dictionary <string, IUMLElement>(); try { dte = (EnvDTE80.DTE2)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DTE.8.0", ""); Solution2 soln = (Solution2)dte.Solution; soln.Open(File); SolutionBuild2 build = (SolutionBuild2)soln.SolutionBuild; addMessageBackgroundWorker(0, "Building Solution..."); build.SolutionConfigurations.Item("Debug").Activate(); build.Clean(true); build.Build(true); UMLModel model = Helper.GetCurrentElement <UMLModel>(); if (build.LastBuildInfo == 0 && model != null) { IUMLElement solutionUML = new UMLPackage(); solutionUML.Name = Path.GetFileName(soln.FileName); solutionUML.Owner = model; listElements.Add(solutionUML.Name, solutionUML); for (int i = 1; i <= soln.Projects.Count; i++) { Project project = soln.Projects.Item(i); if (project.Properties != null) { string fullPath = (string)project.Properties.Item("FullPath").Value; string outputfileName = (string)project.Properties.Item("OutputFileName").Value; Assembly assembly = Assembly.LoadFile(fullPath + @"Bin\Debug\" + outputfileName); IUMLElement projectUML = new UMLPackage(); projectUML.Name = project.Name; listElements.Add(project.Name, projectUML); projectUML.Owner = solutionUML; addMessageBackgroundWorker(0, "Processing Types: \n" + project.Name); foreach (Type type in assembly.GetTypes()) { if (type.MemberType == MemberTypes.TypeInfo) { IUMLElement element = null; if (type.IsEnum && IncludeEnumeration) { element = new UMLEnumeration(); element.Name = type.Name; ((UMLEnumeration)element).Literals = GetLiterals(type); } else { if (type.IsClass && IncludeClass) { element = new UMLClass(); element.Name = type.Name; ((UMLClass)element).Attributes = GetProperties(type); ((UMLClass)element).Attributes.AddRange(GetStaticAndConstants(type)); ((UMLClass)element).Methods = GetMethods(type); if (type.IsGenericType) { element.Name = element.Name.Substring(0, element.Name.IndexOf("`")); element.Name += "<"; foreach (Type t in type.GetGenericArguments()) { element.Name += t.Name + ","; } element.Name = element.Name.TrimEnd(','); element.Name += ">"; } } else if (type.IsInterface && IncludeInterface) { element = new UMLInterface(); element.Name = type.Name; ((UMLInterface)element).Attributes = GetProperties(type); } } if (element != null) { IUMLElement owner = null; if (type.Namespace == null) { owner = projectUML; } else if (listElements.ContainsKey(type.Namespace)) { owner = listElements[type.Namespace]; } else { owner = new UMLPackage(); //if(type.Namespace.Contains(projectUML.Name)) //{ // owner.Name = type.Namespace.Replace(projectUML.Name, ""); //} owner.Stereotype = "ClassPackage"; owner.Name = type.Namespace; owner.Owner = projectUML; listElements.Add(type.Namespace, owner); } element.Owner = owner; if ((type.Attributes & TypeAttributes.Public) == TypeAttributes.Public) { element.Visibility = Visibility.Public; } else { element.Visibility = Visibility.Private; } XmlNode node = DocsByReflection.XMLFromType(type); if (node != null) { element.Documentation = node.InnerXml.Trim(); } if (!listElements.ContainsKey(type.Namespace + "." + type.Name)) { listElements.Add(type.Namespace + "." + type.Name, element); } } } } } } } else { // Error Build } soln.Close(true); } catch (SystemException ex) { //MessageBox.Show("ERROR: " + ex); } finally { if (dte != null) { dte.Quit(); } } Helper.BeginUpdate(); addMessageBackgroundWorker(0, "Init import..."); int pos = 0; foreach (IUMLElement element in listElements.Values) { pos++; addMessageBackgroundWorker((pos * 100) / listElements.Count, "Creating: \n" + element.Name); element.GetType().InvokeMember("Save", BindingFlags.Default | BindingFlags.InvokeMethod, null, element, new object[] { }); } addMessageBackgroundWorker(100, "End import"); Helper.EndUpdate(); }
public DteWrapper(DTE dte) { this.dte = (DTE2)dte; solutionBuild = ((SolutionBuild2)((Solution2)dte.Solution).SolutionBuild); }
private void Button_Click_2(object sender, RoutedEventArgs e) { var dte = GetActiveIDE(); //dte.ExecuteCommand("CloseAll"); if (unitTestProject == null && sourceCodeProject == null) { var projects = new List <ProjectPresentation>(); foreach (var item in solutionProjectList.SelectedItems) { var selectedProject = (ProjectPresentation)item; selectedProject.IsSelected = true; projects.Add(selectedProject); } sourceCodeProject = GetSourceCodeProject(projects); unitTestProject = GetUnitTestProject(projects); } if (unitTestProject != null && sourceCodeProject != null) { //delete the mutated source code class foreach (ProjectItem item in sourceCodeProject.ProjectItems) { var itemName = item.Name; if (itemName == "SourceCodeMutants.cs") { item.Delete(); break; } } sourceCodeProject.Save(); //delete mutated unit test project foreach (ProjectItem item in unitTestProject.ProjectItems) { var itemName = item.Name; if (itemName == "UnitTestMutants.cs") { item.Delete(); } //delete mutation analysis folder if (itemName == "MutationAnalysis") { MutationAnalysisNumber = 0; item.Delete(); } } unitTestProject.Save(); //recompile projects SolutionBuild2 solutionBuild2 = (SolutionBuild2)unitTestProject.DTE.Solution.SolutionBuild; solutionBuild2.BuildProject(solutionBuild2.ActiveConfiguration.Name, unitTestProject.UniqueName, true); bool unitTestCompiledOK = (solutionBuild2.LastBuildInfo == 0); SolutionBuild2 solutionBuild = (SolutionBuild2)sourceCodeProject.DTE.Solution.SolutionBuild; solutionBuild.BuildProject(solutionBuild.ActiveConfiguration.Name, sourceCodeProject.UniqueName, true); bool sourceCodeCompiledOK = (solutionBuild.LastBuildInfo == 0); if (unitTestCompiledOK && sourceCodeCompiledOK) { MessageBox.Show("MTOOS deletion done! No Errors!"); } else { MessageBox.Show("Error while MTOOS deletion!"); } } else { MessageBox.Show("Select the source code and the unit test project!"); } }