Ejemplo n.º 1
0
        /// <summary>
        ///     Attaches error handling to a block so that if it throws an unhandled exception,
        ///     the error will be reported to the user.
        /// </summary>
        /// <param name="faultHandlerService">
        ///     The <see cref="IProjectFaultHostHandler"/> that should handle the fault.
        /// </param>
        /// <param name="block">
        ///     The block to attach error handling to.
        /// </param>
        /// <param name="project">
        ///     The project related to the failure, if applicable. Can be <see langword="null"/>.
        /// </param>
        /// <param name="severity">
        ///     The severity of the failure.
        /// </param>
        public static Task RegisterFaultHandler(
            this IProjectFaultHandlerService faultHandlerService,
            IDataflowBlock block,
            UnconfiguredProject?project,
            ProjectFaultSeverity severity = ProjectFaultSeverity.Recoverable)
        {
            Requires.NotNull(faultHandlerService, nameof(faultHandlerService));
            Requires.NotNull(block, nameof(block));

            return(block.Completion.ContinueWith(_ =>
            {
                var dataSourceException = new AggregateException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.DataFlowFaults,
                        block.ToString(),
                        block.Completion.Exception),
                    block.Completion.Exception);

                try
                {
                    throw dataSourceException;
                }
                catch (AggregateException ex)
                {
                    dataSourceException = ex;
                }

                return faultHandlerService.ReportFaultAsync(dataSourceException, project, severity);
            },
                                                 CancellationToken.None,
                                                 TaskContinuationOptions.OnlyOnFaulted,
                                                 TaskScheduler.Default));
        }
Ejemplo n.º 2
0
 public WorkspaceProjectContextHostInitiator(UnconfiguredProject project, IUnconfiguredProjectTasksService tasksService, IActiveWorkspaceProjectContextHost activeWorkspaceProjectContextHost, IProjectFaultHandlerService projectFaultHandler)
 {
     _project      = project;
     _tasksService = tasksService;
     _activeWorkspaceProjectContextHost = activeWorkspaceProjectContextHost;
     _projectFaultHandler = projectFaultHandler;
 }
Ejemplo n.º 3
0
        private static void RegisterFaultHandler(IDataflowBlock block, UnconfiguredProject project, ProjectFaultSeverity severity)
        {
            IProjectFaultHandlerService faultHandlerService = project.Services.FaultHandler;

            Task faultTask = faultHandlerService.RegisterFaultHandler(block, project, severity);

            // We don't actually care about the result of reporting the fault if one occurs
            faultHandlerService.Forget(faultTask, project);
        }
 public WorkspaceProjectContextProvider(UnconfiguredProject project,
                                        ISafeProjectGuidService projectGuidService,
                                        IProjectFaultHandlerService faultHandlerService,
                                        Lazy <IWorkspaceProjectContextFactory> workspaceProjectContextFactory)        // From Roslyn, so lazy
 {
     _project                        = project;
     _faultHandlerService            = faultHandlerService;
     _workspaceProjectContextFactory = workspaceProjectContextFactory;
     _projectGuidService             = projectGuidService;
 }
Ejemplo n.º 5
0
        /// <summary>
        ///     Attaches error handling to a task so that if it throws an unhandled exception,
        ///     the error will be reported to the user.
        /// </summary>
        /// <param name="faultHandlerService">
        ///     The <see cref="IProjectFaultHostHandler"/> that should handle the fault.
        /// </param>
        /// <param name="task">
        ///     The task to attach error handling to.
        /// </param>
        /// <param name="project">
        ///     The project related to the failure, if applicable. Can be <see langword="null"/>.
        /// </param>
        /// <param name="severity">
        ///     The severity of the failure.
        /// </param>
        public static void Forget <TResult>(
            this IProjectFaultHandlerService faultHandlerService,
            Task <TResult> task,
            UnconfiguredProject?project,
            ProjectFaultSeverity severity = ProjectFaultSeverity.Recoverable)
        {
            Requires.NotNull(faultHandlerService, nameof(faultHandlerService));

            faultHandlerService.RegisterFaultHandler(task, s_defaultReportSettings, severity, project);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Reports the specified fault.
        /// </summary>
        /// <param name="faultHandlerService">
        ///     The <see cref="IProjectFaultHostHandler"/> that should handle the fault.
        /// </param>
        /// <param name="ex">
        ///     Exception containing the fault information.
        ///  </param>
        /// <param name="severity">
        ///     The severity of the failure.
        /// </param>
        /// <param name="project">
        ///     The project related to the failure, if applicable. Can be <see langword="null"/>.
        /// </param>
        public static Task ReportFaultAsync(
            this IProjectFaultHandlerService faultHandlerService,
            Exception ex,
            UnconfiguredProject?project,
            ProjectFaultSeverity severity = ProjectFaultSeverity.Recoverable)
        {
            Requires.NotNull(faultHandlerService, nameof(faultHandlerService));

            return(faultHandlerService.HandleFaultAsync(ex, s_defaultReportSettings, severity, project));
        }
 public WorkspaceProjectContextHostInitiator(
     UnconfiguredProject project,
     IUnconfiguredProjectTasksService tasksService,
     IActiveWorkspaceProjectContextHost activeWorkspaceProjectContextHost,
     IProjectFaultHandlerService projectFaultHandler,
     IUnconfiguredProjectLanguageServiceTelemetryService languageServiceTelemetryService)
 {
     _project      = project;
     _tasksService = tasksService;
     _activeWorkspaceProjectContextHost = activeWorkspaceProjectContextHost;
     _projectFaultHandler             = projectFaultHandler;
     _languageServiceTelemetryService = languageServiceTelemetryService;
 }
Ejemplo n.º 8
0
 public MissingWorkloadDetector(
     ConfiguredProject project,
     IWorkloadDescriptorDataSource workloadDescriptorDataSource,
     IMissingSetupComponentRegistrationService missingSetupComponentRegistrationService,
     IProjectThreadingService threadingService,
     IProjectFaultHandlerService projectFaultHandlerService,
     IProjectSubscriptionService projectSubscriptionService)
     : base(threadingService.JoinableTaskContext)
 {
     _project = project;
     _workloadDescriptorDataSource             = workloadDescriptorDataSource;
     _missingSetupComponentRegistrationService = missingSetupComponentRegistrationService;
     _projectFaultHandlerService = projectFaultHandlerService;
     _projectSubscriptionService = projectSubscriptionService;
 }
Ejemplo n.º 9
0
 public PackageRestoreProgressTrackerInstance(
     ConfiguredProject project,
     IProjectThreadingService threadingService,
     IProjectFaultHandlerService projectFaultHandlerService,
     IDataProgressTrackerService dataProgressTrackerService,
     IPackageRestoreDataSource dataSource,
     IProjectSubscriptionService projectSubscriptionService)
     : base(threadingService.JoinableTaskContext)
 {
     ConfiguredProject           = project;
     _projectFaultHandlerService = projectFaultHandlerService;
     _dataProgressTrackerService = dataProgressTrackerService;
     _dataSource = dataSource;
     _projectSubscriptionService = projectSubscriptionService;
 }
        private PackageRestoreProgressTrackerInstance CreateInstance(ConfiguredProject?project = null, IDataProgressTrackerService?dataProgressTrackerService = null, IPackageRestoreDataSource?packageRestoreDataSource = null, IProjectSubscriptionService?projectSubscriptionService = null)
        {
            project ??= ConfiguredProjectFactory.Create();
            dataProgressTrackerService ??= IDataProgressTrackerServiceFactory.Create();
            packageRestoreDataSource ??= IPackageRestoreServiceFactory.Create();
            projectSubscriptionService ??= IProjectSubscriptionServiceFactory.Create();

            IProjectThreadingService    threadingService           = IProjectThreadingServiceFactory.Create();
            IProjectFaultHandlerService projectFaultHandlerService = IProjectFaultHandlerServiceFactory.Create();

            return(new PackageRestoreProgressTrackerInstance(
                       project,
                       threadingService,
                       projectFaultHandlerService,
                       dataProgressTrackerService,
                       packageRestoreDataSource,
                       projectSubscriptionService));
        }
Ejemplo n.º 11
0
 public TempPEBuildManager(IProjectThreadingService threadingService,
                           IUnconfiguredProjectCommonServices unconfiguredProjectServices,
                           IActiveWorkspaceProjectContextHost activeWorkspaceProjectContextHost,
                           IActiveConfiguredProjectSubscriptionService projectSubscriptionService,
                           ITempPECompiler compiler,
                           IFileSystem fileSystem,
                           IProjectFaultHandlerService projectFaultHandlerService,
                           VSBuildManager buildManager)
     : base(threadingService.JoinableTaskContext)
 {
     _unconfiguredProjectServices       = unconfiguredProjectServices;
     _activeWorkspaceProjectContextHost = activeWorkspaceProjectContextHost;
     _projectSubscriptionService        = projectSubscriptionService;
     _compiler   = compiler;
     _fileSystem = fileSystem;
     _projectFaultHandlerService = projectFaultHandlerService;
     BuildManager = buildManager;
 }
 public PackageRestoreProgressTracker(
     ConfiguredProject project,
     IProjectThreadingService threadingService,
     IProjectFaultHandlerService projectFaultHandlerService,
     IDataProgressTrackerService dataProgressTrackerService,
     IPackageRestoreDataSource dataSource,
     IProjectSubscriptionService projectSubscriptionService,
     IConfiguredProjectPackageRestoreTelemetryService packageReferenceTelemetryService)
     : base(threadingService.JoinableTaskContext)
 {
     _project                          = project;
     _threadingService                 = threadingService;
     _projectFaultHandlerService       = projectFaultHandlerService;
     _dataProgressTrackerService       = dataProgressTrackerService;
     _dataSource                       = dataSource;
     _projectSubscriptionService       = projectSubscriptionService;
     _packageReferenceTelemetryService = packageReferenceTelemetryService;
 }
Ejemplo n.º 13
0
        public LaunchSettingsProvider(UnconfiguredProject project, IUnconfiguredProjectServices projectServices,
                                      IFileSystem fileSystem, IUnconfiguredProjectCommonServices commonProjectServices,
                                      IActiveConfiguredProjectSubscriptionService projectSubscriptionService,
                                      ActiveConfiguredProject <AppDesignerFolderSpecialFileProvider> appDesignerSpecialFileProvider,
                                      IProjectFaultHandlerService projectFaultHandler)
        {
            _project                   = project;
            ProjectServices            = projectServices;
            FileManager                = fileSystem;
            CommonProjectServices      = commonProjectServices;
            JsonSerializationProviders = new OrderPrecedenceImportCollection <ILaunchSettingsSerializationProvider, IJsonSection>(ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesFirst,
                                                                                                                                  project);
            SourceControlIntegrations = new OrderPrecedenceImportCollection <ISourceCodeControlIntegration>(projectCapabilityCheckProvider: project);

            ProjectSubscriptionService      = projectSubscriptionService;
            _appDesignerSpecialFileProvider = appDesignerSpecialFileProvider;
            _projectFaultHandler            = projectFaultHandler;
            _launchSettingsFilePath         = new AsyncLazy <string>(GetLaunchSettingsFilePathNoCacheAsync, commonProjectServices.ThreadingService.JoinableTaskFactory);
        }
        public static IProjectServices Create(IProjectThreadingService threadingService = null, IProjectFaultHandlerService faultHandlerService = null, IProjectService projectService = null)
        {
            threadingService    = threadingService ?? IProjectThreadingServiceFactory.Create();
            faultHandlerService = faultHandlerService ?? IProjectFaultHandlerServiceFactory.Create();

            var projectServices = new Mock <IProjectServices>();

            projectServices.Setup(u => u.ThreadingPolicy)
            .Returns(threadingService);

            projectServices.Setup(u => u.FaultHandler)
            .Returns(faultHandlerService);

            projectServices.Setup(u => u.ProjectService)
            .Returns(projectService);

            return(projectServices.Object);
        }
Ejemplo n.º 15
0
 // ECan pass null for all and a default will be created
 public LaunchSettingsUnderTest(UnconfiguredProject project, IUnconfiguredProjectServices projectServices,
                                IFileSystem fileSystem, IUnconfiguredProjectCommonServices commonProjectServices,
                                IActiveConfiguredProjectSubscriptionService projectSubscriptionService, ActiveConfiguredProject <AppDesignerFolderSpecialFileProvider> appDesignerFolderSpecialFileProvider, IProjectFaultHandlerService projectFaultHandler = null)
     : base(project, projectServices, fileSystem, commonProjectServices, projectSubscriptionService, appDesignerFolderSpecialFileProvider, projectFaultHandler)
 {
     // Block the code from setting up one on the real file system. Since we block, it we need to set up the fileChange scheduler manually
     FileWatcher = new SimpleFileWatcher();
     // Make the unit tests run faster
     FileChangeProcessingDelay = TimeSpan.FromMilliseconds(50);
     FileChangeScheduler       = new TaskDelayScheduler(FileChangeProcessingDelay, commonProjectServices.ThreadingService,
                                                        CancellationToken.None);
 }