public ApplyChangesToWorkspaceContext(ConfiguredProject project, IProjectDiagnosticOutputService logger, [ImportMany] ExportFactory <IWorkspaceContextHandler>[] workspaceContextHandlerFactories) { _project = project; _logger = logger; _workspaceContextHandlerFactories = workspaceContextHandlerFactories; CommandLineParsers = new OrderPrecedenceImportCollection <ICommandLineParserService>(projectCapabilityCheckProvider: project); }
/// <summary> /// If <see cref="IProjectDiagnosticOutputService.IsEnabled"/> is <see langword="true"/>, /// writes the text representation of the specified objects, followed /// by the current line terminator, to the log using the specified /// format information. /// </summary> /// <exception cref="ArgumentNullException"> /// <paramref name="logger"/> is <see langword="null"/> /// <para> /// -or- /// </para> /// <paramref name="format"/> is <see langword="null"/>. /// </exception> /// <exception cref="FormatException"> /// The format specification in <paramref name="format"/> is invalid. /// </exception> public static void WriteLine(this IProjectDiagnosticOutputService logger, string format, object?argument1, object?argument2, object?argument3) { Requires.NotNull(logger, nameof(logger)); if (logger.IsEnabled) { logger.WriteLine(string.Format(format, argument1, argument2, argument3)); } }
public static void EndNominateRestore(IProjectDiagnosticOutputService logger, string fullPath) { if (logger.IsEnabled) { using var batch = new BatchLogger(logger); batch.WriteLine(); batch.WriteLine("------------------------------------------"); batch.WriteLine($"COMPLETED Nominate Restore for {fullPath}"); batch.WriteLine(); } }
public PackageRestoreDataSourceMocked(UnconfiguredProject project, IPackageRestoreUnconfiguredInputDataSource dataSource, IProjectAsynchronousTasksService projectAsynchronousTasksService, IVsSolutionRestoreService3 solutionRestoreService, IFileSystem fileSystem, IProjectDiagnosticOutputService logger, IVsSolutionRestoreService4 solutionRestoreService4, PackageRestoreSharedJoinableTaskCollection sharedJoinableTaskCollection) : base(project, dataSource, projectAsynchronousTasksService, solutionRestoreService, fileSystem, logger, solutionRestoreService4, sharedJoinableTaskCollection) { }
public PackageRestoreDataSource( UnconfiguredProject project, IPackageRestoreUnconfiguredInputDataSource dataSource, [Import(ExportContractNames.Scopes.UnconfiguredProject)] IProjectAsynchronousTasksService projectAsynchronousTasksService, IVsSolutionRestoreService3 solutionRestoreService, IFileSystem fileSystem, IProjectDiagnosticOutputService logger, IProjectDependentFileChangeNotificationService projectDependentFileChangeNotificationService) : base(project, synchronousDisposal: true, registerDataSource: false) { _project = project; _dataSource = dataSource; _projectAsynchronousTasksService = projectAsynchronousTasksService; _solutionRestoreService = solutionRestoreService; _fileSystem = fileSystem; _logger = logger; _projectDependentFileChangeNotificationService = projectDependentFileChangeNotificationService; }
public PackageRestoreDataSource( UnconfiguredProject project, IPackageRestoreUnconfiguredInputDataSource dataSource, [Import(ExportContractNames.Scopes.UnconfiguredProject)] IProjectAsynchronousTasksService projectAsynchronousTasksService, IVsSolutionRestoreService3 solutionRestoreService, IFileSystem fileSystem, IProjectDiagnosticOutputService logger, IVsSolutionRestoreService4 solutionRestoreService4, PackageRestoreSharedJoinableTaskCollection sharedJoinableTaskCollection) : base(project, sharedJoinableTaskCollection, synchronousDisposal: true, registerDataSource: false) { _project = project; _dataSource = dataSource; _projectAsynchronousTasksService = projectAsynchronousTasksService; _solutionRestoreService = solutionRestoreService; _fileSystem = fileSystem; _logger = logger; _solutionRestoreService4 = solutionRestoreService4; }
public static void BeginNominateRestore(IProjectDiagnosticOutputService logger, string fullPath, IVsProjectRestoreInfo2 projectRestoreInfo) { if (logger.IsEnabled) { using var batch = new BatchLogger(logger); batch.WriteLine(); batch.WriteLine("------------------------------------------"); batch.WriteLine($"BEGIN Nominate Restore for {fullPath}"); batch.IndentLevel++; batch.WriteLine($"MSBuildProjectExtensionsPath: {projectRestoreInfo.BaseIntermediatePath}"); batch.WriteLine($"OriginalTargetFrameworks: {projectRestoreInfo.OriginalTargetFrameworks}"); LogTargetFrameworks(batch, projectRestoreInfo.TargetFrameworks); LogReferenceItems(batch, "Tool References", projectRestoreInfo.ToolReferences); batch.IndentLevel--; batch.WriteLine(); } }
private static PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null) { project ??= UnconfiguredProjectFactory.Create(IProjectThreadingServiceFactory.Create()); dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create(); IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create(); solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create(); IProjectDiagnosticOutputService logger = IProjectDiagnosticOutputServiceFactory.Create(); IFileSystem fileSystem = IFileSystemFactory.Create(); var projectDependentFileChangeNotificationService = IProjectDependentFileChangeNotificationServiceFactory.Create(); return(new PackageRestoreDataSource( project, dataSource, projectAsynchronousTasksService, solutionRestoreService, fileSystem, logger, projectDependentFileChangeNotificationService)); }
private static PackageRestoreDataSource CreateInstance(UnconfiguredProject?project = null, IPackageRestoreUnconfiguredInputDataSource?dataSource = null, IVsSolutionRestoreService3?solutionRestoreService = null) { project ??= UnconfiguredProjectFactory.CreateWithActiveConfiguredProjectProvider(IProjectThreadingServiceFactory.Create()); dataSource ??= IPackageRestoreUnconfiguredInputDataSourceFactory.Create(); IProjectAsynchronousTasksService projectAsynchronousTasksService = IProjectAsynchronousTasksServiceFactory.Create(); solutionRestoreService ??= IVsSolutionRestoreServiceFactory.Create(); IProjectDiagnosticOutputService logger = IProjectDiagnosticOutputServiceFactory.Create(); IFileSystem fileSystem = IFileSystemFactory.Create(); var vsSolutionRestoreService4 = IVsSolutionRestoreService4Factory.ImplementRegisterRestoreInfoSourceAsync(); var sharedJoinableTaskCollection = new PackageRestoreSharedJoinableTaskCollection(IProjectThreadingServiceFactory.Create()); return(new PackageRestoreDataSourceMocked( project, dataSource, projectAsynchronousTasksService, solutionRestoreService, fileSystem, logger, vsSolutionRestoreService4, sharedJoinableTaskCollection)); }
private bool TryHandleSpecificProperties(string name, string value, IProjectDiagnosticOutputService logger) { // The language service wants both the intermediate (bin\obj) and output (bin\debug)) paths // so that it can automatically hook up project-to-project references. It does this by matching the // bin output path with the another project's /reference argument, if they match, then it automatically // introduces a project reference between the two. We pass the intermediate path via the /out // command-line argument and set via one of the other handlers, where as the latter is calculated via // the TargetPath property and explicitly set on the context. if (StringComparers.PropertyNames.Equals(name, LanguageService.TargetPathProperty)) { if (!string.IsNullOrEmpty(value)) { logger.WriteLine("BinOutputPath: {0}", value); Context.BinOutputPath = value; } return(true); } return(false); }
public void Handle(IComparable version, IProjectChangeDescription projectChange, ContextState state, IProjectDiagnosticOutputService logger) { Requires.NotNull(version, nameof(version)); Requires.NotNull(projectChange, nameof(projectChange)); Requires.NotNull(logger, nameof(logger)); VerifyInitialized(); if (projectChange.Difference.ChangedProperties.Contains(ConfigurationGeneral.MSBuildProjectFullPathProperty)) { string projectFilePath = projectChange.After.Properties[ConfigurationGeneral.MSBuildProjectFullPathProperty]; string displayName = GetDisplayName(projectFilePath); logger.WriteLine("DisplayName: {0}", displayName); logger.WriteLine("ProjectFilePath: {0}", projectFilePath); Context.ProjectFilePath = projectFilePath; Context.DisplayName = displayName; } }
protected override void UpdateInContext(string fullPath, IImmutableDictionary <string, string> previousMetadata, IImmutableDictionary <string, string> currentMetadata, bool isActiveContext, IProjectDiagnosticOutputService logger) { if (LinkMetadataChanged(previousMetadata, currentMetadata)) { logger.WriteLine("Removing and then re-adding source file '{0}' to <Link> metadata changes", fullPath); RemoveFromContext(fullPath, logger); AddToContext(fullPath, currentMetadata, isActiveContext, logger); } }
public void Handle(IComparable version, BuildOptions added, BuildOptions removed, ContextState state, IProjectDiagnosticOutputService logger) { Requires.NotNull(version, nameof(version)); Requires.NotNull(added, nameof(added)); Requires.NotNull(removed, nameof(removed)); Requires.NotNull(logger, nameof(logger)); VerifyInitialized(); foreach (Lazy <Action <string, BuildOptions, BuildOptions>, IOrderPrecedenceMetadataView> value in CommandLineNotifications) { value.Value(Context.BinOutputPath, added, removed); } }
protected override void RemoveFromContext(string fullPath, IProjectDiagnosticOutputService logger) { Files.Remove(fullPath); }
public void Handle(IComparable version, IProjectChangeDescription projectChange, ContextState state, IProjectDiagnosticOutputService logger) { Requires.NotNull(version, nameof(version)); Requires.NotNull(projectChange, nameof(projectChange)); Requires.NotNull(logger, nameof(logger)); VerifyInitialized(); ApplyProjectEvaluation(version, projectChange.Difference, projectChange.Before.Items, projectChange.After.Items, state.IsActiveEditorContext, logger); }
public void Handle(IComparable version, IProjectChangeDescription projectChange, ContextState state, IProjectDiagnosticOutputService logger) { Requires.NotNull(version, nameof(version)); Requires.NotNull(projectChange, nameof(projectChange)); Requires.NotNull(logger, nameof(logger)); VerifyInitialized(); foreach (string name in projectChange.Difference.ChangedProperties) { string value = projectChange.After.Properties[name]; // Is it a property we're specifically aware of? if (TryHandleSpecificProperties(name, value, logger)) { continue; } // Otherwise, just pass it through logger.WriteLine("{0}: {1}", name, value); Context.SetProperty(name, value); } // NOTE: Roslyn treats "unset" as true, so always set it. Context.IsPrimary = state.IsActiveConfiguration; }
protected override void AddToContext(string fullPath, IImmutableDictionary <string, string> metadata, bool isActiveContext, IProjectDiagnosticOutputService logger) { Files.Add(fullPath, metadata); }
public void Handle(IComparable version, BuildOptions added, BuildOptions removed, ContextState state, IProjectDiagnosticOutputService logger) { Requires.NotNull(version, nameof(version)); Requires.NotNull(added, nameof(added)); Requires.NotNull(removed, nameof(removed)); Requires.NotNull(logger, nameof(logger)); VerifyInitialized(); IProjectChangeDiff difference = ConvertToProjectDiff(added, removed); ApplyProjectBuild(version, difference, state.IsActiveEditorContext, logger); }
protected override void UpdateInContext(string fullPath, IImmutableDictionary <string, string> previousMetadata, IImmutableDictionary <string, string> currentMetadata, bool isActiveContext, IProjectDiagnosticOutputService logger) { RemoveFromContext(fullPath, logger); AddToContext(fullPath, currentMetadata, isActiveContext, logger); }
protected override void AddToContext(string fullPath, IImmutableDictionary <string, string> metadata, bool isActiveContext, IProjectDiagnosticOutputService logger) { string[]? folderNames = FileItemServices.GetLogicalFolderNames(Path.GetDirectoryName(_project.FullPath), fullPath, metadata); logger.WriteLine("Adding source file '{0}'", fullPath); Context.AddSourceFile(fullPath, isInCurrentContext: isActiveContext, folderNames: folderNames); }
public BatchLogger(IProjectDiagnosticOutputService outputService) { Requires.NotNull(outputService, nameof(outputService)); _outputService = outputService; }
protected override void RemoveFromContext(string fullPath, IProjectDiagnosticOutputService logger) { logger.WriteLine("Removing source file '{0}'", fullPath); Context.RemoveSourceFile(fullPath); }