Пример #1
0
        static RoslynCommandTarget()
        {
            var defaultForegroundThreadData = ForegroundThreadData.CreateDefault(
                defaultKind: ForegroundThreadDataKind.ForcedByPackageInitialize);

            ForegroundThreadAffinitizedObject.CurrentForegroundThreadData = defaultForegroundThreadData;
        }
Пример #2
0
        protected override void Initialize()
        {
            base.Initialize();

            // Assume that we are being initialized on the UI thread at this point.
            var defaultForegroundThreadData = ForegroundThreadData.CreateDefault(
                defaultKind: ForegroundThreadDataKind.ForcedByPackageInitialize);

            ForegroundThreadAffinitizedObject.CurrentForegroundThreadData = defaultForegroundThreadData;
            ForegroundObject = new ForegroundThreadAffinitizedObject();
        }
Пример #3
0
        protected override void Initialize()
        {
            base.Initialize();

            var defaultForegroundThreadData = ForegroundThreadData.CreateDefault();

            ForegroundThreadAffinitizedObject.DefaultForegroundThreadData = defaultForegroundThreadData;
            _foregroundObject = new ForegroundThreadAffinitizedObject(defaultForegroundThreadData);

            foreach (var editorFactory in CreateEditorFactories())
            {
                RegisterEditorFactory(editorFactory);
            }

            RegisterLanguageService(typeof(TLanguageService), () =>
            {
                // Create the language service, tell it to set itself up, then store it in a field
                // so we can notify it that it's time to clean up.
                _languageService = CreateLanguageService();
                _languageService.Setup();
                return(_languageService.ComAggregate);
            });

            // Okay, this is also a bit strange.  We need to get our Interop dll into our process,
            // but we're in the GAC.  Ask the base Roslyn Package to load, and it will take care of
            // it for us.
            // * NOTE * workspace should never be created before loading roslyn package since roslyn package
            //          installs a service roslyn visual studio workspace requires
            IVsPackage setupPackage;
            var        shell = (IVsShell)this.GetService(typeof(SVsShell));

            shell.LoadPackage(Guids.RoslynPackageId, out setupPackage);

            _miscellaneousFilesWorkspace = this.ComponentModel.GetService <MiscellaneousFilesWorkspace>();
            if (_miscellaneousFilesWorkspace != null)
            {
                // make sure solution crawler start once everything has been setup.
                _miscellaneousFilesWorkspace.StartSolutionCrawler();
            }

            RegisterMiscellaneousFilesWorkspaceInformation(_miscellaneousFilesWorkspace);

            this.Workspace = this.CreateWorkspace();
            if (this.Workspace != null)
            {
                // make sure solution crawler start once everything has been setup.
                // this also should be started before any of workspace events start firing
                this.Workspace.StartSolutionCrawler();
            }

            // Ensure services that must be created on the UI thread have been.
            HACK_AbstractCreateServicesOnUiThread.CreateServicesOnUIThread(ComponentModel, RoslynLanguageName);
        }
Пример #4
0
        protected override void Initialize()
        {
            base.Initialize();

            ForegroundThreadAffinitizedObject.CurrentForegroundThreadData = ForegroundThreadData.CreateDefault();
            Debug.Assert(
                ForegroundThreadAffinitizedObject.CurrentForegroundThreadData.Kind == ForegroundThreadDataKind.Wpf ||
                ForegroundThreadAffinitizedObject.CurrentForegroundThreadData.Kind == ForegroundThreadDataKind.JoinableTask);

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