Esempio n. 1
0
 public VisualStudioDiagnosticListTableWorkspaceEventListener(
     [Import("Microsoft.VisualStudio.Shell.Interop.SAsyncServiceProvider")] object asyncServiceProvider,
     IThreadingContext threadingContext,
     ITableManagerProvider tableManagerProvider)
 {
     // MEFv2 doesn't support type based contract for Import above and for this particular contract (SAsyncServiceProvider)
     // actual type cast doesn't work. (https://github.com/microsoft/vs-mef/issues/138)
     // workaround by getting the service as object and cast to actual interface
     _asyncServiceProvider = (Shell.IAsyncServiceProvider)asyncServiceProvider;
     _threadingContext     = threadingContext;
     _tableManagerProvider = tableManagerProvider;
 }
Esempio n. 2
0
 public CPSProjectFactory(
     IThreadingContext threadingContext,
     VisualStudioProjectFactory projectFactory,
     VisualStudioWorkspaceImpl workspace,
     IProjectCodeModelFactory projectCodeModelFactory,
     SVsServiceProvider serviceProvider)
 {
     _threadingContext        = threadingContext;
     _projectFactory          = projectFactory;
     _workspace               = workspace;
     _projectCodeModelFactory = projectCodeModelFactory;
     _serviceProvider         = (Shell.IAsyncServiceProvider)serviceProvider;
 }
 public VisualStudioProjectFactory(
     IThreadingContext threadingContext,
     VisualStudioWorkspaceImpl visualStudioWorkspaceImpl,
     [ImportMany] IEnumerable <Lazy <IDynamicFileInfoProvider, FileExtensionsMetadata> > fileInfoProviders,
     HostDiagnosticUpdateSource hostDiagnosticUpdateSource,
     SVsServiceProvider serviceProvider)
 {
     _threadingContext           = threadingContext;
     _visualStudioWorkspaceImpl  = visualStudioWorkspaceImpl;
     _dynamicFileInfoProviders   = fileInfoProviders.AsImmutableOrEmpty();
     _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
     _serviceProvider            = (Shell.IAsyncServiceProvider)serviceProvider;
 }
Esempio n. 4
0
        public AbstractSnippetInfoService(
            IThreadingContext threadingContext,
            Shell.IAsyncServiceProvider serviceProvider,
            Guid languageGuidForSnippets,
            IAsynchronousOperationListenerProvider listenerProvider)
            : base(threadingContext)
        {
            _waiter = listenerProvider.GetListener(FeatureAttribute.Snippets);
            _languageGuidForSnippets = languageGuidForSnippets;
            _threadingContext        = threadingContext;

            _threadingContext.RunWithShutdownBlockAsync((_) => InitializeAndPopulateSnippetsCacheAsync(serviceProvider));
        }
        public FileChangeWatcherProvider(IThreadingContext threadingContext, [Import(typeof(SVsServiceProvider))] Shell.IAsyncServiceProvider serviceProvider)
        {
            // We do not want background work to implicitly block on the availability of the SVsFileChangeEx to avoid any deadlock risk,
            // since the first fetch for a file watcher might end up happening on the background.
            Watcher = new FileChangeWatcher(_fileChangeService.Task);

            System.Threading.Tasks.Task.Run(async() =>
            {
                await threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync();

                var fileChangeService = (IVsAsyncFileChangeEx)await serviceProvider.GetServiceAsync(typeof(SVsFileChangeEx)).ConfigureAwait(true);
                _fileChangeService.SetResult(fileChangeService);
            });
        }
Esempio n. 6
0
        private async Task InitializeAndPopulateSnippetsCacheAsync(Shell.IAsyncServiceProvider asyncServiceProvider)
        {
            await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync();

            var textManager = (IVsTextManager2?)await asyncServiceProvider.GetServiceAsync(typeof(SVsTextManager)).ConfigureAwait(true);

            Assumes.Present(textManager);

            if (textManager.GetExpansionManager(out _expansionManager) == VSConstants.S_OK)
            {
                ComEventSink.Advise <IVsExpansionEvents>(_expansionManager, this);
                await PopulateSnippetCacheAsync().ConfigureAwait(false);
            }
        }
        public FileChangeWatcherProvider(
            IThreadingContext threadingContext,
            IAsynchronousOperationListenerProvider listenerProvider,
            [Import(typeof(SVsServiceProvider))] Shell.IAsyncServiceProvider serviceProvider)
        {
            var fileChangeService = Task.Factory.StartNew(
                async() =>
            {
                await threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(threadingContext.DisposalToken);

                var fileChangeService = (IVsAsyncFileChangeEx?)await serviceProvider.GetServiceAsync(typeof(SVsFileChangeEx)).ConfigureAwait(true);
                Assumes.Present(fileChangeService);
                return(fileChangeService);
            },
                threadingContext.DisposalToken,
                TaskCreationOptions.RunContinuationsAsynchronously,
                TaskScheduler.Default)
                                    .Unwrap();

            // We do not want background work to implicitly block on the availability of the SVsFileChangeEx to avoid any deadlock risk,
            // since the first fetch for a file watcher might end up happening on the background.
            Watcher = new FileChangeWatcher(listenerProvider, fileChangeService);
        }