public CSharpProjectShim( ICSharpProjectRoot projectRoot, VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, LanguageNames.CSharp, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { _projectRoot = projectRoot; _warningNumberArrayPointer = Marshal.AllocHGlobal(0); // Ensure the default options are set up ResetAllOptions(); UpdateOptions(); projectTracker.AddProject(this); }
public CPSProject( VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectDisplayName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, string commandLineForOptions, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { // Initialize the options. SetCommandLineArguments(commandLineForOptions); // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker. // If we were unable to set the output path from SetCommandLineArguments (due to null output file name or directory in the given commandLineForOptions), // we set a default unique output path. if (this.TryGetBinOutputPath() == null) { var uniqueDefaultOutputPath = PathUtilities.CombinePathsUnchecked(Path.GetTempPath(), projectDisplayName + projectGuid.GetHashCode().ToString()); SetOutputPathAndRelatedData(objOutputPath: uniqueDefaultOutputPath, hasSameBinAndObjOutputPaths: true); } Contract.ThrowIfNull(this.TryGetBinOutputPath()); // Now hook up the project to the project tracker. projectTracker.AddProject(this); _lastDesignTimeBuildSucceeded = true; }
public CPSProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectDisplayName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, string commandLineForOptions, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { // Initialize the options. SetCommandLineArguments(commandLineForOptions); // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker. // If we were unable to set the output path from SetCommandLineArguments (due to null output file name or directory in the given commandLineForOptions), // we set a default unique output path. if (this.TryGetBinOutputPath() == null) { var uniqueDefaultOutputPath = PathUtilities.CombinePathsUnchecked(Path.GetTempPath(), projectDisplayName + projectGuid.GetHashCode().ToString()); SetOutputPathAndRelatedData(objOutputPath: uniqueDefaultOutputPath, hasSameBinAndObjOutputPaths: true); } Contract.ThrowIfNull(this.TryGetBinOutputPath()); // Now hook up the project to the project tracker. projectTracker.AddProject(this); _lastDesignTimeBuildSucceeded = true; }
// internal for testing purposes only. internal static CPSProject CreateCPSProject(VisualStudioProjectTracker projectTracker, IServiceProvider serviceProvider, IVsHierarchy hierarchy, string projectDisplayName, string projectFilePath, Guid projectGuid, string language, ICommandLineParserService commandLineParserService, string binOutputPath) { return new CPSProject(projectTracker, reportExternalErrorCreatorOpt: null, hierarchy: hierarchy, language: language, serviceProvider: serviceProvider, visualStudioWorkspaceOpt: null, hostDiagnosticUpdateSourceOpt: null, projectDisplayName: projectDisplayName, projectFilePath: projectFilePath, projectGuid: projectGuid, binOutputPath: binOutputPath, commandLineParserServiceOpt: commandLineParserService); }
public AbstractLegacyProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt = null) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, projectFilePath: GetProjectFilePath(hierarchy), hierarchy: hierarchy, projectGuid: GetProjectIDGuid(hierarchy), language: language, serviceProvider: serviceProvider, visualStudioWorkspaceOpt: visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt: hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt: commandLineParserServiceOpt) { if (Hierarchy != null) { ConnectHierarchyEvents(); this.IsWebSite = GetIsWebsiteProject(Hierarchy); } // Initialize command line arguments. base.SetArguments(commandLine: string.Empty); }
public CommandLineItemHandler(UnconfiguredProject project, ICommandLineParserService commandLineParser) { Requires.NotNull(commandLineParser, nameof(commandLineParser)); _commandLineParser = commandLineParser; Handlers = new OrderPrecedenceImportCollection <ILanguageServiceCommandLineHandler>(projectCapabilityCheckProvider: project); }
public AbstractLegacyProject( VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt = null) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, projectFilePath: GetProjectFilePath(hierarchy), hierarchy: hierarchy, projectGuid: GetProjectIDGuid(hierarchy), language: language, serviceProvider: serviceProvider, visualStudioWorkspaceOpt: visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt: hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt: commandLineParserServiceOpt) { if (Hierarchy != null) { ConnectHierarchyEvents(); this.IsWebSite = GetIsWebsiteProject(Hierarchy); } // Initialize command line arguments. base.SetArguments(commandLine: string.Empty); }
public CSharpProjectShim( ICSharpProjectRoot projectRoot, VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, LanguageNames.CSharp, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { _projectRoot = projectRoot; _warningNumberArrayPointer = Marshal.AllocHGlobal(0); // Ensure the default options are set up ResetAllOptions(); UpdateOptions(); projectTracker.AddProject(this); }
public LanguageServiceHandlerManager(UnconfiguredProject project, ICommandLineParserService commandLineParser, IContextHandlerProvider handlerProvider, IProjectLogger logger) { _project = project; _commandLineParser = commandLineParser; _handlerProvider = handlerProvider; _logger = logger; CommandLineNotifications = new OrderPrecedenceImportCollection <Action <string, BuildOptions, BuildOptions> >(projectCapabilityCheckProvider: project); }
public AbstractLegacyProject( string projectSystemName, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, IThreadingContext threadingContext, string externalErrorReportingPrefix, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(threadingContext) { Contract.ThrowIfNull(hierarchy); var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); Workspace = componentModel.GetService <VisualStudioWorkspace>(); var projectFilePath = hierarchy.GetProjectFilePath(); if (projectFilePath != null && !File.Exists(projectFilePath)) { projectFilePath = null; } var projectFactory = componentModel.GetService <VisualStudioProjectFactory>(); VisualStudioProject = projectFactory.CreateAndAddToWorkspace( projectSystemName, language, new VisualStudioProjectCreationInfo { // The workspace requires an assembly name so we can make compilations. We'll use // projectSystemName because they'll have a better one eventually. AssemblyName = projectSystemName, FilePath = projectFilePath, Hierarchy = hierarchy, ProjectGuid = GetProjectIDGuid(hierarchy), DefaultNamespace = GetDefaultNamespace(hierarchy, language) }); Hierarchy = hierarchy; ConnectHierarchyEvents(); RefreshBinOutputPath(); // TODO: remove this terrible hack, which is working around shims throwing in not-good ways try { _externalErrorReporter = new ProjectExternalErrorReporter(VisualStudioProject.Id, externalErrorReportingPrefix, serviceProvider); _editAndContinueProject = new VsENCRebuildableProjectImpl(Workspace, VisualStudioProject, serviceProvider); } catch (Exception) { } _batchScopeCreator = componentModel.GetService <SolutionEventsBatchScopeCreator>(); _batchScopeCreator.StartTrackingProject(VisualStudioProject, Hierarchy); }
public VisualStudioProjectOptionsProcessor(VisualStudioProject project, HostWorkspaceServices workspaceServices) { _project = project ?? throw new ArgumentNullException(nameof(project)); _workspaceServices = workspaceServices; _commandLineParserService = workspaceServices.GetLanguageServices(project.Language).GetRequiredService <ICommandLineParserService>(); // Set up _commandLineArgumentsForCommandLine to a default. No lock taken since we're in the constructor so nothing can race. ReparseCommandLine_NoLock(); }
public LanguageServiceHandlerManager(UnconfiguredProject project, ICommandLineParserService commandLineParser, IContextHandlerProvider handlerProvider) { Requires.NotNull(project, nameof(project)); Requires.NotNull(commandLineParser, nameof(commandLineParser)); Requires.NotNull(handlerProvider, nameof(handlerProvider)); _commandLineParser = commandLineParser; _handlerProvider = handlerProvider; }
public AbstractProject( VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, #pragma warning disable IDE0060 // Remove unused parameter - not used, but left for compat with TypeScript IServiceProvider serviceProviderNotUsed, #pragma warning restore IDE0060 // Remove unused parameter VisualStudioWorkspaceImpl workspace, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, #pragma warning disable IDE0060 // Remove unused parameter - not used, but left for compat ICommandLineParserService commandLineParserServiceOpt = null ) #pragma warning restore IDE0060 // Remove unused parameter : base(projectTracker.ThreadingContext) { Hierarchy = hierarchy; Guid = projectGuid; Language = language; ProjectTracker = projectTracker; _visualStudioWorkspace = workspace; this.DisplayName = hierarchy != null && hierarchy.TryGetName(out var name) ? name : projectSystemName; ProjectSystemName = projectSystemName; HostDiagnosticUpdateSource = hostDiagnosticUpdateSourceOpt; // Set the default value for last design time build result to be true, until the project system lets us know that it failed. LastDesignTimeBuildSucceeded = true; if (projectFilePath != null && File.Exists(projectFilePath)) { ProjectFilePath = projectFilePath; } if (ProjectFilePath != null) { Version = VersionStamp.Create(File.GetLastWriteTimeUtc(ProjectFilePath)); } else { Version = VersionStamp.Create(); } if (reportExternalErrorCreatorOpt != null) { ExternalErrorReporter = reportExternalErrorCreatorOpt(Id); } }
private void ProcessCommandLine(IComparable version, IProjectChangeDiff differences, bool isActiveContext, CancellationToken cancellationToken) { ICommandLineParserService parser = CommandLineParsers.FirstOrDefault()?.Value; Assumes.Present(parser); string baseDirectory = Path.GetDirectoryName(_project.UnconfiguredProject.FullPath); BuildOptions added = parser.Parse(differences.AddedItems, baseDirectory); BuildOptions removed = parser.Parse(differences.RemovedItems, baseDirectory); ProcessCommandLineHandlers(version, added, removed, isActiveContext, cancellationToken); }
public CSharpLspProject(VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt = null) : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, projectFilePath, hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { }
public VisualStudioProjectOptionsProcessor( VisualStudioProject project, HostWorkspaceServices workspaceServices) { _project = project ?? throw new ArgumentNullException(nameof(project)); _workspaceServices = workspaceServices; _commandLineParserService = workspaceServices.GetLanguageServices(project.Language).GetRequiredService <ICommandLineParserService>(); _temporaryStorageService = workspaceServices.GetRequiredService <ITemporaryStorageService>(); // Set up _commandLineArgumentsForCommandLine to a default. No lock taken since we're in // the constructor so nothing can race. // Silence NRT warning. This will be initialized by the call below to ReparseCommandLineIfChanged_NoLock. _commandLineArgumentsForCommandLine = null !; ReparseCommandLineIfChanged_NoLock(commandLine: ""); }
public VisualStudioProjectOptionsProcessor(VisualStudioProject project, HostWorkspaceServices workspaceServices) { _project = project ?? throw new ArgumentNullException(nameof(project)); _workspaceServices = workspaceServices; _commandLineParserService = workspaceServices.GetLanguageServices(project.Language).GetRequiredService <ICommandLineParserService>(); // Set up _commandLineArgumentsForCommandLine to a default. No lock taken since we're in the constructor so nothing can race. ReparseCommandLine_NoLock(); _optionService = workspaceServices.GetRequiredService <IOptionService>(); // For C#, we need to listen to the options for NRT analysis // that can change in VS through tools > options if (_project.Language == LanguageNames.CSharp) { _optionService.OptionChanged += OptionService_OptionChanged; } }
public CPSProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectDisplayName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, string binOutputPath, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker. NormalizeAndSetBinOutputPathAndRelatedData(binOutputPath); // Now hook up the project to the project tracker. projectTracker.AddProject(this); }
public CPSProject( VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectDisplayName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, string binOutputPath, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker. SetBinOutputPathAndRelatedData(binOutputPath); // Now hook up the project to the project tracker. projectTracker.AddProject(this); }
public CSharpProjectShimWithServices( ICSharpProjectRoot projectRoot, VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base( projectRoot, projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { }
public CSharpProjectShimWithServices( ICSharpProjectRoot projectRoot, VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, IVsHierarchy hierarchy, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base( projectRoot, projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { }
public CPSProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectDisplayName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, string binOutputPath, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { if (binOutputPath != null) { // Ensure that binOutputPath is either null or a rooted path. // CPS might provide such invalid paths during initialization or when project is in unrestored state. if (binOutputPath == String.Empty) { binOutputPath = null; } else if (!PathUtilities.IsAbsolute(binOutputPath)) { // Make it a rooted path. var basePath = PathUtilities.IsAbsolute(projectFilePath) ? PathUtilities.GetDirectoryName(projectFilePath) : Path.GetTempPath(); binOutputPath = PathUtilities.CombineAbsoluteAndRelativePaths(basePath, binOutputPath); } } // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker. SetBinOutputPathAndRelatedData(binOutputPath); // Now hook up the project to the project tracker. projectTracker.AddProject(this); }
public CPSProject( VisualStudioProjectTracker projectTracker, Func <ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectDisplayName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, string binOutputPath, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, hierarchy, language, projectGuid, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt, commandLineParserServiceOpt) { if (binOutputPath != null) { // Ensure that binOutputPath is either null or a rooted path. // CPS might provide such invalid paths during initialization or when project is in unrestored state. if (binOutputPath == String.Empty) { binOutputPath = null; } else if (!PathUtilities.IsAbsolute(binOutputPath)) { // Make it a rooted path. var basePath = PathUtilities.IsAbsolute(projectFilePath) ? PathUtilities.GetDirectoryName(projectFilePath) : Path.GetTempPath(); binOutputPath = PathUtilities.CombineAbsoluteAndRelativePaths(basePath, binOutputPath); } } // We need to ensure that the bin output path for the project has been initialized before we hookup the project with the project tracker. SetBinOutputPathAndRelatedData(binOutputPath); // Now hook up the project to the project tracker. projectTracker.AddProject(this); }
public AbstractLegacyProject( string projectSystemName, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, IThreadingContext threadingContext, string externalErrorReportingPrefix, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(threadingContext) { Contract.ThrowIfNull(hierarchy); var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); Workspace = componentModel.GetService <VisualStudioWorkspace>(); var projectFilePath = hierarchy.TryGetProjectFilePath(); if (projectFilePath != null && !File.Exists(projectFilePath)) { projectFilePath = null; } var projectFactory = componentModel.GetService <VisualStudioProjectFactory>(); VisualStudioProject = projectFactory.CreateAndAddToWorkspace( projectSystemName, language, new VisualStudioProjectCreationInfo { // The workspace requires an assembly name so we can make compilations. We'll use // projectSystemName because they'll have a better one eventually. AssemblyName = projectSystemName, FilePath = projectFilePath, Hierarchy = hierarchy, ProjectGuid = GetProjectIDGuid(hierarchy), }); // Right now VB doesn't have the concept of "default namespace". But we conjure one in workspace // by assigning the value of the project's root namespace to it. So various feature can choose to // use it for their own purpose. // In the future, we might consider officially exposing "default namespace" for VB project // (e.g. through a <defaultnamespace> msbuild property) VisualStudioProject.DefaultNamespace = GetRootNamespacePropertyValue(hierarchy); Hierarchy = hierarchy; ConnectHierarchyEvents(); RefreshBinOutputPath(); // TODO: remove this terrible hack, which is working around shims throwing in not-good ways try { _externalErrorReporter = new ProjectExternalErrorReporter(VisualStudioProject.Id, externalErrorReportingPrefix, serviceProvider); _editAndContinueProject = new VsENCRebuildableProjectImpl(Workspace, VisualStudioProject, serviceProvider); } catch (Exception) { } _batchScopeCreator = componentModel.GetService <SolutionEventsBatchScopeCreator>(); _batchScopeCreator.StartTrackingProject(VisualStudioProject, Hierarchy); }
// internal for testing purposes only. internal static CPSProject CreateCPSProject(VisualStudioProjectTracker projectTracker, IServiceProvider serviceProvider, IVsHierarchy hierarchy, string projectDisplayName, string projectFilePath, Guid projectGuid, string language, ICommandLineParserService commandLineParserService, string binOutputPath) { return(new CPSProject(projectTracker, reportExternalErrorCreatorOpt: null, hierarchy: hierarchy, language: language, serviceProvider: serviceProvider, visualStudioWorkspaceOpt: null, hostDiagnosticUpdateSourceOpt: null, projectDisplayName: projectDisplayName, projectFilePath: projectFilePath, projectGuid: projectGuid, binOutputPath: binOutputPath, commandLineParserServiceOpt: commandLineParserService)); }
public AbstractProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt = null) { Contract.ThrowIfNull(projectSystemName); ServiceProvider = serviceProvider; Language = language; Hierarchy = hierarchy; Guid = projectGuid; var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); ContentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>(); this.RunningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); this.DisplayName = projectSystemName; this.ProjectTracker = projectTracker; ProjectSystemName = projectSystemName; Workspace = visualStudioWorkspaceOpt; CommandLineParserService = commandLineParserServiceOpt; HostDiagnosticUpdateSource = hostDiagnosticUpdateSourceOpt; UpdateProjectDisplayNameAndFilePath(projectSystemName, projectFilePath); if (_filePathOpt != null) { Version = VersionStamp.Create(File.GetLastWriteTimeUtc(_filePathOpt)); } else { Version = VersionStamp.Create(); } Id = this.ProjectTracker.GetOrCreateProjectIdForPath(_filePathOpt ?? ProjectSystemName, ProjectSystemName); if (reportExternalErrorCreatorOpt != null) { ExternalErrorReporter = reportExternalErrorCreatorOpt(Id); } if (visualStudioWorkspaceOpt != null) { this.EditAndContinueImplOpt = new VsENCRebuildableProjectImpl(this); } }
public AbstractLegacyProject( string projectSystemName, IVsHierarchy hierarchy, string language, IServiceProvider serviceProvider, IThreadingContext threadingContext, string externalErrorReportingPrefix, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt) : base(threadingContext, assertIsForeground: true) { Contract.ThrowIfNull(hierarchy); var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); Workspace = componentModel.GetService <VisualStudioWorkspace>(); var workspaceImpl = (VisualStudioWorkspaceImpl)Workspace; var projectFilePath = hierarchy.TryGetProjectFilePath(); if (projectFilePath != null && !File.Exists(projectFilePath)) { projectFilePath = null; } if (projectFilePath != null) { _projectDirectory = Path.GetDirectoryName(projectFilePath); } var projectFactory = componentModel.GetService <VisualStudioProjectFactory>(); VisualStudioProject = projectFactory.CreateAndAddToWorkspace( projectSystemName, language, new VisualStudioProjectCreationInfo { // The workspace requires an assembly name so we can make compilations. We'll use // projectSystemName because they'll have a better one eventually. AssemblyName = projectSystemName, FilePath = projectFilePath, Hierarchy = hierarchy, ProjectGuid = GetProjectIDGuid(hierarchy), }); workspaceImpl.AddProjectRuleSetFileToInternalMaps( VisualStudioProject, () => VisualStudioProjectOptionsProcessor.EffectiveRuleSetFilePath); // Right now VB doesn't have the concept of "default namespace". But we conjure one in workspace // by assigning the value of the project's root namespace to it. So various feature can choose to // use it for their own purpose. // In the future, we might consider officially exposing "default namespace" for VB project // (e.g. through a <defaultnamespace> msbuild property) VisualStudioProject.DefaultNamespace = GetRootNamespacePropertyValue(hierarchy); Hierarchy = hierarchy; ConnectHierarchyEvents(); RefreshBinOutputPath(); workspaceImpl.SubscribeExternalErrorDiagnosticUpdateSourceToSolutionBuildEvents(); _externalErrorReporter = new ProjectExternalErrorReporter(VisualStudioProject.Id, externalErrorReportingPrefix, workspaceImpl); _batchScopeCreator = componentModel.GetService <SolutionEventsBatchScopeCreator>(); _batchScopeCreator.StartTrackingProject(VisualStudioProject, Hierarchy); }
private static ApplyChangesToWorkspaceContext CreateInstance(ConfiguredProject project = null, ICommandLineParserService commandLineParser = null, IProjectLogger logger = null, params IWorkspaceContextHandler[] handlers) { if (project == null) { var unconfiguredProject = UnconfiguredProjectFactory.ImplementFullPath(@"C:\Project\Project.csproj"); project = ConfiguredProjectFactory.ImplementUnconfiguredProject(unconfiguredProject); } commandLineParser = commandLineParser ?? ICommandLineParserServiceFactory.Create(); logger = logger ?? IProjectLoggerFactory.Create(); var factories = handlers.Select(h => ExportFactoryFactory.ImplementCreateValueWithAutoDispose(() => h)) .ToArray(); var applyChangesToWorkspaceContext = new ApplyChangesToWorkspaceContext(project, logger, factories); applyChangesToWorkspaceContext.CommandLineParsers.Add(commandLineParser); return(applyChangesToWorkspaceContext); }
private static ApplyChangesToWorkspaceContext CreateInitializedInstance(out IWorkspaceProjectContext context, ConfiguredProject project = null, ICommandLineParserService commandLineParser = null, IProjectLogger logger = null, params IWorkspaceContextHandler[] handlers) { var applyChangesToWorkspace = CreateInstance(project, commandLineParser, logger, handlers); context = IWorkspaceProjectContextFactory.Create(); applyChangesToWorkspace.Initialize(context); return(applyChangesToWorkspace); }
private static ApplyChangesToWorkspaceContext CreateInitializedInstance(ConfiguredProject project = null, ICommandLineParserService commandLineParser = null, IProjectLogger logger = null, params IWorkspaceContextHandler[] handlers) { return(CreateInitializedInstance(out _, project, commandLineParser, logger, handlers)); }
public AbstractProject( VisualStudioProjectTracker projectTracker, Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt, string projectSystemName, string projectFilePath, IVsHierarchy hierarchy, string language, Guid projectGuid, IServiceProvider serviceProvider, VisualStudioWorkspaceImpl visualStudioWorkspaceOpt, HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt, ICommandLineParserService commandLineParserServiceOpt = null) { Contract.ThrowIfNull(projectSystemName); ServiceProvider = serviceProvider; Language = language; Hierarchy = hierarchy; Guid = projectGuid; var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel)); ContentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>(); this.RunningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); this.DisplayName = projectSystemName; this.ProjectTracker = projectTracker; ProjectSystemName = projectSystemName; Workspace = visualStudioWorkspaceOpt; CommandLineParserService = commandLineParserServiceOpt; HostDiagnosticUpdateSource = hostDiagnosticUpdateSourceOpt; // Set the default value for last design time build result to be true, until the project system lets us know that it failed. LastDesignTimeBuildSucceeded = true; UpdateProjectDisplayNameAndFilePath(projectSystemName, projectFilePath); if (ProjectFilePath != null) { Version = VersionStamp.Create(File.GetLastWriteTimeUtc(ProjectFilePath)); } else { Version = VersionStamp.Create(); } Id = this.ProjectTracker.GetOrCreateProjectIdForPath(ProjectFilePath ?? ProjectSystemName, ProjectSystemName); if (reportExternalErrorCreatorOpt != null) { ExternalErrorReporter = reportExternalErrorCreatorOpt(Id); } if (visualStudioWorkspaceOpt != null) { if (Language == LanguageNames.CSharp || Language == LanguageNames.VisualBasic) { this.EditAndContinueImplOpt = new VsENCRebuildableProjectImpl(this); } this.MetadataService = visualStudioWorkspaceOpt.Services.GetService<IMetadataService>(); } UpdateAssemblyName(); }
public GpxToKmlConverter(ICommandLineParserService commandLineParserService, IGpxReader gpxReader, IKmlWriter kmlWriter) { CommandLineParserService = commandLineParserService; GpxReader = gpxReader; KmlWriter = kmlWriter; }