Ejemplo n.º 1
0
		public GlobalProjectProperties(ProjectNode project)
		{
			msBuildProject = project.As<Project>();
			dteProject = project.As<EnvDTE.Project>();
			vsBuild = project.HierarchyNode.HierarchyIdentity.Hierarchy as IVsBuildPropertyStorage;
			accessor = new DynamicPropertyAccessor(this);
		}
Ejemplo n.º 2
0
        public AddTranslationDialog(EnvDTE.Project pro)
        {
            project = pro;
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            ShowInTaskbar = false;

            this.langLabel.Text = SR.GetString("AddTranslationDialog_Language");
            this.cancelButton.Text = SR.GetString(SR.Cancel);
            this.okButton.Text = SR.GetString(SR.OK);
            this.label1.Text = SR.GetString("AddTranslationDialog_FileName");
            this.Text = SR.GetString("AddTranslationDialog_Title");

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;

            //if (SR.LanguageName == "ja")
            //{
            //    this.cancelButton.Location = new System.Drawing.Point(188, 72);
            //    this.cancelButton.Size = new System.Drawing.Size(84, 24);
            //    this.okButton.Location = new System.Drawing.Point(100, 72);
            //    this.okButton.Size = new System.Drawing.Size(84, 24);
            //}
            this.KeyPress += new KeyPressEventHandler(this.AddTranslationDialog_KeyPress);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ProjectParser_CSharp(VSProject2 vsProject, string solutionRootFolder)
        {
            try
            {
                m_vsProject = vsProject;
                m_solutionRootFolder = solutionRootFolder;
                m_dteProject = Utils.call(() => vsProject.Project);

                // We get the project name...
                m_projectInfo.Name = Utils.call(() => (m_dteProject.Name));

                if (MakeItSoConfig.Instance.ignoreProject(m_projectInfo.Name) == true)
                    Log.log("- project " + m_projectInfo.Name + "ignored");
                else
                {
                    Log.log("- parsing project " + m_projectInfo.Name);

                    // and parse the project...
                    parseProject();
                    Log.log("  - done");
                }
            }
            catch (Exception ex)
            {
                Log.log(String.Format("  - FAILED ({0})", ex.Message));
            }
        }
        public bool IsAccepted(DteProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            var projectName = project.Name;
            var hierarchy = this.projectSystem.GetIVsHierarchy(project);
            var propertyStorage = hierarchy as IVsBuildPropertyStorage;

            if (hierarchy == null || propertyStorage == null)
            {
                throw new ArgumentException(Strings.ProjectFilterDteProjectFailedToGetIVs, nameof(project));
            }

            if (IsNotSupportedProject(project))
            {
                return false;
            }

            if (IsExcludedViaProjectProperty(project))
            {
                return false;
            }

            if (IsTestProject(project, hierarchy, this.testRegex, projectName))
            {
                return false;
            }

            return true;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="project">The EnvDTE.Project which is to be adapted</param>
        public Project(EnvDTE.Project project)
        {
            if (project == null) throw new ArgumentNullException("project");

            this._project = project;
            this.Name = project.FullName;
        }
Ejemplo n.º 6
0
        public void SolutionEvents_ProjectAdded(Project projectAdded)
        {
            if (projectAdded.Object == null)
                return;

            var changes = FindChanges(projectAdded);

            SaveChanges(projectAdded, changes);

            StringBuilder sb = new StringBuilder();
            foreach (var item in changes)
            {
                sb.AppendFormat("{0} will refer to: {1}\n", item.Project.Project.Name, item.ProjectToReference.Name);
            }

            if (!changes.Any())
                return;

            if (!AskUserToProceed("Switch File References to Project References?", sb.ToString()))
                return;

            //Apply changes
            foreach (var item in changes)
            {
                item.Reference.Remove();
                item.Project.References.AddProject(item.ProjectToReference);
            }
        }
Ejemplo n.º 7
0
        public SProcGeneratorTest(PackageTestFilesFixture files) {
            _files = files;
            _coreShell = Substitute.For<ICoreShell>();
            _pss = Substitute.For<IProjectSystemServices>();

            _project = Substitute.For<EnvDTE.Project>();
            _project.FullName.Returns(Path.Combine(_files.DestinationPath, sqlProjectName));
        }
        bool IProjectSystemFilter.IsAccepted(DteProject dteProject)
        {
            if (this.AllProjectsMatchReturn.HasValue)
            {
                return this.AllProjectsMatchReturn.Value;
            }

            return this.MatchingProjects.Any(x => StringComparer.OrdinalIgnoreCase.Equals(x.UniqueName, dteProject.UniqueName));
        }
Ejemplo n.º 9
0
        public VisualStudioSolution(SolutionFile solution) {
            _solution = solution;
            _app = new VisualStudioApp();
            Project = _app.OpenProject(solution.Filename);

            ThreadHelper.Generic.Invoke(Keyboard.Reset);
            SolutionExplorer = _app.OpenSolutionExplorer();
            SelectSolutionNode();
        }
Ejemplo n.º 10
0
        public void SolutionEvents_ProjectRemoved(Project project)
        {
            Trace.WriteLine("Project Removed: " + project.Name);

            StorageProvider storage = new StorageProvider();

            var items = storage.Load(project.DTE.Solution).GetProjectsThatReference(project.UniqueName);

            List<ProjectReferenceToRemove> workToDo = new List<ProjectReferenceToRemove>();

            foreach (var item in items)
            {
                Project projectToAddReferenceTo = null;
                foreach (Project p in project.DTE.Solution.Projects)
                {
                    if (p.UniqueName == item.SourceProject)
                    {
                        projectToAddReferenceTo = p;
                        break;
                    }
                }

                string filePath = item.KnownPaths;

                if (filePath == null)
                    continue;

                if (projectToAddReferenceTo != null)
                {
                    workToDo.Add(new ProjectReferenceToRemove
                        {
                            ProjectNeedingReference = projectToAddReferenceTo,
                            FilePath = filePath,
                            ProjectRemoving = project
                        });
                }
            }

            StringBuilder sb = new StringBuilder();
            foreach (var item in workToDo)
            {
                sb.AppendFormat("{0} will refer back to: {1}\n\n", item.ProjectNeedingReference.Name, ToRelative(item.FilePath, item.ProjectNeedingReference.FullName));
            }

            if (workToDo.Count == 0)
                return;

            if(!AskUserToProceed("Switch Project Reference to File References?",  sb.ToString()))
                return;

            foreach (var item in workToDo)
            {
                AddReference(item.ProjectNeedingReference, item.ProjectRemoving, item.FilePath);
            }
        }
Ejemplo n.º 11
0
 public RccOptions(EnvDTE.Project pro, VCFile qrcFile)
 {
     project = pro;
     id = qrcFile.RelativePath;
     qrcFileName = qrcFile.FullPath;
     name = id;
     if (id.StartsWith(".\\"))
         name = name.Substring(2);
     if (name.EndsWith(".qrc"))
         name = name.Substring(0, name.Length-4);
 }
Ejemplo n.º 12
0
		public UserProjectProperties(ProjectNode project)
		{
			this.project = project;
			msBuildProject = project.As<Project>();
			dteProject = project.As<EnvDTE.Project>();
			vsBuild = project.HierarchyNode.VsHierarchy as IVsBuildPropertyStorage;

			if (msBuildProject == null || vsBuild == null)
				tracer.Warn(Strings.UserProjectProperties.NonMsBuildProject(project.DisplayName));

			accessor = new DynamicPropertyAccessor(this);
		}
Ejemplo n.º 13
0
 public ProjectQtSettings(EnvDTE.Project proj)
 {
     versionManager = QtVersionManager.The();
     project = proj;
     newMocDir = oldMocDir = QtVSIPSettings.GetMocDirectory(project);
     newMocOptions = oldMocOptions= QtVSIPSettings.GetMocOptions(project);
     newRccDir = oldRccDir = QtVSIPSettings.GetRccDirectory(project);
     newUicDir = oldUicDir = QtVSIPSettings.GetUicDirectory(project);
     newLUpdateOnBuild = oldLUpdateOnBuild = QtVSIPSettings.GetLUpdateOnBuild(project);
     newLUpdateOptions = oldLUpdateOptions = QtVSIPSettings.GetLUpdateOptions(project);
     newLReleaseOptions = oldLReleaseOptions = QtVSIPSettings.GetLReleaseOptions(project);
     newQtVersion = oldQtVersion = versionManager.GetProjectQtVersion(project);
 }
 protected BaseUndoUnit(
     PackageInstallerService packageInstallerService,
     string source,
     string packageName,
     string versionOpt,
     EnvDTE.DTE dte,
     EnvDTE.Project dteProject,
     IOleUndoManager undoManager)
 {
     this.packageInstallerService = packageInstallerService;
     this.packageName = packageName;
     this.versionOpt = versionOpt;
     this.dte = dte;
     this.dteProject = dteProject;
     this.undoManager = undoManager;
 }
Ejemplo n.º 15
0
        internal Project(DteProject dteProject, Solution solution, ProjectLanguage language)
        {
            if (dteProject == null)
            {
                throw new ArgumentNullException(nameof(dteProject));
            }

            if (solution == null)
            {
                throw new ArgumentNullException(nameof(solution));
            }

            _dteProject = dteProject;
            _solution = solution;
            _language = language;
        }
Ejemplo n.º 16
0
        private void InitializeWizard(object automationObject, Dictionary<string, string> replacementsDictionary)
        {
            _Storage = new Storage();
            _Storage.LoadStorage();


            inputForm = new frmWizDAC_1(_Storage.CnnString);


            inputForm.FinalizeWizEvent += new FinalizeWizHandler(inputForm_FinalizeWizEvent);
            solution = (((EnvDTE.SolutionClass)(((EnvDTE.DTE)automationObject).Solution)));


            selectedProject = HelperFunctions.GetDTE_SelectedProject(solution);

            replacementsDictionary[CommonConstants.CONST_FwkProject_NAME] = HelperFunctions.GetDTEProperty(solution ,"Name").Value.ToString();
            inputForm.ProjectName = replacementsDictionary[CommonConstants.CONST_FwkProject_NAME];
        }
        public static IMSBuildNuGetProjectSystem CreateMSBuildNuGetProjectSystem(EnvDTEProject envDTEProject, INuGetProjectContext nuGetProjectContext)
        {
            if (envDTEProject == null)
            {
                throw new ArgumentNullException("project");
            }

            if (String.IsNullOrEmpty(envDTEProject.FullName))
            {
                throw new InvalidOperationException(
                    String.Format(CultureInfo.CurrentCulture,
                    Strings.DTE_ProjectUnsupported, EnvDTEProjectUtility.GetName(envDTEProject)));
            }

#if VS14
            if (EnvDTEProjectUtility.SupportsINuGetProjectSystem(envDTEProject))
            {
                throw new InvalidOperationException("Does not support INuGetProjectSystem");
            }
#endif

            var guids = VsHierarchyUtility.GetProjectTypeGuids(envDTEProject);
            if (guids.Contains(NuGetVSConstants.CppProjectTypeGuid)) // Got a cpp project
            {
                if (!EnvDTEProjectUtility.IsClr(envDTEProject))
                    return new NativeProjectSystem(envDTEProject, nuGetProjectContext);
            }



            // Try to get a factory for the project type guid            
            foreach (var guid in guids)
            {
                IMSBuildNuGetProjectSystemThunk factory;
                if (_factories.TryGetValue(guid, out factory))
                {
                    return factory(envDTEProject, nuGetProjectContext);
                }
            }

            // Fall back to the default if we have no special project types
            return new VSMSBuildNuGetProjectSystem(envDTEProject, nuGetProjectContext);
        }
 /// <summary>
 /// Recursively retrieves projects form the provided Visual Studio project
 /// </summary>
 /// <param name="folderOrProject">A reference to a Visual Studio Project or Solution Folder</param>
 /// <returns>An enumeration of all Visual Studio projects (only)</returns>
 private IEnumerable<IProject> GetProjects(VSProject folderOrProject)
 {
     // it is a solution folder
     if (folderOrProject.Kind == EnvDTEProjectKinds.VsProjectKindSolutionFolder)
     {
         foreach (VSProjectItem item in folderOrProject.ProjectItems)
         {
             // it is a project
             if (item.SubProject != null)
             {
                 foreach (IProject project in GetProjects(item.SubProject))
                 {
                     yield return project;
                 }
             }
         }
     }
     else if (folderOrProject.Kind == EnvDTEProjectKinds.VsProjectKindVCpp)
     {
         yield return new Project(folderOrProject);
     }
 }
Ejemplo n.º 19
0
        public ServerWizard(EnvDTE.Project project, IVsUIShell uiShell, IVsPackageInstaller packageInstaller, IVsPackageInstallerServices packageInstallerServices)
        {
            InitializeComponent();

            _dte = project.DTE;
            _project = project;
            _uiShell = uiShell;
            _packageInstaller = packageInstaller;
            _packageInstallerServices = packageInstallerServices;

            var edmxs = _dte.GetSolutionEdmx(_project).ToList();
            edmx.ItemsSource = edmxs;
            edmx.SelectedItem = edmxs.FirstOrDefault();

            generationOptions.ItemsSource = new[] { GenerationOptions.GetViewModel(GenerationOptions.Kind.All), GenerationOptions.GetViewModel(GenerationOptions.Kind.WithoutGlobalWithoutFramework), GenerationOptions.GetViewModel(GenerationOptions.Kind.FrameworkOnly), GenerationOptions.GetViewModel(GenerationOptions.Kind.GlobalOnly) };
            generationOptions.SelectedIndex = edmxs.Count == 0 ? 2 : 0;

            if (! GenerationOptions.CanBeRunnedWithNoCopy(_dte))
            {
                copyTemplates.IsChecked = true;
                copyTemplates.IsEnabled = false;
            }
        }
Ejemplo n.º 20
0
        public VsProject(VsSolution solution, DteProject dteProject, IProjectManager projectManager)
            : base()
        {
            _solution = solution;
            _installed = new CoreInteropInstalledPackagesList((IPackageReferenceRepository2)projectManager.LocalRepository);
            DteProject = dteProject;

            // Add V2-related interop features
            AddFeature(() => projectManager);
            AddFeature(() => projectManager.PackageManager);
            AddFeature(() => projectManager.Project);
            AddFeature(() => projectManager.PackageManager.LocalRepository);
            AddFeature<IPackageCacheRepository>(() => MachineCache.Default);

            // the source repository of the local repo of the project
            AddFeature<SourceRepository>(() =>
            {
                var repo = new NuGet.Client.Interop.V2SourceRepository(
                    null,
                    projectManager.LocalRepository,
                    "");
                return repo;
            });

            // Add PowerShell feature
            AddFeature<PowerShellScriptExecutor>(() =>
                new VsPowerShellScriptExecutor(ServiceLocator.GetInstance<IScriptExecutor>()));

#if VS14
            // Add NuGetAwareProject if the project system is nuget-aware.
            _nugetAwareProject = projectManager.Project as INuGetPackageManager;
            if (_nugetAwareProject != null)
            {
                AddFeature<NuGetAwareProject>(() => new VsNuGetAwareProject(_nugetAwareProject));
            }
#endif
        }
        private bool IsExcludedViaProjectProperty(DteProject dteProject)
        {
            Debug.Assert(dteProject != null);

            // General exclusions
            // If exclusion property is set to true, this takes precedence
            bool? sonarExclude = this.propertyManager.GetBooleanProperty(dteProject, Constants.SonarQubeExcludeBuildPropertyKey);
            return sonarExclude.HasValue && sonarExclude.Value;
        }
 public WebProjectSystem(EnvDTEProject envDTEProject, INuGetProjectContext nuGetProjectContext)
     : base(envDTEProject, nuGetProjectContext)
 {
 }
Ejemplo n.º 23
0
 public static string GetMocDirectory(EnvDTE.Project project)
 {
     return(GetDirectory(project, Resources.mocDirKeyword));
 }
 public IVsProjectAdapter CreateAdapterForFullyLoadedProject(EnvDTE.Project dteProject)
 {
     return(_threadingService.ExecuteSynchronously(
                () => CreateAdapterForFullyLoadedProjectAsync(dteProject)));
 }
Ejemplo n.º 25
0
 public ProjectWrapper(EnvDTE.Project item)
 {
     Item = item;
 }
Ejemplo n.º 26
0
        private async Task RegisterPluginAssembly(ConnectionData connectionData, CommonConfiguration commonConfig, EnvDTE.Project project, string defaultOutputFilePath)
        {
            if (connectionData == null)
            {
                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.NoCurrentCRMConnection);
                return;
            }

            if (project == null || string.IsNullOrEmpty(project.Name))
            {
                this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.AssemblyNameIsEmpty);
                return;
            }

            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectingToCRM);

            this._iWriteToOutput.WriteToOutput(connectionData, connectionData.GetConnectionDescription());

            // Подключаемся к CRM.
            var service = await QuickConnection.ConnectAsync(connectionData);

            if (service == null)
            {
                _iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ConnectionFailedFormat1, connectionData.Name);
                return;
            }

            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.CurrentServiceEndpointFormat1, service.CurrentServiceEndpoint);

            var assembly = new PluginAssembly();

            System.Threading.Thread worker = new System.Threading.Thread(() =>
            {
                try
                {
                    var form = new WindowPluginAssembly(_iWriteToOutput, service, assembly, defaultOutputFilePath, project);

                    form.ShowDialog();
                }
                catch (Exception ex)
                {
                    DTEHelper.WriteExceptionToOutput(null, ex);
                }
            });

            worker.SetApartmentState(System.Threading.ApartmentState.STA);

            worker.Start();
        }
Ejemplo n.º 27
0
    private ProjectTracker(VSProject vsProject) {
      Contract.Requires(vsProject != null);
      Contract.Requires(vsProject.Project != null);
      Contract.Requires(ProjectIsAvailable(vsProject.Project));

      //Keep a pointer to our project
      VS_Project = vsProject;
      EnvDTE_Project = vsProject.Project;

      Contract.Assume(EnvDTE_Project.Properties != null);

      //Get our name
      ProjectName = EnvDTE_Project.Name;
      UniqueProjectName = EnvDTE_Project.UniqueName;

      //Get our host
      Version frameworkVersion = null;
      frameworkVersion = GetTargetFramework(EnvDTE_Project);
      VSServiceProvider.Current.Logger.WriteToLog("fx version: " + frameworkVersion.ToString());

      this._host = VSServiceProvider.Current.GetHost(frameworkVersion);

      //Eagerly add our project's references to the host's lib paths
      AddProjectReferencesPathsIntoHost(References, Host);

      //Subscribe to build events
      VSServiceProvider.Current.BuildBegin += OnBuildBegin;
      VSServiceProvider.Current.BuildDone += OnBuildDone;

      //Initialize build variables
      BuildNumber = 0;
      InBuild = false;

      //Get our assembly identity
      AssemblyIdentity = GetAssemblyIdentity(EnvDTE_Project, Host);

      //Set the contracts provider
      _contractsProvider = VSServiceProvider.Current.GetVersionedServicesFactory().CreateContractsProvider(this);
    }
Ejemplo n.º 28
0
 internal static PythonProjectNode GetPythonProject(this EnvDTE.Project project)
 {
     return(project.GetCommonProject() as PythonProjectNode);
 }
Ejemplo n.º 29
0
 public void ProjectFinishedGenerating(EnvDTE.Project project)
 {
 }
Ejemplo n.º 30
0
 public static bool GetIsItemBolded(this EnvDTE.Project project, string item)
 {
     return(GetNodeState(project, item, __VSHIERARCHYITEMSTATE.HIS_Bold));
 }
Ejemplo n.º 31
0
 public static bool GetIsFolderExpanded(this EnvDTE.Project project, string folder)
 {
     return(GetNodeState(project, folder, __VSHIERARCHYITEMSTATE.HIS_Expanded));
 }
Ejemplo n.º 32
0
        internal async System.Threading.Tasks.Task ProfileProject(SessionNode session, EnvDTE.Project projectToProfile, bool openReport)
        {
            var uiThread = (UIThreadBase)NodejsProfilingPackage.Instance.GetService(typeof(UIThreadBase));

            if (!await uiThread.InvokeTask(() => EnsureProjectUpToDate(projectToProfile)) &&
                await uiThread.InvokeAsync(() => MessageBox.Show(Resources.FailedToBuild, Resources.NodejsToolsForVS, MessageBoxButton.YesNo)) == MessageBoxResult.No)
            {
                return;
            }

            var    interpreterArgs = (string)projectToProfile.Properties.Item("NodeExeArguments").Value;
            var    scriptArgs      = (string)projectToProfile.Properties.Item("ScriptArguments").Value;
            var    startBrowser    = (bool)projectToProfile.Properties.Item("StartWebBrowser").Value;
            string launchUrl       = (string)projectToProfile.Properties.Item("LaunchUrl").Value;

            int?port = (int?)projectToProfile.Properties.Item("NodejsPort").Value;

            string interpreterPath = (string)projectToProfile.Properties.Item("NodeExePath").Value;

            string startupFile = (string)projectToProfile.Properties.Item("StartupFile").Value;

            if (String.IsNullOrEmpty(startupFile))
            {
                MessageBox.Show("Project has no configured startup file, cannot start profiling.", Resources.NodejsToolsForVS);
                return;
            }

            string workingDir = projectToProfile.Properties.Item("WorkingDirectory").Value as string;

            if (String.IsNullOrEmpty(workingDir) || workingDir == ".")
            {
                workingDir = projectToProfile.Properties.Item("ProjectHome").Value as string;
                if (String.IsNullOrEmpty(workingDir))
                {
                    workingDir = Path.GetDirectoryName(projectToProfile.FullName);
                }
            }

            RunProfiler(
                session,
                interpreterPath,
                interpreterArgs,
                startupFile,
                scriptArgs,
                workingDir,
                null,
                openReport,
                launchUrl,
                port,
                startBrowser
                );
        }
        private async void InstallPackageAsync()
        {
            try
            {
                ILibrary selectedPackage = SelectedPackage;
                _isInstalling = true;
                InstallPackageCommand.CanExecute(null);
                Manifest manifest = await Manifest.FromFileAsync(_configFileName, _deps, CancellationToken.None).ConfigureAwait(false);

                string targetPath = _targetPath;

                if (!string.IsNullOrEmpty(_configFileName))
                {
                    Uri configContainerUri = new Uri(_configFileName, UriKind.Absolute);
                    Uri targetUri          = new Uri(targetPath, UriKind.Absolute);
                    targetPath = configContainerUri.MakeRelativeUri(targetUri).ToString();
                }

                if (String.IsNullOrEmpty(manifest.Version))
                {
                    manifest.Version = Manifest.SupportedVersions.Max().ToString();
                }

                LibraryInstallationState libraryInstallationState = new LibraryInstallationState
                {
                    LibraryId       = PackageId,
                    ProviderId      = selectedPackage.ProviderId,
                    DestinationPath = InstallationFolder.DestinationFolder,
                };

                // When "Include all files" option is checked, we don't want to write out the files to libman.json.
                // We will only list the files when user chose to install specific files.
                if (LibraryFilesToInstall == FileSelectionType.ChooseSpecificFilesToInstall)
                {
                    libraryInstallationState.Files = SelectedFiles.ToList();
                }

                manifest.AddLibrary(libraryInstallationState);

                await Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                EnvDTE.Project project = VsHelpers.DTE.SelectedItems.Item(1)?.ProjectItem?.ContainingProject;
                project?.AddFileToProjectAsync(_configFileName);

                RunningDocumentTable rdt = new RunningDocumentTable(Shell.ServiceProvider.GlobalProvider);
                string configFilePath    = Path.GetFullPath(_configFileName);

                IVsTextBuffer textBuffer = rdt.FindDocument(configFilePath) as IVsTextBuffer;

                _dispatcher.Invoke(() =>
                {
                    _closeDialog(true);
                });

                // The file isn't open. So we'll write to disk directly
                if (textBuffer == null)
                {
                    manifest.AddLibrary(libraryInstallationState);

                    await manifest.SaveAsync(_configFileName, CancellationToken.None).ConfigureAwait(false);

                    await _libraryCommandService.RestoreAsync(_configFileName, CancellationToken.None).ConfigureAwait(false);
                }
                else
                {
                    // libman.json file is open, so we will write to the textBuffer.
                    InsertIntoTextBuffer(textBuffer, libraryInstallationState);

                    // Save manifest file so we can restore library files.
                    rdt.SaveFileIfDirty(configFilePath);
                }
            }
            catch { }
        }
        private bool IsTestProject(DteProject dteProject, IVsHierarchy projectHierarchy, Regex testProjectNameRegex, string projectName)
        {
            Debug.Assert(dteProject != null);
            Debug.Assert(projectHierarchy != null);

            // Ignore test projects
            // If specifically marked with test project property, use that to specify if test project or not
            bool? sonarTest = this.propertyManager.GetBooleanProperty(dteProject, Constants.SonarQubeTestProjectBuildPropertyKey);
            if (sonarTest.HasValue)
            {
                // Even if the project is a test project by the checks below, if this property was set to false
                // then we treat it as if it's not a test project
                return sonarTest.Value;
            }

            // Otherwise, try to detect test project using known project types and/or regex match
            if (this.projectSystem.IsKnownTestProject(projectHierarchy))
            {
                return true;
            }

            // Heuristically exclude by project name
            return (testProjectNameRegex != null && testProjectNameRegex.IsMatch(projectName));
        }
Ejemplo n.º 35
0
        public void SaveSettings()
        {
            bool updateMoc = false;
            QtProject qtPro = QtProject.Create(project);

            if (oldMocDir != newMocDir)
            {
                QtVSIPSettings.SaveMocDirectory(project, newMocDir);
                updateMoc = true;
            }
            if (oldMocOptions != newMocOptions)
            {
                QtVSIPSettings.SaveMocOptions(project, newMocOptions);
                updateMoc = true;
            }
            if (updateMoc)
                qtPro.UpdateMocSteps(oldMocDir);

            if (oldUicDir != newUicDir)
            {
                QtVSIPSettings.SaveUicDirectory(project, newUicDir);
                qtPro.UpdateUicSteps(oldUicDir, true);
            }

            if (oldRccDir != newRccDir)
            {
                QtVSIPSettings.SaveRccDirectory(project, newRccDir);
                qtPro.RefreshRccSteps(oldRccDir);
            }

            if (oldLUpdateOnBuild != newLUpdateOnBuild)
                QtVSIPSettings.SaveLUpdateOnBuild(project, newLUpdateOnBuild);

            if (oldLUpdateOptions != newLUpdateOptions)
                QtVSIPSettings.SaveLUpdateOptions(project, newLUpdateOptions);

            if (oldLReleaseOptions != newLReleaseOptions)
                QtVSIPSettings.SaveLReleaseOptions(project, newLReleaseOptions);

            if (oldDesignerOptions != newDesignerOptions)
                QtVSIPSettings.SaveDesignerOptions(project, newDesignerOptions);

            if (oldLinguistOptions != newLinguistOptions)
                QtVSIPSettings.SaveLinguistOptions(project, newLinguistOptions);

            if (oldAssistantOptions != newAssistantOptions)
                QtVSIPSettings.SaveAssistantOptions(project, newAssistantOptions);

            if (oldQtVersion != newQtVersion)
            {
                bool newProjectCreated = false;
                bool versionChanged = qtPro.ChangeQtVersion(oldQtVersion, newQtVersion, ref newProjectCreated);
                if (versionChanged && newProjectCreated)
                    project = qtPro.Project;
            }
        }
Ejemplo n.º 36
0
        /// <summary>
        /// Installs one or more packages into the specified project.
        /// </summary>
        /// <param name="packageInstaller">The package installer service that performs the actual package installation.</param>
        /// <param name="project">The target project for installation.</param>
        /// <param name="configuration">
        /// The packages to install, where to install them from, and additional options for
        /// their installation.
        /// </param>
        /// <param name="repositorySettings">The repository settings for the packages being installed.</param>
        /// <param name="preferPackageReferenceFormat">Install packages to the project as PackageReference if the project type supports it</param>
        /// <param name="warningHandler">
        /// An action that accepts a warning message and presents it to the user, allowing
        /// execution to continue.
        /// </param>
        /// <param name="errorHandler">
        /// An action that accepts an error message and presents it to the user, allowing
        /// execution to continue.
        /// </param>
        internal async Task PerformPackageInstallAsync(
            EnvDTE.Project project,
            PreinstalledPackageConfiguration configuration,
            bool preferPackageReferenceFormat,
            Action <string> warningHandler,
            Action <string> errorHandler)
        {
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var repositoryPath      = configuration.RepositoryPath;
            var repositorySource    = new Configuration.PackageSource(repositoryPath);
            var failedPackageErrors = new List <string>();

            // find the project
            var defaultProjectContext = new VSAPIProjectContext
            {
                PackageExtractionContext = new PackageExtractionContext(
                    PackageSaveMode.Defaultv2,
                    PackageExtractionBehavior.XmlDocFileSaveMode,
                    ClientPolicyContext.GetClientPolicy(_settings, NullLogger.Instance),
                    NullLogger.Instance)
            };

            var nuGetProject = await _solutionManager.GetOrCreateProjectAsync(project, defaultProjectContext);

            if (preferPackageReferenceFormat && await NuGetProjectUpgradeUtility.IsNuGetProjectUpgradeableAsync(nuGetProject, project, needsAPackagesConfig: false))
            {
                nuGetProject = await _solutionManager.UpgradeProjectToPackageReferenceAsync(nuGetProject);
            }

            // For BuildIntegratedNuGetProject, nuget will ignore preunzipped configuration.
            var buildIntegratedProject = nuGetProject as BuildIntegratedNuGetProject;

            var repository = (buildIntegratedProject == null && configuration.IsPreunzipped) ?
                             _sourceProvider.CreateRepository(repositorySource, FeedType.FileSystemUnzipped) :
                             _sourceProvider.CreateRepository(repositorySource);

            var repoProvider = new PreinstalledRepositoryProvider(errorHandler, _sourceProvider);

            repoProvider.AddFromSource(repository);

            var packageManager = _installer.CreatePackageManager(repoProvider);
            var gatherCache    = new GatherCache();

            var sources = repoProvider.GetRepositories().ToList();

            // store expanded node state
            var expandedNodes = await VsHierarchyUtility.GetAllExpandedNodesAsync();

            try
            {
                foreach (var package in configuration.Packages)
                {
                    var packageIdentity = new PackageIdentity(package.Id, package.Version);

                    // Does the project already have this package installed?
#pragma warning disable CS0618 // Type or member is obsolete
                    if (_packageServices.IsPackageInstalled(project, package.Id))
                    {
                        // If so, is it the right version?
                        if (!_packageServices.IsPackageInstalledEx(project, package.Id, package.Version.ToNormalizedString()))
#pragma warning restore CS0618 // Type or member is obsolete
                        {
                            // No? Raise a warning (likely written to the Output window) and ignore this package.
                            warningHandler(string.Format(VsResources.PreinstalledPackages_VersionConflict, package.Id, package.Version));
                        }
                        // Yes? Just silently ignore this package!
                    }
                    else
                    {
                        try
                        {
                            if (InfoHandler != null)
                            {
                                InfoHandler(string.Format(CultureInfo.CurrentCulture, VsResources.PreinstalledPackages_PackageInstallStatus, package.Id, package.Version));
                            }

                            // Skip assembly references and disable binding redirections should be done together
                            var disableBindingRedirects = package.SkipAssemblyReferences;

                            var projectContext = new VSAPIProjectContext(package.SkipAssemblyReferences, disableBindingRedirects);
                            var loggerAdapter  = new LoggerAdapter(projectContext);
                            projectContext.PackageExtractionContext = new PackageExtractionContext(
                                PackageSaveMode.Defaultv2,
                                PackageExtractionBehavior.XmlDocFileSaveMode,
                                ClientPolicyContext.GetClientPolicy(_settings, loggerAdapter),
                                loggerAdapter);

                            // This runs from the UI thread
                            await _installer.InstallInternalCoreAsync(
                                packageManager,
                                gatherCache,
                                nuGetProject,
                                packageIdentity,
                                sources,
                                projectContext,
                                includePrerelease : false,
                                ignoreDependencies : package.IgnoreDependencies,
                                token : CancellationToken.None);
                        }
                        catch (InvalidOperationException exception)
                        {
                            failedPackageErrors.Add(package.Id + "." + package.Version + " : " + exception.Message);
                        }
                        catch (AggregateException aggregateEx)
                        {
                            var ex = aggregateEx.Flatten().InnerExceptions.FirstOrDefault();
                            if (ex is InvalidOperationException)
                            {
                                failedPackageErrors.Add(package.Id + "." + package.Version + " : " + ex.Message);
                            }
                            else
                            {
                                throw;
                            }
                        }
                    }
                }

                if (failedPackageErrors.Any())
                {
                    var errorString = new StringBuilder();
                    errorString.AppendFormat(VsResources.PreinstalledPackages_FailedToInstallPackage, repositoryPath);
                    errorString.AppendLine();
                    errorString.AppendLine();
                    errorString.Append(string.Join(Environment.NewLine, failedPackageErrors));

                    errorHandler(errorString.ToString());
                }

                // RepositorySettings = null in unit tests
                if (project.IsWebSite())
                {
                    CreateRefreshFilesInBin(
                        project,
                        repositoryPath,
                        configuration.Packages.Where(p => p.SkipAssemblyReferences));

                    CopyNativeBinariesToBin(project, repositoryPath, configuration.Packages);
                }
            }
            finally
            {
                // collapse nodes
                await VsHierarchyUtility.CollapseAllNodesAsync(expandedNodes);
            }
        }
Ejemplo n.º 37
0
        public void ProjectFinishedGenerating(Project project) {
            if (project.DTE.SuppressUI) {
                return;
            }

            string description = null;
            try {
                var p = project.Properties.Item("InterpreterDescription");
                if (p != null) {
                    description = p.Value as string;
                }
            } catch (ArgumentException) {
            }

            if (string.IsNullOrEmpty(description)) {
                bool isValid = false;
                try {
                    var p = project.Properties.Item("InterpreterId");
                    isValid = p != null && !string.IsNullOrEmpty(p.Value as string);
                } catch (ArgumentException) {
                }
                if (!isValid) {
                    // We don't have a usable interpreter, so there's no point
                    // going ahead.
                    // Fall out - the user will find what they need when they
                    // try and run or edit, but until then there's no reason to
                    // block them or duplicate all of our help messages into yet
                    // another assembly.
                    return;
                }
            }

            ProjectItem requirementsTxt = null;
            try {
                requirementsTxt = project.ProjectItems.Item("requirements.txt");
            } catch (ArgumentException) {
            }

            if (requirementsTxt == null) {
                return;
            }

            var txt = requirementsTxt.FileNames[0];
            if (!File.Exists(txt)) {
                return;
            }

            var provider = WizardHelpers.GetProvider(project.DTE);
            if (provider == null) {
                return;
            }

            var td = new TaskDialog(provider) {
                Title = string.Format("{0} - {1}", project.Name, Strings.ProductTitle),
                MainInstruction = Strings.InstallRequirementsHeading,
                Content = Strings.InstallRequirementsMessage,
                EnableHyperlinks = true,
                AllowCancellation = true,
            };

            var venv = new TaskDialogButton(
                Strings.InstallRequirementsIntoVirtualEnv,
                Strings.InstallRequirementsIntoVirtualEnvTip
            );
            description = description ?? Strings.DefaultInterpreterDescription;
            var install = new TaskDialogButton(
                string.Format(Strings.InstallRequirementsIntoGlobalEnv, description),
                Strings.InstallRequirementsIntoGlobalEnvTip
            );
            var goAway = new TaskDialogButton(Strings.InstallRequirementsNowhere);
            td.Buttons.Add(venv);
            td.Buttons.Add(install);
            td.Buttons.Add(goAway);

            try {
                td.ExpandedInformation = File.ReadAllText(txt);
                td.CollapsedControlText = Strings.InstallRequirementsShowPackages;
                td.ExpandedControlText = Strings.InstallRequirementsHidePackages;
            } catch (IOException) {
            } catch (NotSupportedException) {
            } catch (UnauthorizedAccessException) {
            }

            var btn = td.ShowModal();
            int cmdId = 0;
            if (btn == venv) {
                cmdId = (int)PkgCmdIDList.cmdidAddVirtualEnv;
            } else if (btn == install) {
                cmdId = (int)PkgCmdIDList.cmdidInstallRequirementsTxt;
            }
            if (cmdId != 0) {
                object inObj = (object)true, outObj = null;
                try {
                    project.DTE.Commands.Raise(
                        GuidList.guidPythonToolsCmdSet.ToString("B"),
                        cmdId,
                        ref inObj,
                        ref outObj
                    );
                } catch (Exception ex) {
                    if (ex.IsCriticalException()) {
                        throw;
                    }
                    TaskDialog.ForException(
                        provider,
                        ex,
                        Strings.InstallRequirementsFailed,
                        PythonConstants.IssueTrackerUrl
                    ).ShowModal();
                }
            }
        }
Ejemplo n.º 38
0
        /// <summary>
        /// For Website projects, adds necessary "refresh" files in the bin folder for added references.
        /// </summary>
        /// <param name="project">The target Website project.</param>
        /// <param name="repositoryPath">The local repository path.</param>
        /// <param name="packageInfos">The packages that were installed.</param>
        private void CreateRefreshFilesInBin(EnvDTE.Project project, string repositoryPath, IEnumerable <PreinstalledPackageInfo> packageInfos)
        {
            IEnumerable <PackageIdentity> packageNames = packageInfos.Select(pi => new PackageIdentity(pi.Id, pi.Version));

            AddRefreshFilesForReferences(project, repositoryPath, packageNames);
        }
Ejemplo n.º 39
0
        public static bool HasDifferentMocFilePerConfig(EnvDTE.Project project)
        {
            var mocDir = GetMocDirectory(project);

            return(mocDir.Contains("$(ConfigurationName)"));
        }
Ejemplo n.º 40
0
        private void ProjectContextMenuItemCallback(object sender, EventArgs e)
        {
            var          dte          = this.dte.DTE;
            OutputWindow outputWindow = null;

            try
            {
                outputWindow = new OutputWindow(dte);

                OleMenuCommand menuCommand = sender as OleMenuCommand;
                if (menuCommand != null && dte != null)
                {
                    Array selectedProjects = (Array)dte.ActiveSolutionProjects;
                    //only support 1 selected project
                    if (selectedProjects.Length == 1)
                    {
                        EnvDTE.Project project = (EnvDTE.Project)selectedProjects.GetValue(0);
                        var            vcproj  = project.Object as VCProject;
                        if (vcproj != null)
                        {
                            IVCCollection   configs = (IVCCollection)vcproj.Configurations;
                            VCConfiguration cfg     = (VCConfiguration)vcproj.ActiveConfiguration;
                            VCDebugSettings debug   = (VCDebugSettings)cfg.DebugSettings;

                            string command          = null;
                            string arguments        = null;
                            string workingDirectory = null;
                            if (debug != null)
                            {
                                command          = cfg.Evaluate(debug.Command);
                                workingDirectory = cfg.Evaluate(debug.WorkingDirectory);
                                arguments        = cfg.Evaluate(debug.CommandArguments);
                            }

                            VCPlatform currentPlatform = (VCPlatform)cfg.Platform;

                            string platform = currentPlatform == null ? null : currentPlatform.Name;
                            if (platform != null)
                            {
                                platform = platform.ToLower();
                                if (platform.Contains("x64"))
                                {
                                    platform = "x64";
                                }
                                else if (platform.Contains("x86") || platform.Contains("win32"))
                                {
                                    platform = "x86";
                                }
                                else
                                {
                                    throw new NotSupportedException("Platform is not supported.");
                                }
                            }
                            else
                            {
                                cfg      = (VCConfiguration)configs.Item("Debug|x64");
                                platform = "x64";

                                if (cfg == null)
                                {
                                    throw new NotSupportedException("Cannot find x64 platform for project.");
                                }
                            }

                            if (command == null || String.IsNullOrEmpty(command))
                            {
                                command = cfg.PrimaryOutput;
                            }

                            if (command != null)
                            {
                                var solutionFolder = System.IO.Path.GetDirectoryName(dte.Solution.FileName);

                                CoverageExecution executor = new CoverageExecution(dte, outputWindow);
                                executor.Start(
                                    solutionFolder,
                                    platform,
                                    System.IO.Path.GetDirectoryName(command),
                                    System.IO.Path.GetFileName(command),
                                    workingDirectory,
                                    arguments);
                            }
                        }
                    }
                }
            }
            catch (NotSupportedException ex)
            {
                if (outputWindow != null)
                {
                    outputWindow.WriteLine("Error running coverage: {0}", ex.Message);
                }
            }
            catch (Exception ex)
            {
                if (outputWindow != null)
                {
                    outputWindow.WriteLine("Unexpected code coverage failure; error: {0}", ex.ToString());
                }
            }
        }
Ejemplo n.º 41
0
 public IVsProjectAdapter CreateAdapterForFullyLoadedProject(EnvDTE.Project dteProject)
 {
     return(_threadingService.JoinableTaskFactory.Run(
                () => CreateAdapterForFullyLoadedProjectAsync(dteProject)));
 }
Ejemplo n.º 42
0
 public static bool GetLUpdateOnBuild(EnvDTE.Project project)
 {
     return(GetBoolValue(project, Resources.lupdateKeyword));
 }
Ejemplo n.º 43
0
 public static string GetLUpdateOptions(EnvDTE.Project project)
 {
     return(GetOption(project, Resources.lupdateOptionsKeyword));
 }
 public void OnBeforeAddPackageReference(EnvDTE.Project project)
 {
 }
Ejemplo n.º 45
0
 public void UninstallPackage(EnvDTE.Project project, string packageId, bool removeDependencies)
 => _packageUninstaller.UninstallPackage(project, packageId, removeDependencies);
 public void OnAfterAddPackageReference(EnvDTE.Project project)
 {
 }
 private static bool IsNotSupportedProject(DteProject project)
 {
     var language = Language.ForProject(project);
     return (language == null || !language.IsSupported);
 }
Ejemplo n.º 48
0
 public static string GetMocOptions(EnvDTE.Project project)
 {
     return(GetOption(project, Resources.mocOptionsKeyword));
 }
Ejemplo n.º 49
0
 public void InstallLatestPackage(string source, EnvDTE.Project project, string packageId, bool includePrerelease, bool ignoreDependencies)
 => _packageInstaller.InstallLatestPackage(source, project, packageId, includePrerelease, ignoreDependencies);
Ejemplo n.º 50
0
 public void InstallPackage(string source, EnvDTE.Project project, string packageId, string version, bool ignoreDependencies)
 => _packageInstaller.InstallPackage(source, project, packageId, version, ignoreDependencies);
Ejemplo n.º 51
0
 public void ProjectFinishedGenerating(Project project) {
     if (_wizard != null) {
         _wizard.ProjectFinishedGenerating(project);
     }
 }
Ejemplo n.º 52
0
 public static void SaveLUpdateOnBuild(EnvDTE.Project project, bool value)
 {
     SetBoolValue(project, Resources.lupdateKeyword, value);
 }
Ejemplo n.º 53
0
        private static string GetDirectory(EnvDTE.Project project, string type)
        {
            // check for directory in following order:
            // - stored in project
            // - stored in cache
            // - retrieve from moc/uic steps
            // - globally defined default directory
            // - fallback on hardcoded directory
            if (project != null)
            {
                if (project.Globals.get_VariablePersists(type))
                {
                    return(HelperFunctions.NormalizeRelativeFilePath((string)project.Globals[type]));
                }

                try {
                    if (type == Resources.mocDirKeyword && mocDirCache.Contains(project.FullName))
                    {
                        return((string)mocDirCache[project.FullName]);
                    }
                    if (type == Resources.uicDirKeyword && uicDirCache.Contains(project.FullName))
                    {
                        return((string)uicDirCache[project.FullName]);
                    }
                    if (type == Resources.rccDirKeyword && rccDirCache.Contains(project.FullName))
                    {
                        return((string)rccDirCache[project.FullName]);
                    }

                    QtCustomBuildTool tool         = null;
                    string            configName   = null;
                    string            platformName = null;
                    var vcpro = (VCProject)project.Object;
                    foreach (VCFile vcfile in (IVCCollection)vcpro.Files)
                    {
                        var name = vcfile.Name;
                        if ((type == Resources.mocDirKeyword && HelperFunctions.IsHeaderFile(name)) ||
                            (type == Resources.mocDirKeyword && HelperFunctions.IsMocFile(name)) ||
                            (type == Resources.uicDirKeyword && HelperFunctions.IsUicFile(name)) ||
                            (type == Resources.rccDirKeyword && HelperFunctions.IsQrcFile(name)))
                        {
                            foreach (VCFileConfiguration config in (IVCCollection)vcfile.FileConfigurations)
                            {
                                tool       = new QtCustomBuildTool(config);
                                configName = config.Name.Remove(config.Name.IndexOf('|'));
                                var vcConfig = config.ProjectConfiguration as VCConfiguration;
                                var platform = vcConfig.Platform as VCPlatform;
                                platformName = platform.Name;
                                if (tool != null && (tool.CommandLine.IndexOf("moc.exe", StringComparison.OrdinalIgnoreCase) != -1 ||
                                                     (tool.CommandLine.IndexOf("uic.exe", StringComparison.OrdinalIgnoreCase) != -1) ||
                                                     (tool.CommandLine.IndexOf("rcc.exe", StringComparison.OrdinalIgnoreCase) != -1)))
                                {
                                    break;
                                }
                                tool = null;
                            }

                            if (tool != null)
                            {
                                break;
                            }
                        }
                    }

                    if (tool != null)
                    {
                        string dir       = null;
                        var    lastindex = tool.Outputs.LastIndexOf('\\');
                        if (tool.Outputs.LastIndexOf('/') > lastindex)
                        {
                            lastindex = tool.Outputs.LastIndexOf('/');
                        }

                        if (lastindex == -1)
                        {
                            dir = ".";
                        }
                        else
                        {
                            dir = tool.Outputs.Substring(0, lastindex);
                        }
                        dir = dir.Replace("\"", "");

                        if (type == Resources.mocDirKeyword)
                        {
                            int index;
                            if ((index = dir.IndexOf(configName, StringComparison.OrdinalIgnoreCase)) != -1)
                            {
                                dir = dir.Replace(dir.Substring(index, configName.Length), "$(ConfigurationName)");
                            }
                            if ((index = dir.IndexOf(platformName, StringComparison.OrdinalIgnoreCase)) != -1)
                            {
                                dir = dir.Replace(dir.Substring(index, platformName.Length), "$(PlatformName)");
                            }

                            mocDirCache.Add(project.FullName, HelperFunctions.NormalizeRelativeFilePath(dir));
                        }
                        else if (type == Resources.uicDirKeyword)
                        {
                            uicDirCache.Add(project.FullName, HelperFunctions.NormalizeRelativeFilePath(dir));
                        }
                        else if (type == Resources.rccDirKeyword)
                        {
                            rccDirCache.Add(project.FullName, HelperFunctions.NormalizeRelativeFilePath(dir));
                        }

                        cleanUpCache(project);

                        return(HelperFunctions.NormalizeRelativeFilePath(dir));
                    }
                } catch { }
            }

            return(GetDirectory(type));
        }
Ejemplo n.º 54
0
        public static bool HasDifferentMocFilePerPlatform(EnvDTE.Project project)
        {
            var mocDir = GetMocDirectory(project);

            return(mocDir.Contains("$(PlatformName)"));
        }
Ejemplo n.º 55
0
        private void GenDataSetForm_Load(object sender, System.EventArgs e)
        {
            if (dte == null)
            {
                MessageBox.Show(
                    "Visual Studio .NET DTE could not be found.");
                return;
            }

            if (dte.ActiveDocument == null  ||
                dte.ActiveDocument.ProjectItem == null  ||
                dte.ActiveDocument.ProjectItem.ContainingProject == null)
            {
                MessageBox.Show(
                    "Visual Studio .NET current project could not be found.");
                return;
            }

            currentProject = dte.ActiveDocument.ProjectItem.ContainingProject;
            currentProjectFullPath =
                GetProperty(currentProject.Properties, "FullPath");
            if (currentProjectFullPath.Length == 0  ||
                !System.IO.Directory.Exists(currentProjectFullPath))
            {
                MessageBox.Show(
                    "Visual Studio .NET current project directory " +
                    "\"" + currentProjectFullPath + "\"" +
                    "could not be found.");
                return;
            }
            currentProjectNamespace=
                GetProperty(currentProject.Properties, "RootNamespace");
            if (currentProjectNamespace.Length == 0)
                currentProjectNamespace=
                    GetProperty(currentProject.Properties, "DefaultNamespace");

            existingDataSetProjectItems =
                GetAllDataSetsInProjectItems(
                    new ArrayList(), currentProject.ProjectItems);

            existingDataSetNames =
                GetProjectItemsNames(existingDataSetProjectItems);

            this.comboBoxExisting.DataSource = existingDataSetNames;

            this.textBoxNew.Text = CreateUniqueDataSetName();

            tableNames = new StringCollection();

            string tableName = "Table";
            IDbDataAdapter idbDataAdapter = this.dbDataAdapter as IDbDataAdapter;
            if (idbDataAdapter == null  ||
                idbDataAdapter.SelectCommand == null  ||
                idbDataAdapter.SelectCommand.CommandText == null ||
                idbDataAdapter.SelectCommand.CommandText.Length == 0)
            {
                MessageBox.Show("Adapter's SelectCommand is not configured",
                    "Generate " + DATASETNAME_PREFIX);
                return;
            }

            string cmdText = idbDataAdapter.SelectCommand.CommandText;
            try
            {
                // Scan the SELECT statment,
                // set the CmdTokenList token list for the SQL statement, and
                // build the column and table names lists.
                Ingres.ProviderInternals.MetaData md =
                    new Ingres.ProviderInternals.MetaData(cmdText);
                if (md        != null  &&
                    md.Tables != null  &&
                    md.Tables.Count > 0)
                {
                    Ingres.ProviderInternals.MetaData.Table t =
                        (Ingres.ProviderInternals.MetaData.Table)md.Tables[0];
                    tableName = t.TableName;
                }
            }
            catch(FormatException)  // catch invalid syntax
            {
                MessageBox.Show("Adapter's SelectCommand is not valid syntax.",
                    "Generate " + DATASETNAME_PREFIX);
                return;
            }
            Component component = (Component)this.dbDataAdapter;
            tableName = tableName + " (" + component.Site.Name + ")";
            this.checkedListBoxTables.Items.Add(tableName, CheckState.Checked);

            // we're good to go; activate controls
            if (existingDataSetProjectItems.Count > 0)
                this.radioButtonExisting.Enabled = true;
            this.radioButtonNew.Enabled      = true;
            this.radioButtonNew.Checked      = true;
            this.buttonOK.Enabled            = true;
            this.buttonOK.Focus();  // set focus to OK button
        }
Ejemplo n.º 56
0
        public async Task <IVsProjectAdapter> CreateAdapterForFullyLoadedProjectAsync(EnvDTE.Project dteProject)
        {
            Assumes.Present(dteProject);

            // Get services while we might be on background thread
            var vsSolution = await _vsSolution.GetValueAsync();

            // switch to main thread and use services we know must be done on main thread.
            await _threadingService.JoinableTaskFactory.SwitchToMainThreadAsync();

            var vsHierarchyItem = await VsHierarchyItem.FromDteProjectAsync(dteProject);

            Func <IVsHierarchy, EnvDTE.Project> loadDteProject = _ => dteProject;

            var buildStorageProperty = vsHierarchyItem.VsHierarchy as IVsBuildPropertyStorage;
            var vsBuildProperties    = new VsProjectBuildProperties(
                dteProject, buildStorageProperty, _threadingService);

            var projectNames = await ProjectNames.FromDTEProjectAsync(dteProject, vsSolution);

            var fullProjectPath = dteProject.GetFullProjectPath();

            return(new VsProjectAdapter(
                       vsHierarchyItem,
                       projectNames,
                       fullProjectPath,
                       loadDteProject,
                       vsBuildProperties,
                       _threadingService));
        }
 protected CpsProjectSystem(EnvDTEProject envDTEProject, INuGetProjectContext nuGetProjectContext)
     : base(envDTEProject, nuGetProjectContext)
 {
 }
Ejemplo n.º 58
0
        public async Task ExecuteRegisterPluginAssembly(ConnectionData connectionData, CommonConfiguration commonConfig, EnvDTE.Project project, string defaultOutputFilePath)
        {
            string operation = string.Format(Properties.OperationNames.RegisteringPluginAssemblyFormat1, connectionData?.Name);

            this._iWriteToOutput.WriteToOutputStartOperation(connectionData, operation);

            try
            {
                await RegisterPluginAssembly(connectionData, commonConfig, project, defaultOutputFilePath);
            }
            catch (Exception ex)
            {
                this._iWriteToOutput.WriteErrorToOutput(connectionData, ex);
            }
            finally
            {
                this._iWriteToOutput.WriteToOutputEndOperation(connectionData, operation);
            }
        }
Ejemplo n.º 59
0
        public UserDefinedScript(string fileName, EnvDTE.Project project)
        {
            if (!File.Exists(fileName))
            {
                throw new Exception("The file '" + fileName + "' does not exists.");
            }

            this.FileName = fileName;
            var text  = File.ReadAllText(this.FileName);
            var lines = text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
            var line  = lines.FirstOrDefault(x => x.StartsWith("--MODELID: "));

            if (!string.IsNullOrEmpty(line))
            {
                //Set type
                if (fileName.ToLower().Contains(@"\stored procedures\user defined"))
                {
                    this.TypeName = "Stored Procedure";
                }
                else if (fileName.ToLower().Contains(@"\views\user defined"))
                {
                    this.TypeName = "View";
                }
                else if (fileName.ToLower().Contains(@"\functions\user defined"))
                {
                    this.TypeName = "Function";
                }

                var gText = line.Replace("--MODELID:", string.Empty).Trim();
                var pText = "0";
                if (gText.Contains(","))
                {
                    var cindex = gText.IndexOf(",");
                    pText = gText.Substring(cindex + 1, gText.Length - cindex - 1).Replace("PrecedenceOrder:", string.Empty).Trim();
                    gText = gText.Substring(0, cindex);
                }

                this.IsValid = true;
                this.Name    = (new FileInfo(this.FileName)).Name;

                Guid g;
                if (Guid.TryParse(gText, out g))
                {
                    this.ID = g;
                }
                else
                {
                    this.IsValid = false;
                }

                int prec;
                if (int.TryParse(pText, out prec))
                {
                    this.PrecedenceOrder = prec;
                }
                else
                {
                    this.IsValid = false;
                }
            }
        }
Ejemplo n.º 60
0
 public static string GetLReleaseOptions(EnvDTE.Project project)
 {
     return(GetOption(project, Resources.lreleaseOptionsKeyword));
 }