/// <summary> /// This is where the nominate calls for the IVs1 and IVS3 APIs combine. The reason for this method is to avoid duplication and potential issues /// The issue with this method is that it has some weird custom logging to ensure backward compatibility. It's on the implementer to ensure these calls are correct. /// <param name="projectUniqueName">projectUniqueName</param> /// <param name="projectRestoreInfo">projectRestoreInfo. Can be null</param> /// <param name="projectRestoreInfo2">proectRestoreInfo2. Can be null</param> /// <param name="token"></param> /// <remarks>Exactly one of projectRestoreInfos has to null.</remarks> /// <returns>The task that scheduled restore</returns> private Task <bool> NominateProjectAsync(string projectUniqueName, IVsProjectRestoreInfo projectRestoreInfo, IVsProjectRestoreInfo2 projectRestoreInfo2, CancellationToken token) { if (string.IsNullOrEmpty(projectUniqueName)) { throw new ArgumentException(Resources.Argument_Cannot_Be_Null_Or_Empty, nameof(projectUniqueName)); } if (projectRestoreInfo == null && projectRestoreInfo2 == null) { throw new ArgumentNullException(nameof(projectRestoreInfo)); } if (projectRestoreInfo != null && projectRestoreInfo2 != null) { throw new ArgumentException($"Internal error: Both {nameof(projectRestoreInfo)} and {nameof(projectRestoreInfo2)} cannot have values. Please file an issue at NuGet/Home if you see this exception."); } if (projectRestoreInfo != null) { if (projectRestoreInfo.TargetFrameworks == null) { throw new InvalidOperationException("TargetFrameworks cannot be null."); } } else { if (projectRestoreInfo2.TargetFrameworks == null) { throw new InvalidOperationException("TargetFrameworks cannot be null."); } } try { _logger.LogInformation( $"The nominate API is called for '{projectUniqueName}'."); var projectNames = ProjectNames.FromFullProjectPath(projectUniqueName); var dgSpec = ToDependencyGraphSpec(projectNames, projectRestoreInfo, projectRestoreInfo2); _projectSystemCache.AddProjectRestoreInfo(projectNames, dgSpec); // returned task completes when scheduled restore operation completes. var restoreTask = _restoreWorker.ScheduleRestoreAsync( SolutionRestoreRequest.OnUpdate(), token); return(restoreTask); } catch (OperationCanceledException) { throw; } catch (Exception e) { _logger.LogError(e.ToString()); return(Task.FromResult(false)); } }
public void AddProjectRestoreInfo_TriggersNoEvent_NoEventHandler() { // Arrange var target = new ProjectSystemCache(); var projectNames = new ProjectNames( fullName: @"C:\src\project\project.csproj", uniqueName: @"folder\project", shortName: "project", customUniqueName: @"folder\project"); var projectNamesFromFullPath = ProjectNames.FromFullProjectPath(@"C:\src\project\project.csproj"); var projectRestoreInfo = new DependencyGraphSpec(); // Act target.AddProjectRestoreInfo(projectNamesFromFullPath, projectRestoreInfo); target.AddProject(projectNames, vsProjectAdapter: null, nuGetProject: null); // Assert DependencyGraphSpec actual; ProjectNames names; var getPackageSpecSuccess = target.TryGetProjectRestoreInfo(projectNames.FullName, out actual); var getProjectNameSuccess = target.TryGetProjectNames(projectNames.UniqueName, out names); Assert.True(getPackageSpecSuccess); Assert.True(getProjectNameSuccess); Assert.Same(projectRestoreInfo, actual); Assert.Equal(@"folder\project", names.CustomUniqueName); // Cache remains clean since no one is listening to the cache events Assert.Equal(target.IsCacheDirty, 0); }
public void AddProject_RemoveProject_Clear_TriggerNoEvent_WithEventHandler() { // Arrange var target = new ProjectSystemCache(); var projectNames = new ProjectNames( fullName: @"C:\src\project\project.csproj", uniqueName: @"folder\project", shortName: "project", customUniqueName: @"folder\project"); var projectNamesFromFullPath = ProjectNames.FromFullProjectPath(@"C:\src\project\project.csproj"); var projectRestoreInfo = new DependencyGraphSpec(); var eventCount = 0; target.CacheUpdated += delegate(object sender, NuGetEventArgs <string> e) { if (target.TestResetDirtyFlag()) { eventCount++; } }; // Act target.AddProject(projectNames, vsProjectAdapter: null, nuGetProject: null); target.RemoveProject(projectNames.FullName); target.Clear(); // Assert Assert.Equal(target.IsCacheDirty, 0); Assert.Equal(eventCount, 0); }
public void TryGetDTEProject_ReturnsNullWhenShortNameIsAmbiguous() { // Arrange var target = new ProjectSystemCache(); var projectNamesA = new ProjectNames( fullName: @"C:\src\projectA\project.csproj", uniqueName: @"folderA\project", shortName: "project", customUniqueName: @"folderA\project"); var projectNamesB = new ProjectNames( fullName: @"C:\src\projectB\project.csproj", uniqueName: @"folderB\project", shortName: projectNamesA.ShortName, customUniqueName: @"folderB\project"); target.AddProject(projectNamesA, vsProjectAdapter: null, nuGetProject: null); target.AddProject(projectNamesB, vsProjectAdapter: null, nuGetProject: null); IVsProjectAdapter actual; // Act var success = target.TryGetVsProjectAdapter(projectNamesA.ShortName, out actual); // Assert Assert.False(success, "The project should not have been fetched from the cache by short name."); Assert.Null(actual); }
public void AddProject_AfterAddProjectRestoreInfo_UpdatesCacheEntry() { // Arrange var target = new ProjectSystemCache(); var projectNames = new ProjectNames( fullName: @"C:\src\project\project.csproj", uniqueName: @"folder\project", shortName: "project", customUniqueName: @"folder\project"); var projectNamesFromFullPath = ProjectNames.FromFullProjectPath(@"C:\src\project\project.csproj"); var projectRestoreInfo = new DependencyGraphSpec(); target.AddProjectRestoreInfo(projectNamesFromFullPath, projectRestoreInfo); // Act target.AddProject(projectNames, vsProjectAdapter: null, nuGetProject: null); // Assert DependencyGraphSpec actual; ProjectNames names; var getPackageSpecSuccess = target.TryGetProjectRestoreInfo(projectNames.FullName, out actual); var getProjectNameSuccess = target.TryGetProjectNames(projectNames.UniqueName, out names); Assert.True(getPackageSpecSuccess); Assert.True(getProjectNameSuccess); Assert.Same(projectRestoreInfo, actual); Assert.Equal(@"folder\project", names.CustomUniqueName); }
private static DependencyGraphSpec ToDependencyGraphSpec(ProjectNames projectNames, IVsProjectRestoreInfo projectRestoreInfo) { var dgSpec = new DependencyGraphSpec(); var packageSpec = ToPackageSpec(projectNames, projectRestoreInfo); dgSpec.AddRestore(packageSpec.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(packageSpec); if (projectRestoreInfo.ToolReferences != null) { projectRestoreInfo .ToolReferences .Cast <IVsReferenceItem>() .Select(r => ToToolPackageSpec(projectNames, r)) .ToList() .ForEach(ts => { dgSpec.AddRestore(ts.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(ts); }); } return(dgSpec); }
/****************** * ToolReferences * ******************/ internal static void ProcessToolReferences(ProjectNames projectNames, IEnumerable targetFrameworks, IVsReferenceItems toolReferences, DependencyGraphSpec dgSpec) { var toolFramework = GetToolFramework(targetFrameworks); var packagesPath = GetRestoreProjectPath(targetFrameworks); var fallbackFolders = GetRestoreFallbackFolders(targetFrameworks).AsList(); var sources = GetRestoreSources(targetFrameworks) .Select(e => new PackageSource(e)) .ToList(); toolReferences .Cast <IVsReferenceItem>() .Select(r => ToolRestoreUtility.GetSpec( projectNames.FullName, r.Name, GetVersionRange(r), toolFramework, packagesPath, fallbackFolders, sources, projectWideWarningProperties: null)) .ForEach(ts => { dgSpec.AddRestore(ts.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(ts); }); }
static IServiceCollection RegisterServices(IServiceCollection services) { var projectNamesList = ProjectNames.Split(','); return(services .RegisterServices(a => a.AddConsole()) .AddSingleton <Shared.Abstractions.IConfiguration>(new Configuration(SolutionName, Output, projectNamesList, XmlConfigurationPath))); }
protected void btnProjectImport_Click(object sender, EventArgs e) { var projectnamelist = new List <ProjectNamesEntity>(); // NEED 1 (first) if (txtImportDate.Text != "" && txtImportDate.Text != null) { var projectDeno = new ProjectNames().FindByImportedDateWithSheet(GeneralUtility.ConvertMonthYearStringFormat(txtImportDate.Text.Trim()), ddlJobName.SelectedValue, ddlStatus.SelectedValue); if (projectDeno.Count() == 0) { if (FileUpload1.HasFile) { if (Path.GetExtension(FileUpload1.FileName) == ".xlsx") { ExcelPackage package = new ExcelPackage(FileUpload1.FileContent); // NEED 2 (first) ExcelWorksheet workSheet = package.Workbook.Worksheets.First(); // NEED 2 (first) // workSheet.DeleteRow(1); // NEED 3 (first) ProjectName_BindBusiness(projectnamelist, workSheet); // NEED 4 (first) } } #region Save Project Names (first) ProjectNames itemBusiness = new ProjectNames(); using (TransactionScope Scope = new TransactionScope()) { try { foreach (var v in projectnamelist) { itemBusiness.Entity = v; itemBusiness.Save(); } Scope.Complete(); MessageBox.MessageShow(this.GetType(), "Project Names Import Successfully!.", ClientScript); } catch (Exception ex) { Response.Redirect("error.aspx"); throw ex; } } #endregion } else { MessageBox.MessageShow(this.GetType(), "This Excel File has already been Imported!", ClientScript); } } else { MessageBox.MessageShow(this.GetType(), "Please Choose Import Date!.", ClientScript); } }
private ProjectNames GetTestProjectNames() { var projectNames = new ProjectNames( fullName: @"C:\src\project\project.csproj", uniqueName: @"folder\project", shortName: "project", customUniqueName: @"folder\project"); return(projectNames); }
private static PackageSpec ToPackageSpec(ProjectNames projectNames, IVsProjectRestoreInfo projectRestoreInfo) { var tfis = projectRestoreInfo .TargetFrameworks .Cast <IVsTargetFrameworkInfo>() .Select(ToTargetFrameworkInformation) .ToArray(); var projectFullPath = Path.GetFullPath(projectNames.FullName); var projectDirectory = Path.GetDirectoryName(projectFullPath); // TODO: Remove temporary integration code NuGet/Home#3810 // Initialize OTF and CT values when original value of OTF property is not provided. var originalTargetFrameworks = tfis .Select(tfi => tfi.FrameworkName.GetShortFolderName()) .ToArray(); var crossTargeting = originalTargetFrameworks.Length > 1; // if "TargetFrameworks" property presents in the project file prefer the raw value. if (!string.IsNullOrWhiteSpace(projectRestoreInfo.OriginalTargetFrameworks)) { originalTargetFrameworks = MSBuildStringUtility.Split( projectRestoreInfo.OriginalTargetFrameworks); // cross-targeting is always ON even in case of a single tfm in the list. crossTargeting = true; } var packageSpec = new PackageSpec(tfis) { Name = GetPackageId(projectNames, projectRestoreInfo.TargetFrameworks), Version = GetPackageVersion(projectRestoreInfo.TargetFrameworks), FilePath = projectFullPath, RestoreMetadata = new ProjectRestoreMetadata { ProjectName = projectNames.ShortName, ProjectUniqueName = projectFullPath, ProjectPath = projectFullPath, OutputPath = Path.GetFullPath( Path.Combine( projectDirectory, projectRestoreInfo.BaseIntermediatePath)), ProjectStyle = ProjectStyle.PackageReference, TargetFrameworks = projectRestoreInfo.TargetFrameworks .Cast <IVsTargetFrameworkInfo>() .Select(item => ToProjectRestoreMetadataFrameworkInfo(item, projectDirectory)) .ToList(), OriginalTargetFrameworks = originalTargetFrameworks, CrossTargeting = crossTargeting }, RuntimeGraph = GetRuntimeGraph(projectRestoreInfo) }; return(packageSpec); }
internal bool IsSupportedProject(Project project) { if (Language == null || Language == project.Language) { return((ProjectNames.Count > 0) ? ProjectNames.Contains(project.Name) : !IgnoredProjectNames.Contains(project.Name)); } return(false); }
private ProjectNames GetTestProjectNames(string projectPath, string projectUniqueName) { var projectNames = new ProjectNames( fullName: projectPath, uniqueName: projectUniqueName, shortName: projectUniqueName, customUniqueName: projectUniqueName, projectId: Guid.NewGuid().ToString()); return(projectNames); }
protected override Task InitializeAsync(object sender, SectionInitializeEventArgs e) { _branchTeamService = new BranchTeamService(Context.TeamProjectCollection, (ITeamExplorer)ServiceProvider.GetService(typeof(ITeamExplorer))); _teamChangesetChangesetProvider = new TeamChangesetChangesetProvider(ServiceProvider); var projectNames = _teamChangesetChangesetProvider.ListProjects(); projectNames.ForEach(x => ProjectNames.Add(x.Name)); return(base.InitializeAsync(sender, e)); }
public void Ctor_ProjectIdIsValidGuid_NormalizesGuid(string projectIdString) { var projectId = new ProjectNames( fullName: "proj", uniqueName: "proj", shortName: "proj", customUniqueName: "proj", projectId: projectIdString); Assert.Equal("b9f8e0c3-d837-4ca5-9c5c-d9f4d80e1a4b", projectId.ProjectId); }
internal bool IsSupportedProject(Project project) { if (SyntaxFactsService.IsSupportedLanguage(project.Language) && (Language == null || Language == project.Language)) { return((ProjectNames.Count > 0) ? ProjectNames.Contains(project.Name) : !IgnoredProjectNames.Contains(project.Name)); } return(false); }
private static void PopulateProjectNames(DTE dte) { Solution = (IVsPersistSolutionProps)GetGlobalService(typeof(IVsPersistSolutionProps)); Projects projects = dte.Solution.Projects; string solutionName = dte.Solution.FullName; solutionName = solutionName.Substring(solutionName.LastIndexOf('\\') + 1); foreach (Project project in projects) { ProjectNames.Add(project); IEnumerable <AssemblyName> references; try { references = CollectSettings(project) .Where(assembly => assembly.Name.StartsWith("Cqrs")) .ToList(); } catch (NullReferenceException) { continue; } foreach (AssemblyName assemblyName in references) { string urlPath = string.Format("/{0}/{1}/{2}/{3}/{4}/{5}/{6}/{7}", HttpUtility.UrlPathEncode(dte.Version), HttpUtility.UrlPathEncode(dte.Edition), HttpUtility.UrlPathEncode(solutionName), HttpUtility.UrlPathEncode(project.Name), HttpUtility.UrlPathEncode(project.Kind), HttpUtility.UrlPathEncode(project.UniqueName.Replace('\\', '¿')), HttpUtility.UrlPathEncode(assemblyName.Name), HttpUtility.UrlPathEncode(assemblyName.Version.ToString())); HttpWebRequest request = WebRequest.Create(string.Format("https://www.chinchillasoftware.com/VisualStudio{0}", urlPath)) as HttpWebRequest; request.Method = "GET"; try { new TaskFactory().StartNew(() => { using (request.GetResponse()) { Debug.WriteLine("Called '{0}'.", request.Address); } }); Debug.WriteLine("Calling '{0}'.", request.Address); } catch { } } } }
public Task <bool> NominateProjectAsync(string projectUniqueName, IVsProjectRestoreInfo projectRestoreInfo, CancellationToken token) { if (string.IsNullOrEmpty(projectUniqueName)) { throw new ArgumentException(Resources.Argument_Cannot_Be_Null_Or_Empty, nameof(projectUniqueName)); } if (projectRestoreInfo == null) { throw new ArgumentNullException(nameof(projectRestoreInfo)); } if (projectRestoreInfo.TargetFrameworks == null) { throw new InvalidOperationException("TargetFrameworks cannot be null."); } try { _logger.LogInformation( $"The nominate API is called for '{projectUniqueName}'."); var projectNames = ProjectNames.FromFullProjectPath(projectUniqueName); var dgSpec = ToDependencyGraphSpec(projectNames, projectRestoreInfo); #if DEBUG DumpProjectRestoreInfo(projectUniqueName, dgSpec); #endif _projectSystemCache.AddProjectRestoreInfo(projectNames, dgSpec); // returned task completes when scheduled restore operation completes. var restoreTask = _restoreWorker.ScheduleRestoreAsync( SolutionRestoreRequest.OnUpdate(), token); return(restoreTask); } catch (Exception e) when(e is InvalidOperationException || e is ArgumentException || e is FormatException) { _logger.LogError(e.ToString()); return(Task.FromResult(false)); } catch (Exception e) { _logger.LogError(e.ToString()); throw; } }
public TestVSProjectAdapter( string fullProjectPath, ProjectNames projectNames, string targetFrameworkString, string restorePackagesWithLockFile = null, string nuGetLockFilePath = null, bool restoreLockedMode = false) { FullProjectPath = fullProjectPath; ProjectNames = projectNames; _targetFrameworkString = targetFrameworkString; _restorePackagesWithLockFile = restorePackagesWithLockFile; _nuGetLockFilePath = nuGetLockFilePath; _restoreLockedMode = restoreLockedMode; }
/// <summary> /// Connects to the TFS server specified by <see cref="IServerManagement.CurrentUri"/>. /// </summary> public async Task ConnectAsync() { await HandleServerError(async() => { IsConnecting = true; try { var serverUrl = Servers.CurrentUri; bool serverChanged = !UriEqualityComparer.Instance.Equals(serverUrl, _explorer.Server?.Uri); if (_explorer.Server != null) { _explorer.Server.ConnectionStatusChanged -= Server_ConnectionStatusChanged; } await _explorer.ConnectAsync(serverUrl); _explorer.Server.ConnectionStatusChanged += Server_ConnectionStatusChanged; var currentProjectName = ProjectName; ProjectNames.Clear(); ProjectNames.AddRange((await _explorer.GetTeamProjectsAsync()).Select(n => n.Name)); // Restore project name on reconnect. if (ProjectNames.Contains(currentProjectName) && !serverChanged) { ProjectName = currentProjectName; } if (serverChanged) { ProjectName = null; } IsConnected = true; Servers.Add(serverUrl); OnConnectionSucceeded(serverUrl); await Task.CompletedTask; } finally { IsConnecting = false; } }); }
public async Task GetPackageSpecAsync_CentralPackageVersionsRemovedDuplicates() { // Arrange var packageAv1 = (PackageId : "packageA", Version : "1.2.3"); var packageB = (PackageId : "packageB", Version : "3.4.5"); var packageAv5 = (PackageId : "packageA", Version : "5.0.0"); var projectNames = new ProjectNames( fullName: "projectName", uniqueName: "projectName", shortName: "projectName", customUniqueName: "projectName", projectId: Guid.NewGuid().ToString()); var vsProjectAdapter = new TestVSProjectAdapter( "projectPath", projectNames, "framework", restorePackagesWithLockFile: null, nuGetLockFilePath: null, restoreLockedMode: false, projectPackageVersions: new List <(string Id, string Version)>() { packageAv1, packageB, packageAv5 }); var legacyPRProject = new LegacyPackageReferenceProject( vsProjectAdapter, Guid.NewGuid().ToString(), new TestProjectSystemServices(), _threadingService); var settings = NullSettings.Instance; var context = new DependencyGraphCacheContext(NullLogger.Instance, settings); var packageSpecs = await legacyPRProject.GetPackageSpecsAsync(context); Assert.Equal(1, packageSpecs.Count); Assert.True(packageSpecs.First().RestoreMetadata.CentralPackageVersionsEnabled); var centralPackageVersions = packageSpecs.First().TargetFrameworks.First().CentralPackageVersions; Assert.Equal(2, centralPackageVersions.Count); Assert.Equal(VersionRange.Parse(packageAv1.Version), centralPackageVersions[packageAv1.PackageId].VersionRange); Assert.Equal(VersionRange.Parse(packageB.Version), centralPackageVersions[packageB.PackageId].VersionRange); }
private static DependencyGraphSpec ToDependencyGraphSpec(ProjectNames projectNames, IVsProjectRestoreInfo projectRestoreInfo) { var dgSpec = new DependencyGraphSpec(); var packageSpec = ToPackageSpec(projectNames, projectRestoreInfo); dgSpec.AddRestore(packageSpec.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(packageSpec); if (projectRestoreInfo.ToolReferences != null) { var toolFramework = GetNonEvaluatedPropertyOrNull( projectRestoreInfo.TargetFrameworks, ProjectBuildProperties.DotnetCliToolTargetFramework, NuGetFramework.Parse) ?? CommonFrameworks.NetCoreApp10; var packagesPath = GetRestoreProjectPath(projectRestoreInfo.TargetFrameworks); var fallbackFolders = GetRestoreFallbackFolders(projectRestoreInfo.TargetFrameworks).AsList(); var sources = GetRestoreSources(projectRestoreInfo.TargetFrameworks) .Select(e => new PackageSource(e)) .ToList(); projectRestoreInfo .ToolReferences .Cast <IVsReferenceItem>() .Select(r => ToolRestoreUtility.GetSpec( projectNames.FullName, r.Name, GetVersionRange(r), toolFramework, packagesPath, fallbackFolders, sources, projectWideWarningProperties: null)) .ForEach(ts => { dgSpec.AddRestore(ts.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(ts); }); } return(dgSpec); }
public void TryGetDTEProject_ReturnsProjectByUniqueName() { // Arrange var target = new ProjectSystemCache(); var projectNames = new ProjectNames( fullName: @"C:\src\project\project.csproj", uniqueName: @"folder\project", shortName: "project", customUniqueName: @"folder\project"); var dteProject = new Mock <EnvDTE.Project>(); target.AddProject(projectNames, dteProject.Object, nuGetProject: null); EnvDTE.Project actual; // Act var success = target.TryGetDTEProject(projectNames.UniqueName, out actual); // Assert Assert.True(success, "The project should have been fetched from the cache by unique name."); Assert.Same(dteProject.Object, actual); }
public async Task InitializeAsync(TeamMergeContext teamMergeContext) { await _setBusyWhileExecutingAsync(async() => { var projectNames = await _teamService.GetProjectNamesAsync(); Workspaces = new ObservableCollection <Workspace>(await _teamService.AllWorkspacesAsync()); SelectedWorkspace = _teamService.CurrentWorkspace() ?? Workspaces.First(); projectNames.ToList().ForEach(x => ProjectNames.Add(x)); if (teamMergeContext != null) { RestoreContext(teamMergeContext); } else { SetSavedSelectedBranches(); } }); }
public void TryGetDTEProject_ReturnsProjectWhenShortNameIsNotAmbiguous() { // Arrange var target = new ProjectSystemCache(); var projectNames = new ProjectNames( fullName: @"C:\src\project\project.csproj", uniqueName: @"folder\project", shortName: "project", customUniqueName: @"folder\project"); var vsProjectAdapter = new Mock <IVsProjectAdapter>(); target.AddProject(projectNames, vsProjectAdapter.Object, nuGetProject: null); IVsProjectAdapter actual; // Act var success = target.TryGetVsProjectAdapter(projectNames.ShortName, out actual); // Assert Assert.True(success, "The project should have been fetched from the cache by short name."); Assert.Same(vsProjectAdapter.Object, actual); }
public async Task ApplicationLogAdded(string functionName, ErrorMessageCode errorCode, ProjectNames projectName, ApplicationType appType, DateTime _time, string errorText, int userid = 0, int Moduleid = 0) { PosApplicationLogsProcess applicationLogManager = PosApplicationLogsProcess.PosApplicationLogProcessMultiton(conHelper); posApplicationLogs appLog = new posApplicationLogs { UserID = userid, ModuleID = Moduleid, ProjectName = projectName, AppType = appType, CreatedDate = _time, ErrorMessageCode = errorCode, ErrorText = "{" + functionName + " }" + " { " + errorText + " }" }; applicationLogManager.posApplicationLogInsert(appLog); }
private static DependencyGraphSpec ToDependencyGraphSpec(ProjectNames projectNames, IVsProjectRestoreInfo projectRestoreInfo, IVsProjectRestoreInfo2 projectRestoreInfo2) { var dgSpec = new DependencyGraphSpec(); var packageSpec = projectRestoreInfo != null? ToPackageSpec(projectNames, projectRestoreInfo.TargetFrameworks, projectRestoreInfo.OriginalTargetFrameworks, projectRestoreInfo.BaseIntermediatePath) : ToPackageSpec(projectNames, projectRestoreInfo2.TargetFrameworks, projectRestoreInfo2.OriginalTargetFrameworks, projectRestoreInfo2.BaseIntermediatePath); dgSpec.AddRestore(packageSpec.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(packageSpec); if (projectRestoreInfo != null && projectRestoreInfo.ToolReferences != null) { VSNominationUtilities.ProcessToolReferences(projectNames, projectRestoreInfo.TargetFrameworks, projectRestoreInfo.ToolReferences, dgSpec); } else if (projectRestoreInfo2 != null && projectRestoreInfo2.ToolReferences != null) { VSNominationUtilities.ProcessToolReferences(projectNames, projectRestoreInfo2.TargetFrameworks, projectRestoreInfo2.ToolReferences, dgSpec); } return(dgSpec); }
public void AddProjectRestoreInfo_TriggersEvent_WithEventHandler_NoReset() { // Arrange var target = new ProjectSystemCache(); var projectNames = new ProjectNames( fullName: @"C:\src\project\project.csproj", uniqueName: @"folder\project", shortName: "project", customUniqueName: @"folder\project"); var projectNamesFromFullPath = ProjectNames.FromFullProjectPath(@"C:\src\project\project.csproj"); var projectRestoreInfo = new DependencyGraphSpec(); var eventCount = 0; target.CacheUpdated += delegate(object sender, NuGetEventArgs <string> e) { eventCount++; }; // Act target.AddProjectRestoreInfo(projectNamesFromFullPath, projectRestoreInfo); target.AddProjectRestoreInfo(projectNamesFromFullPath, projectRestoreInfo); target.AddProject(projectNames, vsProjectAdapter: null, nuGetProject: null); // Assert DependencyGraphSpec actual; ProjectNames names; var getPackageSpecSuccess = target.TryGetProjectRestoreInfo(projectNames.FullName, out actual); var getProjectNameSuccess = target.TryGetProjectNames(projectNames.UniqueName, out names); Assert.True(getPackageSpecSuccess); Assert.True(getProjectNameSuccess); Assert.Same(projectRestoreInfo, actual); Assert.Equal(@"folder\project", names.CustomUniqueName); // Since no listener resets the dirty flag, the cache remains dirty and only 1 event is raised. Assert.Equal(target.IsCacheDirty, 1); Assert.Equal(eventCount, 1); }
public override async void Initialize(object sender, SectionInitializeEventArgs e) { base.Initialize(sender, e); await SetBusyWhileExecutingAsync(async() => { var projectNames = await _teamService.GetProjectNames(); Workspaces = new ObservableCollection <WorkspaceModel>(await _teamService.AllWorkspaces()); SelectedWorkspace = _teamService.CurrentWorkspace() ?? Workspaces.First(); projectNames.ToList().ForEach(x => ProjectNames.Add(x)); if (e.Context != null) { RestoreContext(e); } else { SetSavedSelectedBranches(); } }); }
private static DependencyGraphSpec ToDependencyGraphSpec(ProjectNames projectNames, IVsProjectRestoreInfo projectRestoreInfo) { var dgSpec = new DependencyGraphSpec(); var packageSpec = ToPackageSpec(projectNames, projectRestoreInfo); dgSpec.AddRestore(packageSpec.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(packageSpec); if (projectRestoreInfo.ToolReferences != null) { // Infer tool's TFM version from the current project TFM var projectTfms = projectRestoreInfo .TargetFrameworks .Cast <IVsTargetFrameworkInfo>() .Select(tfi => NuGetFramework.Parse(tfi.TargetFrameworkMoniker)) .ToList(); var isNetCore20 = projectTfms .Where(tfm => tfm.Framework == FrameworkIdentifiers.NetCoreApp || tfm.Framework == FrameworkIdentifiers.NetStandard) .Any(tfm => tfm.Version >= Version20); var toolFramework = isNetCore20 ? CommonFrameworks.NetCoreApp20 : CommonFrameworks.NetCoreApp10; projectRestoreInfo .ToolReferences .Cast <IVsReferenceItem>() .Select(r => ToToolPackageSpec(projectNames, r, toolFramework)) .ToList() .ForEach(ts => { dgSpec.AddRestore(ts.RestoreMetadata.ProjectUniqueName); dgSpec.AddProject(ts); }); } return(dgSpec); }