Example #1
0
        protected override void Initialize()
        {
            base.Initialize();

            ForegroundThreadAffinitizedObject.Initialize();

            FatalError.Handler = FailFast.OnFatalException;
            FatalError.NonFatalHandler = WatsonReporter.Report;

            // We also must set the FailFast handler for the compiler layer as well
            var compilerAssembly = typeof(Compilation).Assembly;
            var compilerFatalError = compilerAssembly.GetType("Microsoft.CodeAnalysis.FatalError", throwOnError: true);
            var property = compilerFatalError.GetProperty(nameof(FatalError.Handler), BindingFlags.Static | BindingFlags.Public);
            var compilerFailFast = compilerAssembly.GetType(typeof(FailFast).FullName, throwOnError: true);
            var method = compilerFailFast.GetMethod(nameof(FailFast.OnFatalException), BindingFlags.Static | BindingFlags.NonPublic);
            property.SetValue(null, Delegate.CreateDelegate(property.PropertyType, method));

            RegisterFindResultsLibraryManager();

            var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel));
            _workspace = componentModel.GetService<VisualStudioWorkspace>();

            var telemetrySetup = componentModel.GetService<IRoslynTelemetrySetup>();
            telemetrySetup?.Initialize(this);
                
            // set workspace output pane
            _outputPane = new WorkspaceFailureOutputPane(this, _workspace);

            InitializeColors();

            // load some services that have to be loaded in UI thread
            LoadComponentsInUIContext();

            _solutionBuildMonitor = new SolutionBuildMonitor(_workspace);
        }
        public VisualStudioDiagnosticListTable(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspace workspace,
            IDiagnosticService diagnosticService,
            ExternalErrorDiagnosticUpdateSource errorSource,
            ITableManagerProvider provider) :
            this(serviceProvider, (Workspace)workspace, diagnosticService, errorSource, provider)
        {
            ConnectWorkspaceEvents();

            _errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;
            if (_errorList == null)
            {
                AddInitialTableSource(workspace.CurrentSolution, _liveTableSource);
                return;
            }

            _errorList.PropertyChanged += OnErrorListPropertyChanged;
            AddInitialTableSource(workspace.CurrentSolution, GetCurrentDataSource());
            SuppressionStateColumnDefinition.SetDefaultFilter(_errorList.TableControl);

            if (ErrorListHasFullSolutionAnalysisButton())
            {
                SetupErrorListFullSolutionAnalysis(workspace);
            }
        }
 public VisualStudioErrorTaskList(
     SVsServiceProvider serviceProvider,
     VisualStudioWorkspace workspace,
     IForegroundNotificationService notificationService,
     IDiagnosticService diagnosticService,
     [ImportMany] IEnumerable<Lazy<IAsynchronousOperationListener, FeatureMetadata>> asyncListeners) :
     base(serviceProvider, workspace, notificationService, diagnosticService, asyncListeners)
 {
 }
        protected AbstractObjectBrowserLibraryManager(string languageName, Guid libraryGuid, IServiceProvider serviceProvider)
            : base(libraryGuid, serviceProvider)
        {
            _languageName = languageName;

            var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
            this.Workspace = componentModel.GetService<VisualStudioWorkspace>();
            this.Workspace.WorkspaceChanged += OnWorkspaceChanged;
        }
        public VisualStudioDiagnosticListTable(
            SVsServiceProvider serviceProvider, VisualStudioWorkspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) :
            base(serviceProvider, workspace, diagnosticService, Identifier, provider)
        {
            ConnectWorkspaceEvents();

            // create initial project rank map
            this.Source.OnProjectDependencyChanged(workspace.CurrentSolution);
        }
 public VsImmediateWindowProvider(
     SVsServiceProvider serviceProvider,
     IVsInteractiveWindowFactory interactiveWindowFactory,
     IViewClassifierAggregatorService classifierAggregator,
     IContentTypeRegistryService contentTypeRegistry,
     VisualStudioWorkspace workspace)
 {
     _vsInteractiveWindowFactory = interactiveWindowFactory;
     _vsDebugger = (IVsDebugger)serviceProvider.GetService(typeof(IVsDebugger));
 }
        protected AbstractObjectBrowserLibraryManager(string languageName, Guid libraryGuid, __SymbolToolLanguage preferredLanguage, IServiceProvider serviceProvider)
            : base(libraryGuid, serviceProvider)
        {
            _languageName = languageName;
            _preferredLanguage = preferredLanguage;

            var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
            this.Workspace = componentModel.GetService<VisualStudioWorkspace>();
            this.LibraryService = this.Workspace.Services.GetLanguageServices(languageName).GetService<ILibraryService>();
            this.Workspace.WorkspaceChanged += OnWorkspaceChanged;
        }
 public CSharpVsInteractiveWindowProvider(
     SVsServiceProvider serviceProvider,
     IVsInteractiveWindowFactory interactiveWindowFactory,
     IViewClassifierAggregatorService classifierAggregator,
     IContentTypeRegistryService contentTypeRegistry,
     IInteractiveWindowCommandsFactory commandsFactory,
     [ImportMany]IInteractiveWindowCommand[] commands,
     VisualStudioWorkspace workspace)
     : base(serviceProvider, interactiveWindowFactory, classifierAggregator, contentTypeRegistry, commandsFactory, commands, workspace)
 {
 }
        public VisualStudioDiagnosticListSuppressionStateService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspace workspace)
        {
            _workspace = workspace;
            _shellService = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell));
            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;
            _tableControl = errorList?.TableControl;

            ClearState();
            InitializeFromTableControlIfNeeded();
        }
Example #10
0
        public CodeModelState(
            IServiceProvider serviceProvider,
            HostLanguageServices languageServices,
            VisualStudioWorkspace workspace)
        {
            Debug.Assert(serviceProvider != null);
            Debug.Assert(languageServices != null);
            Debug.Assert(workspace != null);

            this.ServiceProvider = serviceProvider;
            this.CodeModelService = languageServices.GetService<ICodeModelService>();
            this.SyntaxFactsService = languageServices.GetService<ISyntaxFactsService>();
            this.CodeGenerator = languageServices.GetService<ICodeGenerationService>();
            this.Workspace = workspace;
        }
 protected override InteractiveEvaluator CreateInteractiveEvaluator(
     SVsServiceProvider serviceProvider,
     IViewClassifierAggregatorService classifierAggregator,
     IContentTypeRegistryService contentTypeRegistry,
     VisualStudioWorkspace workspace)
 {
     return new CSharpInteractiveEvaluator(
         workspace.Services.HostServices,
         classifierAggregator,
         CommandsFactory,
         Commands,
         contentTypeRegistry,
         Path.GetDirectoryName(typeof(CSharpVsInteractiveWindowPackage).Assembly.Location),
         CommonVsUtils.GetWorkingDirectory());
 }
 public VsInteractiveWindowProvider(
    SVsServiceProvider serviceProvider,
    IVsInteractiveWindowFactory interactiveWindowFactory,
    IViewClassifierAggregatorService classifierAggregator,
    IContentTypeRegistryService contentTypeRegistry,
    IInteractiveWindowCommandsFactory commandsFactory,
    IInteractiveWindowCommand[] commands,
    VisualStudioWorkspace workspace)
 {
     _vsServiceProvider = serviceProvider;
     _classifierAggregator = classifierAggregator;
     _contentTypeRegistry = contentTypeRegistry;
     _vsWorkspace = workspace;
     _commands = FilterCommands(commands, contentType: PredefinedInteractiveCommandsContentTypes.InteractiveCommandContentTypeName);
     _vsInteractiveWindowFactory = interactiveWindowFactory;
     _commandsFactory = commandsFactory;
 }
        public MiscellaneousFilesWorkspace(
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IMetadataAsSourceFileService fileTrackingMetadataAsSourceService,
            SaveEventsService saveEventsService,
            VisualStudioWorkspace visualStudioWorkspace,
            SVsServiceProvider serviceProvider) :
            base(visualStudioWorkspace.Services.HostServices, WorkspaceKind.MiscellaneousFiles)
        {
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _fileTrackingMetadataAsSourceService = fileTrackingMetadataAsSourceService;
            _runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable));
            _textManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager));

            ((IVsRunningDocumentTable)_runningDocumentTable).AdviseRunningDocTableEvents(this, out _runningDocumentTableEventsCookie);

            _metadataReferences = ImmutableArray.CreateRange(CreateMetadataReferences());
            _documentProvider = new RoslynDocumentProvider(this, serviceProvider);
            saveEventsService.StartSendingSaveEvents();
        }
Example #14
0
        protected override void Initialize()
        {
            base.Initialize();

            // Assume that we are being initialized on the UI thread at this point.
            ForegroundThreadAffinitizedObject.CurrentForegroundThreadData = ForegroundThreadData.CreateDefault(defaultKind: ForcedByPackageInitialize);
            Debug.Assert(ForegroundThreadAffinitizedObject.CurrentForegroundThreadData.Kind != Unknown);

            FatalError.Handler = FailFast.OnFatalException;
            FatalError.NonFatalHandler = WatsonReporter.Report;

            // We also must set the FailFast handler for the compiler layer as well
            var compilerAssembly = typeof(Compilation).Assembly;
            var compilerFatalError = compilerAssembly.GetType("Microsoft.CodeAnalysis.FatalError", throwOnError: true);
            var property = compilerFatalError.GetProperty(nameof(FatalError.Handler), BindingFlags.Static | BindingFlags.Public);
            var compilerFailFast = compilerAssembly.GetType(typeof(FailFast).FullName, throwOnError: true);
            var method = compilerFailFast.GetMethod(nameof(FailFast.OnFatalException), BindingFlags.Static | BindingFlags.NonPublic);
            property.SetValue(null, Delegate.CreateDelegate(property.PropertyType, method));

            InitializePortableShim(compilerAssembly);

            RegisterFindResultsLibraryManager();

            var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel));
            _workspace = componentModel.GetService<VisualStudioWorkspace>();

            var telemetrySetupExtensions = componentModel.GetExtensions<IRoslynTelemetrySetup>();
            foreach (var telemetrySetup in telemetrySetupExtensions)
            {
                telemetrySetup.Initialize(this);
            }

            // set workspace output pane
            _outputPane = new WorkspaceFailureOutputPane(this, _workspace);

            InitializeColors();

            // load some services that have to be loaded in UI thread
            LoadComponentsInUIContext();

            _solutionEventMonitor = new SolutionEventMonitor(_workspace);
        }
        public VisualStudioDiagnosticListTable(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspace workspace,
            IDiagnosticService diagnosticService,
            ExternalErrorDiagnosticUpdateSource errorSource,
            ITableManagerProvider provider) :
            this(serviceProvider, (Workspace)workspace, diagnosticService, errorSource, provider)
        {
            ConnectWorkspaceEvents();

            _errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;
            if (_errorList == null)
            {
                AddInitialTableSource(workspace.CurrentSolution, _liveTableSource);
                return;
            }

            _errorList.PropertyChanged += OnErrorListPropertyChanged;

            AddInitialTableSource(workspace.CurrentSolution, GetCurrentDataSource());
        }
 protected abstract InteractiveEvaluator CreateInteractiveEvaluator(
     SVsServiceProvider serviceProvider,
     IViewClassifierAggregatorService classifierAggregator,
     IContentTypeRegistryService contentTypeRegistry,
     VisualStudioWorkspace workspace);
Example #17
0
 internal CodeModelProjectCache(AbstractProject project, IServiceProvider serviceProvider, HostLanguageServices languageServices, VisualStudioWorkspace workspace)
 {
     _project = project;
     _state = new CodeModelState(serviceProvider, languageServices, workspace);
 }
Example #18
0
 public void SetWorkspace(VisualStudioWorkspace workspace) => _workspace = workspace;
Example #19
0
 public RazorLanguageClient(LanguageServerProtocol languageServerProtocol, VisualStudioWorkspace workspace, IDiagnosticService diagnosticService)
     : base(languageServerProtocol, workspace, diagnosticService, ClientName)
 {
 }
 public TempPECompilerService(VisualStudioWorkspace workspace)
 {
     _workspace = workspace;
 }
 protected abstract IList<TextChange> GetFormattedTextChanges(VisualStudioWorkspace workspace, string filePath, SourceText text, CancellationToken cancellationToken);
 public VisualStudioLspSolutionProvider(VisualStudioWorkspace visualStudioWorkspace, MiscellaneousFilesWorkspace miscellaneousFilesWorkspace)
 {
     _visualStudioWorkspace       = visualStudioWorkspace;
     _miscellaneousFilesWorkspace = miscellaneousFilesWorkspace;
 }
 public VisualStudioTodoListTable(VisualStudioWorkspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) :
     base(workspace, todoListProvider, IdentifierString, provider)
 {
     ConnectWorkspaceEvents();
 }
Example #24
0
 public CSharpProjectCodeModel(CSharpProjectShimWithServices project, VisualStudioWorkspace visualStudioWorkspace, IServiceProvider serviceProvider)
     : base(project, visualStudioWorkspace, serviceProvider)
 {
     _project = project;
 }
 public AbstractProjectCodeModel(AbstractProject project, VisualStudioWorkspace visualStudioWorkspace, IServiceProvider serviceProvider)
 {
     _vsProject = project;
     _visualStudioWorkspace = visualStudioWorkspace;
     _serviceProvider = serviceProvider;
 }
Example #26
0
        private static async Task <IEnumerable <AnalysisResult> > AnalyzeSingleSyntaxTreesAsync(VisualStudioWorkspace visualStudioWorkspace, IProgress <int> progress)
        {
            var           analysisResults = new ConcurrentBag <AnalysisResult>();
            SyntaxTree    syntaxTree      = null;
            SemanticModel semanticModel   = null;
            SingleSyntaxTreeAnalysisContext analysisContext = null;

            var analyseSyntaxTreeActions = AnalyzeSingleSyntaxTreeAndCollectResultsActions
                                           // We intentionally access the modified closure here (syntaxTree, semanticModel, analysisContext),
                                           // because we want to avoid creation of a huge number of temporary Action objects.

                                           // ReSharper disable AccessToModifiedClosure
                                           .Select(action => new Action(() => action(syntaxTree, semanticModel, analysisContext, analysisResults)))
                                           // ReSharper restore AccessToModifiedClosure
                                           .ToArray();

            // WARNING: Keep the progress counter in sync with the logic behind the calculation of the maximum progress!
            int progressCounter = 0;

            foreach (var project in visualStudioWorkspace.CurrentSolution.Projects.Where(ProjectSatisfiesProjectFilter))
            {
                foreach (var document in project.Documents.Where(DocumentSatisfiesDocumentFilter))
                {
                    analysisContext = new SingleSyntaxTreeAnalysisContext(document);

                    syntaxTree = await document.GetSyntaxTreeAsync().ConfigureAwait(false);

                    semanticModel = await document.GetSemanticModelAsync();

                    // Each of the actions will operate on the same (current) syntaxTree.
                    Parallel.Invoke(analyseSyntaxTreeActions);
                    progress.Report(++progressCounter);
                }
            }
            return(analysisResults);
        }
Example #27
0
 public Task <IEnumerable <AnalysisResult> > AnalyzeAsync(VisualStudioWorkspace visualStudioWorkspace, IProgress <int> progress)
 {
     return(AnalyzeSingleSyntaxTreesAsync(visualStudioWorkspace, progress));
 }
 public VisualStudioDebugStateChangeListener(VisualStudioWorkspace workspace)
 {
     _workspace        = workspace;
     _debuggingService = workspace.Services.GetRequiredService <IDebuggingWorkspaceService>();
 }
Example #29
0
 public VisualStudioActiveStatementTracker(VisualStudioWorkspace workspace)
 {
     _encService = workspace.Services.GetRequiredService <IEditAndContinueWorkspaceService>();
 }
 public Service(IThreadingContext threadingContext, VisualStudioWorkspace workspace, IServiceProvider serviceProvider)
     : base(threadingContext, assertIsForeground: false)
 {
     _workspace       = workspace;
     _serviceProvider = serviceProvider;
 }
 protected override IList<TextChange> GetFormattedTextChanges(VisualStudioWorkspace workspace, string filePath, SourceText text, CancellationToken cancellationToken)
 {
     var root = SyntaxFactory.ParseSyntaxTree(text, path: filePath, cancellationToken: cancellationToken).GetRoot(cancellationToken);
     return Formatter.GetFormattedTextChanges(root, workspace, cancellationToken: cancellationToken);
 }
Example #32
0
 public Analyzer(IForegroundNotificationService notificationService, IAsynchronousOperationListener listener, VisualStudioWorkspace workspace, ProjectCodeModelFactory projectCodeModelFactory)
 {
     _notificationService     = notificationService;
     _listener                = listener;
     _workspace               = workspace;
     _projectCodeModelFactory = projectCodeModelFactory;
 }
 public VisualStudioProvider(VisualStudioWorkspace workspace)
 {
     _workspace = workspace;
 }
Example #34
0
 public static Project GetProject(IVsHierarchy projectHierarchy, VisualStudioWorkspace visualStudioWorkspace)
 {
     return(visualStudioWorkspace.CurrentSolution.Projects
            .FirstOrDefault(p => projectHierarchy == visualStudioWorkspace.GetHierarchy(p.Id)));
 }