public static bool getActiveProjectAndConfig(DTE app, out VCProjectW out_proj, out VCConfigurationW out_conf) { out_proj = null; out_conf = null; Document doc = app.ActiveDocument; if (doc == null) { return false; } ProjectItem item = doc.ProjectItem; if (!matchTypeName(item.Object, "VCProjectFileShim")) { return false; } EnvDTE.Project proj = item.ContainingProject; VCFileW vcfile = new VCFileW(item.Object); VCProjectW vcproj = vcfile.project; String configname = proj.ConfigurationManager.ActiveConfiguration.ConfigurationName + "|" + proj.ConfigurationManager.ActiveConfiguration.PlatformName; IVCCollectionW cfgs = vcproj.Configurations; int num = cfgs.Count; for (int i = 1; i <= num; ++i) { VCConfigurationW c = cfgs.Item(i); String name = (String)getProperty(c, "Name"); if (name == configname) { out_proj = vcproj; out_conf = c; return true; } } return false; }
private static bool getStartupProjectAndConfigR(EnvDTE.Project project, String startup, out VCProjectW o_proj, out VCConfigurationW o_conf) { o_proj = null; o_conf = null; if (project.Kind == EnvDTE.Constants.vsProjectKindSolutionItems) { foreach (ProjectItem item in project.ProjectItems) { EnvDTE.Project child = item.SubProject; if (child != null) { if (getStartupProjectAndConfigR(child, startup, out o_proj, out o_conf)) { return(true); } } } } else { if (!matchTypeName(project.Object, "VCProjectShim")) { return(false); } VCProjectW vcproj = new VCProjectW(project.Object); o_proj = vcproj; if (project.UniqueName == startup) { String configname = project.ConfigurationManager.ActiveConfiguration.ConfigurationName + "|" + project.ConfigurationManager.ActiveConfiguration.PlatformName; IVCCollectionW cfgs = vcproj.Configurations; int num = cfgs.Count; for (int i = 1; i <= num; ++i) { VCConfigurationW c = cfgs.Item(i); if (c.Name == configname) { o_conf = c; return(true); } } } } return(false); }
public static bool getActiveProjectAndConfig(DTE app, out VCProjectW out_proj, out VCConfigurationW out_conf) { out_proj = null; out_conf = null; Document doc = app.ActiveDocument; if (doc == null) { return(false); } ProjectItem item = doc.ProjectItem; if (!matchTypeName(item.Object, "VCProjectFileShim")) { return(false); } EnvDTE.Project proj = item.ContainingProject; VCFileW vcfile = new VCFileW(item.Object); VCProjectW vcproj = vcfile.project; String configname = proj.ConfigurationManager.ActiveConfiguration.ConfigurationName + "|" + proj.ConfigurationManager.ActiveConfiguration.PlatformName; IVCCollectionW cfgs = vcproj.Configurations; int num = cfgs.Count; for (int i = 1; i <= num; ++i) { VCConfigurationW c = cfgs.Item(i); String name = (String)getProperty(c, "Name"); if (name == configname) { out_proj = vcproj; out_conf = c; return(true); } } return(false); }
private static bool getStartupProjectAndConfigR(EnvDTE.Project project, String startup, out VCProjectW o_proj, out VCConfigurationW o_conf) { o_proj = null; o_conf = null; if (project.Kind == EnvDTE.Constants.vsProjectKindSolutionItems) { foreach (ProjectItem item in project.ProjectItems) { EnvDTE.Project child = item.SubProject; if (child != null) { if (getStartupProjectAndConfigR(child, startup, out o_proj, out o_conf)) { return true; } } } } else { if (!matchTypeName(project.Object, "VCProjectShim")) { return false; } VCProjectW vcproj = new VCProjectW(project.Object); o_proj = vcproj; if (project.UniqueName == startup) { String configname = project.ConfigurationManager.ActiveConfiguration.ConfigurationName + "|" + project.ConfigurationManager.ActiveConfiguration.PlatformName; IVCCollectionW cfgs = vcproj.Configurations; int num = cfgs.Count; for (int i = 1; i <= num; ++i) { VCConfigurationW c = cfgs.Item(i); if (c.Name == configname) { o_conf = c; return true; } } } } return false; }
public static bool getStartupProjectAndConfig(DTE app, out VCProjectW o_proj, out VCConfigurationW o_conf) { o_proj = null; o_conf = null; Solution sln = app.Solution; if (sln == null || sln.SolutionBuild.StartupProjects==null) { return false; } String startup = (String)((Array)sln.SolutionBuild.StartupProjects).GetValue(0); foreach (EnvDTE.Project project in sln.Projects) { if (getStartupProjectAndConfigR(project, startup, out o_proj, out o_conf)) { return true; } } return false; }
public static bool getStartupProjectAndConfig(DTE app, out VCProjectW o_proj, out VCConfigurationW o_conf) { o_proj = null; o_conf = null; Solution sln = app.Solution; if (sln == null || sln.SolutionBuild.StartupProjects == null) { return(false); } String startup = (String)((Array)sln.SolutionBuild.StartupProjects).GetValue(0); foreach (EnvDTE.Project project in sln.Projects) { if (getStartupProjectAndConfigR(project, startup, out o_proj, out o_conf)) { return(true); } } return(false); }
/// <summary> /// </summary> private void onApplyChange(object sender, EventArgs e) { DTE dte = (DTE)GetService(typeof(DTE)); VCDocumentInfo vcdoc = new VCDocumentInfo(dte); if (!vcdoc.IsValid()) { return; } dte.ActiveDocument.Save(); List <String> cur_func = ProjectUtil.GetFunctionsInCurrentPosition(dte); VCFileW vcfile = vcdoc.VCFile; VCConfigurationW vcconf = vcdoc.VCConfiguration; Dictionary <String, String> properties = new Dictionary <String, String>(); properties.Add("Configuration", vcconf.Evaluate("$(Configuration)")); properties.Add("Platform", vcconf.Evaluate("$(Platform)")); properties.Add("SelectedFiles", vcdoc.FileRelpath); properties.Add("BuildProjectReferences", "false"); properties.Add("SolutionDir", vcconf.Evaluate("$(SolutionDir)")); properties.Add("SolutionExt", vcconf.Evaluate("$(SolutionExt)")); properties.Add("SolutionName", vcconf.Evaluate("$(SolutionName)")); properties.Add("SolutionFileName", vcconf.Evaluate("$(SolutionFileName)")); properties.Add("SolutionPath", vcconf.Evaluate("$(SolutionPath)")); RunBuild(vcdoc.ProjPath, vcfile.ItemType, properties, (BuildLogger logger) => { if (vcfile.ItemType == "ClCompile") { List <alcSymbolFilterColumn> filter = SymbolFilterUtil.GetDefaultFilter(vcdoc.ObjPath, true); { List <alcSymbolFilterColumn> loaded_filter = SymbolFilterUtil.LoadFromConfigFile(vcdoc.ObjFilterPath); if (loaded_filter != null) { filter = SymbolFilterUtil.MergeFilter(filter, loaded_filter); } } if (filter != null && cur_func.Count > 0) { bool changed = false; foreach (alcSymbolFilterColumn c in filter) { foreach (String f in cur_func) { if (c.Name == f) { c.FlagUpdate = true; changed = true; } } } if (changed) { SymbolFilterUtil.SaveConfig(vcdoc.ObjFilterPath, filter); } } else { logger.Write(String.Format("Alcantarea warning: could not get cursor's current position function\n")); } AlcantareaHelper.RequestSetSymbolFilter(vcdoc.ObjPath, filter); SendCommand("dpLoadBinary\n" + vcdoc.ObjPath + "\n\n"); } }); }