Пример #1
0
        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);
        }
Пример #2
0
        public CSharpProjectShim(
            ICSharpProjectRoot projectRoot,
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectSystemName,
            IVsHierarchy hierarchy,
            IServiceProvider serviceProvider,
            MiscellaneousFilesWorkspace miscellaneousFilesWorkspaceOpt,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
            : base(projectTracker,
                   reportExternalErrorCreatorOpt,
                   projectSystemName,
                   hierarchy,
                   LanguageNames.CSharp,
                   serviceProvider,
                   miscellaneousFilesWorkspaceOpt,
                   visualStudioWorkspaceOpt,
                   hostDiagnosticUpdateSourceOpt)
        {
            _projectRoot = projectRoot;
            _warningNumberArrayPointer = Marshal.AllocHGlobal(0);

            InitializeOptions();

            projectTracker.AddProject(this);
        }
Пример #3
0
        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 AnalyzerDependencyCheckingService(
     VisualStudioWorkspaceImpl workspace,
     HostDiagnosticUpdateSource updateSource)
 {
     _workspace = workspace;
     _updateSource = updateSource;
 }
Пример #5
0
        public AbstractLegacyProject(
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectSystemName,
            IVsHierarchy hierarchy,
            string language,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
            : base(projectTracker,
                  reportExternalErrorCreatorOpt,
                  projectSystemName,
                  projectFilePath: GetProjectFilePath(hierarchy),
                  projectGuid: GetProjectIDGuid(hierarchy),
                  projectTypeGuid: GetProjectType(hierarchy),
                  hierarchy: hierarchy,
                  language: language,
                  serviceProvider: serviceProvider,
                  visualStudioWorkspaceOpt: visualStudioWorkspaceOpt,
                  hostDiagnosticUpdateSourceOpt: hostDiagnosticUpdateSourceOpt)
        {
            ConnectHierarchyEvents();

            this.IsWebSite = GetIsWebsiteProject(hierarchy);

            _lastParsedCompilerOptions = string.Empty;
            var commandLineArguments = ParseCommandLineArguments(SpecializedCollections.EmptyEnumerable<string>());
            base.SetArguments(commandLineArguments);
        }
Пример #6
0
        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 AnalyzerDependencyCheckingService(
     VisualStudioWorkspaceImpl workspace,
     HostDiagnosticUpdateSource updateSource)
 {
     _workspace = workspace;
     _updateSource = updateSource;
     _bindingRedirectionService = new BindingRedirectionService();
 }
Пример #8
0
 public AnalyzerFileWatcherService(
     VisualStudioWorkspaceImpl workspace,
     HostDiagnosticUpdateSource hostDiagnosticUpdateSource,
     SVsServiceProvider serviceProvider)
 {
     _workspace = workspace;
     _updateSource = hostDiagnosticUpdateSource;
     _fileChangeService = (IVsFileChangeEx)serviceProvider.GetService(typeof(SVsFileChangeEx));
 }
Пример #9
0
 public CPSProjectFactory(
     SVsServiceProvider serviceProvider,
     VisualStudioWorkspaceImpl visualStudioWorkspace,
     HostDiagnosticUpdateSource hostDiagnosticUpdateSource)
 {
     _serviceProvider = serviceProvider;
     _visualStudioWorkspace = visualStudioWorkspace;
     _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
 }
Пример #10
0
 public CPSProjectFactory(
     SVsServiceProvider serviceProvider,
     VisualStudioWorkspaceImpl visualStudioWorkspace,
     HostDiagnosticUpdateSource hostDiagnosticUpdateSource)
 {
     _serviceProvider = serviceProvider;
     _visualStudioWorkspace = visualStudioWorkspace;
     _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
     _externalErrorReporterMap = new Dictionary<string, IVsReportExternalErrors>(StringComparer.OrdinalIgnoreCase);
 }
        public AnalyzerFileWatcherService(
            VisualStudioWorkspaceImpl workspace,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSource,
            SVsServiceProvider serviceProvider)
        {
            _workspace = workspace;
            _updateSource = hostDiagnosticUpdateSource;
            _fileChangeService = (IVsFileChangeEx)serviceProvider.GetService(typeof(SVsFileChangeEx));

            InMemoryAssemblyProvider.AssemblyLoad += AnalyzerFileReference_AssemblyLoad;
        }
Пример #12
0
 public VisualStudioAnalyzer(string fullPath, IVsFileChangeEx fileChangeService, HostDiagnosticUpdateSource hostDiagnosticUpdateSource, ProjectId projectId, Workspace workspace, string language)
 {
     _fullPath = fullPath;
     _tracker = new FileChangeTracker(fileChangeService, fullPath);
     _tracker.UpdatedOnDisk += OnUpdatedOnDisk;
     _tracker.StartFileChangeListeningAsync();
     _tracker.EnsureSubscription();
     _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
     _projectId = projectId;
     _workspace = workspace;
     _language = language;
 }
Пример #13
0
 public AbstractRoslynProject(
     VisualStudioProjectTracker projectTracker,
     Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
     string projectSystemName,
     IVsHierarchy hierarchy,
     string language,
     IServiceProvider serviceProvider,
     VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
     HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
     : base(projectTracker, reportExternalErrorCreatorOpt, projectSystemName, hierarchy, language, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt)
 {
     if (visualStudioWorkspaceOpt != null)
     {
         this.EditAndContinueImplOpt = new VsENCRebuildableProjectImpl(this);
     }
 }
Пример #14
0
 public CSharpProjectShimWithServices(
     ICSharpProjectRoot projectRoot,
     VisualStudioProjectTracker projectTracker,
     Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
     string projectSystemName,
     IVsHierarchy hierarchy,
     IServiceProvider serviceProvider,
     VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
     HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
     : base(
           projectRoot,
           projectTracker,
           reportExternalErrorCreatorOpt,
           projectSystemName,
           hierarchy,
           serviceProvider,
           visualStudioWorkspaceOpt,
           hostDiagnosticUpdateSourceOpt)
 {
 }
Пример #15
0
        public CPSProject(
            CommandLineArguments commandLineArguments,
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectDisplayName,
            string projectFilePath,
            Guid projectGuid,
            string projectTypeGuid,
            IVsHierarchy hierarchy,
            string language,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
            : base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, projectGuid,
                   projectTypeGuid, hierarchy, language, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt)
        {
            // Set the initial options from the command line before we add the project to the project tracker.
            SetCommandLineArguments(commandLineArguments);

            projectTracker.AddProject(this);
        }
Пример #16
0
        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);
        }
Пример #17
0
        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);
        }
Пример #18
0
        protected CSharpProject(
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectSystemName,
            IVsHierarchy hierarchy,
            IServiceProvider serviceProvider,
            MiscellaneousFilesWorkspace miscellaneousFilesWorkspaceOpt,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
            : base(projectTracker,
                   reportExternalErrorCreatorOpt,
                   projectSystemName,
                   hierarchy,
                   LanguageNames.CSharp,
                   serviceProvider,
                   miscellaneousFilesWorkspaceOpt,
                   visualStudioWorkspaceOpt,
                   hostDiagnosticUpdateSourceOpt)
        {
            InitializeOptions();

            projectTracker.AddProject(this);
        }
Пример #19
0
        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();
        }
Пример #20
0
        public AbstractProject(
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectSystemName,
            string projectFilePath,
            Guid projectGuid,
            string projectTypeGuid,
            IVsHierarchy hierarchy,
            string language,
            IServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
        {
            Contract.ThrowIfNull(projectSystemName);

            ServiceProvider = serviceProvider;
            Language = language;
            Hierarchy = hierarchy;
            Guid = projectGuid;
            ProjectType = projectTypeGuid;

            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;
            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);
            }
        }
Пример #21
0
        public AbstractProject(
            VisualStudioProjectTracker projectTracker,
            Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
            string projectSystemName,
            IVsHierarchy hierarchy,
            string language,
            IServiceProvider serviceProvider,
            MiscellaneousFilesWorkspace miscellaneousFilesWorkspaceOpt,
            VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
            HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
        {
            Contract.ThrowIfNull(projectSystemName);

            _language = language;
            this.ServiceProvider = serviceProvider;
            _hierarchy = hierarchy;

            var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));

            _contentTypeRegistryService = componentModel.GetService<IContentTypeRegistryService>();
            this.RunningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable));

            this.DisplayName = _projectSystemName;
            _projectSystemName = projectSystemName;
            this.ProjectTracker = projectTracker;
            _miscellaneousFilesWorkspaceOpt = miscellaneousFilesWorkspaceOpt;
            _visualStudioWorkspaceOpt = visualStudioWorkspaceOpt;
            _hostDiagnosticUpdateSourceOpt = hostDiagnosticUpdateSourceOpt;

            UpdateProjectDisplayNameAndFilePath();

            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);
            }

            ConnectHierarchyEvents();

            SetIsWebstite(hierarchy);
        }