public ReplWindowTextViewCreationListener(IVsEditorAdaptersFactoryService adaptersFactory, IEditorOperationsFactoryService editorOperationsFactory, [Import(typeof(SVsServiceProvider))]IServiceProvider serviceProvider, IEditorOptionsFactoryService editorOptionsFactory) {
     _serviceProvider = serviceProvider;
     _adaptersFactory = adaptersFactory;
     _editorOperationsFactory = editorOperationsFactory;
     _compModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
     _editorOptionsFactory = editorOptionsFactory;
 }
예제 #2
0
        private ILookup<string, FileSystemPath> installedPackages; // there can be several versions of one package (different versions)

        #endregion Fields

        #region Constructors

        public NuGetApi(ISolution solution, Lifetime lifetime, IComponentModel componentModel, IThreading threading, ProjectModelSynchronizer projectModelSynchronizer)
        {
            this.solution = solution;
            this.threading = threading;
            this.projectModelSynchronizer = projectModelSynchronizer;
            try
            {
                vsPackageInstallerServices = componentModel.GetExtensions<IVsPackageInstallerServices>().SingleOrDefault();
                vsPackageInstaller = componentModel.GetExtensions<IVsPackageInstaller>().SingleOrDefault();
                vsPackageInstallerEvents = componentModel.GetExtensions<IVsPackageInstallerEvents>().SingleOrDefault();
            }
            catch (Exception e)
            {
                Logger.LogException("Unable to get NuGet interfaces.", e);
            }

            if (!IsNuGetAvailable)
            {
                Logger.LogMessage(LoggingLevel.VERBOSE, "[NUGET PLUGIN] Unable to get NuGet interfaces. No exception thrown");
                return;
            }

            lifetime.AddBracket(
              () => vsPackageInstallerEvents.PackageInstalled += RecalcInstalledPackages,
              () => vsPackageInstallerEvents.PackageInstalled -= RecalcInstalledPackages);

              lifetime.AddBracket(
              () => vsPackageInstallerEvents.PackageUninstalled += RecalcInstalledPackages,
              () => vsPackageInstallerEvents.PackageUninstalled -= RecalcInstalledPackages);

              RecalcInstalledPackages(null);
        }
예제 #3
0
 public PythonRunSettings([Import(typeof(SVsServiceProvider))]IServiceProvider serviceProvider) {
     _compModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
     var opState = _compModel.GetService<IOperationState>();
     opState.StateChanged += StateChange;
     _dispatcher = Dispatcher.CurrentDispatcher;
     _serviceProvider = serviceProvider;
 }
예제 #4
0
        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            dteObject = (DTE)automationObject;
            serviceProvider = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)this.dteObject;

            IntPtr zero4 = IntPtr.Zero;
            Guid guid = typeof(SComponentModel).GUID;
            serviceProvider.QueryService(ref guid, ref IUnknownGuid, out zero4);
            componentModel = (IComponentModel)GetObjectFromNativeUnknown(zero4);

            replacementsDictionary["$ext_safeprojectname$"] = RootWizard.GlobalDictionary["$ext_safeprojectname$"];
            replacementsDictionary["$ext_projectname$"] = RootWizard.GlobalDictionary["$ext_projectname$"];

            string localDBInstance = "v11.0";
            var localDBInstances = SqlLocalDbApi.GetInstanceNames();
            if (localDBInstances.IndexOf("MSSqlLocalDB") >= 0)
                localDBInstance = "MSSqlLocalDB";
            else if (localDBInstances.IndexOf("v12.0") >= 0)
                localDBInstance = "v12.0";
            else if (localDBInstances.IndexOf("v11.0") >= 0)
                localDBInstance = "v11.0";
            else if (localDBInstances.Count > 0)
                localDBInstance = localDBInstances[0];

            replacementsDictionary["connectionString=\"Data Source=(LocalDb)\\v11.0;"] =
                "connectionString=\"Data Source=(LocalDb)\\" + localDBInstance + ";";

            if (!replacementsDictionary.TryGetValue("$wizarddata$", out wizardData))
                wizardData = null;
        }
예제 #5
0
 public PreviewEngine(
     string title,
     string helpString,
     string description,
     string topLevelItemName,
     Glyph topLevelGlyph,
     Solution newSolution,
     Solution oldSolution,
     IComponentModel componentModel,
     IVsImageService2 imageService,
     bool showCheckBoxes = true)
 {
     _topLevelName = topLevelItemName;
     _topLevelGlyph = topLevelGlyph;
     _title = title;
     _helpString = helpString;
     _description = description;
     _newSolution = newSolution.WithMergedLinkedFileChangesAsync(oldSolution, cancellationToken: CancellationToken.None).Result;
     _oldSolution = oldSolution;
     _diffSelector = componentModel.GetService<ITextDifferencingSelectorService>();
     _editorFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>();
     _componentModel = componentModel;
     this.ShowCheckBoxes = showCheckBoxes;
     _imageService = imageService;
 }
예제 #6
0
파일: FileChange.cs 프로젝트: RoryVL/roslyn
        public FileChange(TextDocument left,
            TextDocument right,
            IComponentModel componentModel,
            AbstractChange parent,
            PreviewEngine engine,
            IVsImageService2 imageService) : base(engine)
        {
            Contract.ThrowIfFalse(left != null || right != null);

            this.Id = left != null ? left.Id : right.Id;
            _left = left;
            _right = right;
            _imageService = imageService;

            _componentModel = componentModel;
            var bufferFactory = componentModel.GetService<ITextBufferFactoryService>();
            var bufferText = left != null ?
                left.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None) :
                right.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None);
            _buffer = bufferFactory.CreateTextBuffer(bufferText.ToString(), bufferFactory.InertContentType);
            _encoding = bufferText.Encoding;

            this.Children = ComputeChildren(left, right, CancellationToken.None);
            this.parent = parent;
        }
 public CSharpResetInteractiveMenuCommand(
     OleMenuCommandService menuCommandService,
     IVsMonitorSelection monitorSelection,
     IComponentModel componentModel)
     : base(ContentTypeNames.CSharpContentType, menuCommandService, monitorSelection, componentModel)
 {
 }
예제 #8
0
 public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView, IComponentModel componentModel)
 {
     _window = codeWindow;
     _textView = textView;
     _editorOperationsFactory = componentModel.GetService<IEditorOperationsFactoryService>();
     _analyzer = componentModel.GetService<IPythonAnalyzer>();
 }
        private void InstallCompositionPackagesIfNeeded( IComponentModel services, IVsPackageInstallerServices nuget, Lazy<XElement> wizardData )
        {
            Contract.Requires( services != null );
            Contract.Requires( nuget != null );
            Contract.Requires( wizardData != null );

            // ensure composition is enabled
            if ( !GetBoolean( "$compose$" ) )
                return;

            var packages = wizardData.Value;
            var packageIds = new[] { "Microsoft.Composition", "More.Composition" };
            var packageVersions = new Dictionary<string, string>();

            // build collection of required packages and versions
            foreach ( var packageId in packageIds )
            {
                if ( nuget.IsPackageInstalled( Project, packageId ) )
                    continue;

                var packageVersion = ( from element in packages.Elements( "package" )
                                       let id = (string) element.Attribute( "id" )
                                       where id == packageId
                                       select (string) element.Attribute( "version" ) ).FirstOrDefault();

                if ( !string.IsNullOrEmpty( packageVersion ) )
                    packageVersions[packageId] = packageVersion;
            }

            InstallPackages( services, packages, packageVersions );
        }
예제 #10
0
        private void InstallPackages( IComponentModel services, XElement packages, IDictionary<string, string> packageVersions )
        {
            Contract.Requires( services != null );
            Contract.Requires( packages != null );
            Contract.Requires( packageVersions != null );

            if ( packageVersions.Count == 0 )
                return;

            var extensionId = (string) packages.Attribute( "repositoryId" );
            var installer = services.GetService<IVsPackageInstaller>();
            var unzipped = false;
            var skipAssemblyReferences = false;
            var ignoreDependencies = false;

            // although it's less efficient, we install the packages one at a time to display status.
            // the mechanism to report back status is internal and can't be wired up without some
            // crafty reflection hacks.  this is a more straight forward alternative.
            foreach ( var entry in packageVersions )
            {
                var packageVersion = new Dictionary<string, string>()
                {
                    { entry.Key, entry.Value }
                };

                // provide user feedback
                DesignTimeEnvironment.StatusBar.Text = SR.PackageInstallStatus.FormatDefault( entry.Key, entry.Value );

                // install the package from the vsix location
                installer.InstallPackagesFromVSExtensionRepository( extensionId, unzipped, skipAssemblyReferences, ignoreDependencies, Project, packageVersion );
            }
        }
예제 #11
0
 public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView, IComponentModel componentModel)
 {
     _window = codeWindow;
     _textView = textView;
     _editorOperationsFactory = componentModel.GetService<IEditorOperationsFactoryService>();
     _textView.Properties.AddProperty(typeof(CodeWindowManager), this);
 }
예제 #12
0
 public virtual void Apply( IComponentModel model, object component )
 {
     if (Next != null)
     {
         Next.Apply( model, component );
     }
 }
예제 #13
0
        internal VsInteractiveWindow(IComponentModel model, Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags)
        {
            _componentModel = model;
            this.Caption = title;
            _editorAdapters = _componentModel.GetService<IVsEditorAdaptersFactoryService>();
            _evaluator = evaluator;

            // The following calls this.OnCreate:
            Guid clsId = this.ToolClsid;
            Guid empty = Guid.Empty;
            Guid typeId = providerId;
            IVsWindowFrame frame;
            var vsShell = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell));

            // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are
            // destroyed when closed.  We are really multi instance but we don't want to be closed.

            ErrorHandler.ThrowOnFailure(
                vsShell.CreateToolWindow(
                    (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fToolbarHost | creationFlags),
                    (uint)instanceId,
                    this.GetIVsWindowPane(),
                    ref clsId,
                    ref typeId,
                    ref empty,
                    null,
                    title,
                    null,
                    out frame
                )
            );

            this.Frame = frame;
        }
예제 #14
0
        protected override void Initialize()
        {
            base.Initialize();

            _componentModel = (IComponentModel)GetService(typeof(SComponentModel));
            _exportProvider = _componentModel.DefaultExportProvider;
            _vim = _exportProvider.GetExportedValue<IVim>();
        }
 public AbstractResetInteractiveCommand(
     VsInteractiveWindowProvider interactiveWindowProvider,
     IServiceProvider serviceProvider)
 {
     _interactiveWindowProvider = interactiveWindowProvider;
     _serviceProvider = serviceProvider;
     _componentModel = (IComponentModel)GetService(typeof(SComponentModel));
 }
 public ReplCSharpEditorSurface()
 {
     _CurrentScriptName = System.IO.Path.GetFileName(VSTools.DefaultScriptFileName);
     InitializeComponent();
     this.DataContext = this;
     _componentModel = (IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel));
     _EditorAdapterFactory = _componentModel.GetService<IVsEditorAdaptersFactoryService>();
 }
예제 #17
0
 internal VsResetInteractive(DTE dte, IComponentModel componentModel, IVsMonitorSelection monitorSelection, IVsSolutionBuildManager buildManager, Func<string, string> createReference, Func<string, string> createImport)
     : base(createReference, createImport)
 {
     _dte = dte;
     _componentModel = componentModel;
     _monitorSelection = monitorSelection;
     _buildManager = buildManager;
 }
예제 #18
0
        protected AbstractEditorFactory(Package package)
        {
            _package = package ?? throw new ArgumentNullException(nameof(package));
            _componentModel = (IComponentModel)ServiceProvider.GetService(typeof(SComponentModel));

            _editorAdaptersFactoryService = _componentModel.GetService<IVsEditorAdaptersFactoryService>();
            _contentTypeRegistryService = _componentModel.GetService<IContentTypeRegistryService>();
            _waitIndicator = _componentModel.GetService<IWaitIndicator>();
        }
        private void ComponentWrap(IComponentModel model, string key, IHandler handler, IInterceptedComponent interceptedComponent)
        {
            interceptedComponent.Add( m_interceptor );

            AssertNotNull( interceptedComponent.Instance );
            AssertNotNull( interceptedComponent.ProxiedInstance );
            AssertNotNull( interceptedComponent.InterceptorChain );
            Assert( interceptedComponent.Instance != interceptedComponent.ProxiedInstance );
        }
        GoToDefinitionAdorner(IWpfTextView textTextView, IComponentModel componentModel) {
            _textView = textTextView;

            _classicationFormatMapService = componentModel.GetService<IClassificationFormatMapService>();
            _classifier                   = componentModel.GetService<IViewClassifierAggregatorService>().GetClassifier(textTextView);            
            _adornmentLayer               = textTextView.GetAdornmentLayer(AdornerName);

            _textView.Closed += OnTextViewClosed;
        }
예제 #21
0
        public override void Apply(IComponentModel model, object component)
        {
            IConfiguration configuration =
                model.Configuration.GetChild("configuration", true);

            ContainerUtil.Configure( component, configuration );

            base.Apply( model, component );
        }
예제 #22
0
        /// <summary>
        /// Starts watching the provided text view for brace matching.  When new braces are inserted
        /// in the text or when the cursor moves to a brace the matching braces are highlighted.
        /// </summary>
        public static void WatchBraceHighlights(ITextView view, IComponentModel componentModel) {
            var matcher = new BraceMatcher(view, componentModel);

            // position changed only fires when the caret is explicitly moved, not from normal text edits,
            // so we track both changes and position changed.
            view.Caret.PositionChanged += matcher.CaretPositionChanged;
            view.TextBuffer.Changed += matcher.TextBufferChanged;
            view.Closed += matcher.TextViewClosed;
        }
      public ServiceProviderBuildStrategy(IServiceProvider serviceProvider, ServiceLocatorOptions options)
      {
         if (serviceProvider == null)
            throw new ArgumentNullException(nameof(serviceProvider), $"{nameof(serviceProvider)} is null.");

         m_serviceProvider = serviceProvider;
         m_componentModel = serviceProvider.GetService<SComponentModel, IComponentModel>();
         m_options = options;
      }
        internal ComponentActionDispatcher(IComponentModel componentModel, MethodInfo methodToExecute, object[] parameters)
        {
            this.componentModel = componentModel;
            this.methodToExecute = methodToExecute;
            this.parameters = parameters;

            threadStart = new ThreadStart (CallBackExecuteNoRedirect);
            thread = new Thread (threadStart);
        }
예제 #25
0
        public DefaultInterpreterSetter(IPythonInterpreterFactory factory, IServiceProvider site = null) {
            Assert.IsNotNull(factory, "Cannot set default to null");
            _model = (IComponentModel)(site ?? VSTestContext.ServiceProvider).GetService(typeof(SComponentModel));
            var interpreterService = _model.GetService<IInterpreterOptionsService>();
            Assert.IsNotNull(interpreterService);

            OriginalInterpreter = interpreterService.DefaultInterpreter;
            CurrentDefault = factory;
            interpreterService.DefaultInterpreter = factory;
        }
        internal ComponentActionDispatcher(IComponentModel componentModel, MethodInfo methodToExecute, object[] parameters, IViewHandler viewHandler, MethodInfo methodToResponse)
        {
            this.componentModel = componentModel;
            this.methodToExecute = methodToExecute;
            this.parameters = parameters;
            this.viewHandler = viewHandler;
            this.methodToResponse = methodToResponse;

            threadStart = new ThreadStart (CallBackExecuteRedirectView);
            thread = new Thread (threadStart);
        }
예제 #27
0
		public static void PrepareSolution(TestContext context) {
			componentModel = (IComponentModel)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SComponentModel));
			componentModel.GetService<TextViewListener>().ReferenceProviders = new[] { sourceRecord };

			DTE.Solution.Open(Path.Combine(SolutionDir, "TestBed.sln"));

			fileName = Path.GetFullPath(Path.Combine(SolutionDir, "CSharp", "File.cs"));
			DTE.ItemOperations.OpenFile(fileName).Activate();
			textView = GetCurentTextView();
			System.Threading.Thread.Sleep(2500);	// Wait for the language service to bind the file; this can really take 2 seconds
		}
예제 #28
0
		public static void PrepareSolution(TestContext context) {
			DTE.Solution.Open(Path.Combine(SolutionDir, "TestBed.sln"));

			var part = AttributedModelServices.CreatePart(sourceRecord);
			componentModel = (IComponentModel)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SComponentModel));
			((CompositionContainer)componentModel.DefaultCompositionService).Compose(new CompositionBatch(new[] { part }, null));

			fileName = Path.GetFullPath(Path.Combine(SolutionDir, "CSharp", "File.cs"));
			DTE.ItemOperations.OpenFile(fileName).Activate();
			textView = GetCurentTextView();
			System.Threading.Thread.Sleep(2500);	// Wait for the language service to bind the file; this can really take 2 seconds
		}
        private static IReplEvaluator GetReplEvaluator(IComponentModel model, string replId, out string[] roles) {
            roles = new string[0];
            foreach (var provider in model.GetExtensions<IReplEvaluatorProvider>()) {
                var evaluator = provider.GetEvaluator(replId);

                if (evaluator != null) {
                    roles = evaluator.GetType().GetCustomAttributes(typeof(ReplRoleAttribute), true).Select(r => ((ReplRoleAttribute)r).Name).ToArray();
                    return evaluator;
                }
            }
            return null;
        }
        /*Ctor new View*/
        internal ComponentActionDispatcher(IComponentModel componentModel, MethodInfo methodToExecute, object[] parameters, Type viewType, MethodInfo methodToResponse)
        {
            this.componentModel = componentModel;
            this.methodToExecute = methodToExecute;
            this.parameters = parameters;
            this.viewType = viewType;
            this.methodToResponse = methodToResponse;

            //Set up Thread;
            threadStart = new ThreadStart (CallBackExecuteRedirectNewView);
            thread = new Thread (threadStart);
        }
예제 #31
0
 protected AbstractEditorFactory(IComponentModel componentModel)
 => _componentModel = componentModel;
예제 #32
0
 internal XamlOleCommandTarget(
     IWpfTextView wpfTextView,
     IComponentModel componentModel)
     : base(wpfTextView, componentModel)
 {
 }
예제 #33
0
        public static T ResolveMefDependency <T>(System.IServiceProvider serviceProvider) where T : class
        {
            IComponentModel componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));

            return(componentModel.GetService <T>());
        }
예제 #34
0
 public CSharpEditorFactory(IComponentModel componentModel)
     : base(componentModel)
 {
 }
예제 #35
0
        public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel componentModel) : base(optionStore)
        {
            _threadingContext   = componentModel.GetService <IThreadingContext>();
            _colorSchemeApplier = componentModel.GetService <ColorSchemeApplier>();

            InitializeComponent();

            // Analysis
            BindToOption(Run_background_code_analysis_for, SolutionCrawlerOptionsStorage.BackgroundAnalysisScopeOption, LanguageNames.CSharp, label: Run_background_code_analysis_for_label);
            BindToOption(Show_compiler_errors_and_warnings_for, SolutionCrawlerOptionsStorage.CompilerDiagnosticsScopeOption, LanguageNames.CSharp, label: Show_compiler_errors_and_warnings_for_label);
            BindToOption(DisplayDiagnosticsInline, InlineDiagnosticsOptions.EnableInlineDiagnostics, LanguageNames.CSharp);
            BindToOption(at_the_end_of_the_line_of_code, InlineDiagnosticsOptions.Location, InlineDiagnosticsLocations.PlacedAtEndOfCode, LanguageNames.CSharp);
            BindToOption(on_the_right_edge_of_the_editor_window, InlineDiagnosticsOptions.Location, InlineDiagnosticsLocations.PlacedAtEndOfEditor, LanguageNames.CSharp);

            BindToOption(Run_code_analysis_in_separate_process, RemoteHostOptions.OOP64Bit);
            BindToOption(Enable_file_logging_for_diagnostics, VisualStudioLoggingOptionsMetadata.EnableFileLoggingForDiagnostics);
            BindToOption(Skip_analyzers_for_implicitly_triggered_builds, FeatureOnOffOptions.SkipAnalyzersForImplicitlyTriggeredBuilds);
            BindToOption(Show_Remove_Unused_References_command_in_Solution_Explorer_experimental, FeatureOnOffOptions.OfferRemoveUnusedReferences, () =>
            {
                // If the option has not been set by the user, check if the option to remove unused references
                // is enabled from experimentation. If so, default to that.
                return(optionStore.GetOption(FeatureOnOffOptions.OfferRemoveUnusedReferencesFeatureFlag));
            });

            // Go To Definition
            BindToOption(Enable_navigation_to_decompiled_sources, MetadataAsSourceOptionsStorage.NavigateToDecompiledSources);
            BindToOption(Always_use_default_symbol_servers_for_navigation, MetadataAsSourceOptionsStorage.AlwaysUseDefaultSymbolServers);
            BindToOption(Navigate_asynchronously_exerimental, FeatureOnOffOptions.NavigateAsynchronously);

            // Rename
            BindToOption(Rename_asynchronously_exerimental, InlineRenameSessionOptionsStorage.RenameAsynchronously);

            // Using Directives
            BindToOption(PlaceSystemNamespaceFirst, GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
            BindToOption(SeparateImportGroups, GenerationOptions.SeparateImportDirectiveGroups, LanguageNames.CSharp);
            BindToOption(SuggestForTypesInReferenceAssemblies, SymbolSearchOptionsStorage.SearchReferenceAssemblies, LanguageNames.CSharp);
            BindToOption(SuggestForTypesInNuGetPackages, SymbolSearchOptionsStorage.SearchNuGetPackages, LanguageNames.CSharp);
            BindToOption(AddUsingsOnPaste, FeatureOnOffOptions.AddImportsOnPaste, LanguageNames.CSharp);

            // Quick Actions
            BindToOption(ComputeQuickActionsAsynchronouslyExperimental, SuggestionsOptions.Asynchronous, () =>
            {
                // If the option has not been set by the user, check if the option is disabled from experimentation.
                return(!optionStore.GetOption(SuggestionsOptions.AsynchronousQuickActionsDisableFeatureFlag));
            });

            // Highlighting
            BindToOption(EnableHighlightReferences, FeatureOnOffOptions.ReferenceHighlighting, LanguageNames.CSharp);
            BindToOption(EnableHighlightKeywords, FeatureOnOffOptions.KeywordHighlighting, LanguageNames.CSharp);

            // Outlining
            BindToOption(EnterOutliningMode, FeatureOnOffOptions.Outlining, LanguageNames.CSharp);
            BindToOption(Collapse_regions_on_file_open, BlockStructureOptionsStorage.CollapseRegionsWhenFirstOpened, LanguageNames.CSharp);
            BindToOption(Collapse_usings_on_file_open, BlockStructureOptionsStorage.CollapseImportsWhenFirstOpened, LanguageNames.CSharp);
            BindToOption(Collapse_sourcelink_embedded_decompiled_files_on_open, BlockStructureOptionsStorage.CollapseSourceLinkEmbeddedDecompiledFilesWhenFirstOpened, LanguageNames.CSharp);
            BindToOption(Collapse_metadata_signature_files_on_open, BlockStructureOptionsStorage.CollapseMetadataSignatureFilesWhenFirstOpened, LanguageNames.CSharp);
            BindToOption(DisplayLineSeparators, FeatureOnOffOptions.LineSeparator, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_declaration_level_constructs, BlockStructureOptionsStorage.ShowOutliningForDeclarationLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_code_level_constructs, BlockStructureOptionsStorage.ShowOutliningForCodeLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_comments_and_preprocessor_regions, BlockStructureOptionsStorage.ShowOutliningForCommentsAndPreprocessorRegions, LanguageNames.CSharp);
            BindToOption(Collapse_regions_when_collapsing_to_definitions, BlockStructureOptionsStorage.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp);

            // Fading
            BindToOption(Fade_out_unused_usings, FadingOptions.FadeOutUnusedImports, LanguageNames.CSharp);
            BindToOption(Fade_out_unreachable_code, FadingOptions.FadeOutUnreachableCode, LanguageNames.CSharp);

            // Block Structure Guides
            BindToOption(Show_guides_for_declaration_level_constructs, BlockStructureOptionsStorage.ShowBlockStructureGuidesForDeclarationLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_guides_for_code_level_constructs, BlockStructureOptionsStorage.ShowBlockStructureGuidesForCodeLevelConstructs, LanguageNames.CSharp);

            // Comments
            BindToOption(GenerateXmlDocCommentsForTripleSlash, DocumentationCommentOptionsStorage.AutoXmlDocCommentGeneration, LanguageNames.CSharp);
            BindToOption(InsertSlashSlashAtTheStartOfNewLinesWhenWritingSingleLineComments, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);
            BindToOption(InsertAsteriskAtTheStartOfNewLinesWhenWritingBlockComments, FeatureOnOffOptions.AutoInsertBlockCommentStartString, LanguageNames.CSharp);

            // Editor Help
            BindToOption(ShowRemarksInQuickInfo, QuickInfoOptionsStorage.ShowRemarksInQuickInfo, LanguageNames.CSharp);
            BindToOption(RenameTrackingPreview, FeatureOnOffOptions.RenameTrackingPreview, LanguageNames.CSharp);
            BindToOption(Split_string_literals_on_enter, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);
            BindToOption(Fix_text_pasted_into_string_literals_experimental, FeatureOnOffOptions.AutomaticallyFixStringContentsOnPaste, LanguageNames.CSharp);
            BindToOption(Report_invalid_placeholders_in_string_dot_format_calls, IdeAnalyzerOptionsStorage.ReportInvalidPlaceholdersInStringDotFormatCalls, LanguageNames.CSharp);
            BindToOption(Underline_reassigned_variables, ClassificationOptionsStorage.ClassifyReassignedVariables, LanguageNames.CSharp);
            BindToOption(Enable_all_features_in_opened_files_from_source_generators, WorkspaceConfigurationOptionsStorage.EnableOpeningSourceGeneratedFilesInWorkspace, () =>
            {
                // If the option has not been set by the user, check if the option is enabled from experimentation.
                // If so, default to that.
                return(optionStore.GetOption(WorkspaceConfigurationOptionsStorage.EnableOpeningSourceGeneratedFilesInWorkspaceFeatureFlag));
            });

            // Regular Expressions
            BindToOption(Colorize_regular_expressions, ClassificationOptionsStorage.ColorizeRegexPatterns, LanguageNames.CSharp);
            BindToOption(Report_invalid_regular_expressions, IdeAnalyzerOptionsStorage.ReportInvalidRegexPatterns, LanguageNames.CSharp);
            BindToOption(Highlight_related_regular_expression_components_under_cursor, HighlightingOptionsStorage.HighlightRelatedRegexComponentsUnderCursor, LanguageNames.CSharp);
            BindToOption(Show_completion_list, CompletionOptionsStorage.ProvideRegexCompletions, LanguageNames.CSharp);

            // Json
            BindToOption(Colorize_JSON_strings, ClassificationOptionsStorage.ColorizeJsonPatterns, LanguageNames.CSharp);
            BindToOption(Report_invalid_JSON_strings, IdeAnalyzerOptionsStorage.ReportInvalidJsonPatterns, LanguageNames.CSharp);
            BindToOption(Highlight_related_JSON_components_under_cursor, HighlightingOptionsStorage.HighlightRelatedJsonComponentsUnderCursor, LanguageNames.CSharp);

            // Classifications
            BindToOption(Editor_color_scheme, ColorSchemeOptions.ColorScheme);

            // Extract Method
            BindToOption(DontPutOutOrRefOnStruct, ExtractMethodOptionsStorage.DontPutOutOrRefOnStruct, LanguageNames.CSharp);

            // Implement Interface or Abstract Class
            BindToOption(with_other_members_of_the_same_kind, ImplementTypeOptionsStorage.InsertionBehavior, ImplementTypeInsertionBehavior.WithOtherMembersOfTheSameKind, LanguageNames.CSharp);
            BindToOption(at_the_end, ImplementTypeOptionsStorage.InsertionBehavior, ImplementTypeInsertionBehavior.AtTheEnd, LanguageNames.CSharp);
            BindToOption(prefer_throwing_properties, ImplementTypeOptionsStorage.PropertyGenerationBehavior, ImplementTypePropertyGenerationBehavior.PreferThrowingProperties, LanguageNames.CSharp);
            BindToOption(prefer_auto_properties, ImplementTypeOptionsStorage.PropertyGenerationBehavior, ImplementTypePropertyGenerationBehavior.PreferAutoProperties, LanguageNames.CSharp);

            // Inline Hints
            BindToOption(DisplayAllHintsWhilePressingAltF1, InlineHintsViewOptions.DisplayAllHintsWhilePressingAltF1);
            BindToOption(ColorHints, InlineHintsViewOptions.ColorHints, LanguageNames.CSharp);

            BindToOption(DisplayInlineParameterNameHints, InlineHintsOptionsStorage.EnabledForParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForLiterals, InlineHintsOptionsStorage.ForLiteralParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForNewExpressions, InlineHintsOptionsStorage.ForObjectCreationParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForEverythingElse, InlineHintsOptionsStorage.ForOtherParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForIndexers, InlineHintsOptionsStorage.ForIndexerParameters, LanguageNames.CSharp);
            BindToOption(SuppressHintsWhenParameterNameMatchesTheMethodsIntent, InlineHintsOptionsStorage.SuppressForParametersThatMatchMethodIntent, LanguageNames.CSharp);
            BindToOption(SuppressHintsWhenParameterNamesDifferOnlyBySuffix, InlineHintsOptionsStorage.SuppressForParametersThatDifferOnlyBySuffix, LanguageNames.CSharp);
            BindToOption(SuppressHintsWhenParameterNamesMatchArgumentNames, InlineHintsOptionsStorage.SuppressForParametersThatMatchArgumentName, LanguageNames.CSharp);

            BindToOption(DisplayInlineTypeHints, InlineHintsOptionsStorage.EnabledForTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForVariablesWithInferredTypes, InlineHintsOptionsStorage.ForImplicitVariableTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForLambdaParameterTypes, InlineHintsOptionsStorage.ForLambdaParameterTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForImplicitObjectCreation, InlineHintsOptionsStorage.ForImplicitObjectCreation, LanguageNames.CSharp);

            // Inheritance Margin
            // Leave the null converter here to make sure if the option value is get from the storage (if it is null), the feature will be enabled
            BindToOption(ShowInheritanceMargin, FeatureOnOffOptions.ShowInheritanceMargin, LanguageNames.CSharp, () => true);
            BindToOption(InheritanceMarginCombinedWithIndicatorMargin, FeatureOnOffOptions.InheritanceMarginCombinedWithIndicatorMargin);
            BindToOption(IncludeGlobalImports, FeatureOnOffOptions.InheritanceMarginIncludeGlobalImports, LanguageNames.CSharp);

            // Stack Trace Explorer
            BindToOption(AutomaticallyOpenStackTraceExplorer, StackTraceExplorerOptionsMetadata.OpenOnFocus);
        }
예제 #36
0
 public NPLLanguageInfo(IServiceProvider serviceProvider)
 {
     _serviceProvider = serviceProvider;
     _componentModel  = serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
 }
예제 #37
0
 internal VsInteractiveWindowFactory(SVsServiceProvider serviceProvider)
 {
     _componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
 }
예제 #38
0
        internal bool CreateFromRegistry(IComponentModel model, int id)
        {
            string contentTypeName, title, replId, languageServiceId;

            using (var root = GetRegistryRoot()) {
                if (root == null)
                {
                    return(false);
                }

                using (var replInfo = root.OpenSubKey(id.ToString())) {
                    if (replInfo == null)
                    {
                        return(false);
                    }

                    contentTypeName = replInfo.GetValue(ContentTypeKey) as string;
                    if (contentTypeName == null)
                    {
                        return(false);
                    }

                    title = replInfo.GetValue(TitleKey) as string;
                    if (title == null)
                    {
                        return(false);
                    }

                    replId = replInfo.GetValue(ReplIdKey) as string;
                    if (replId == null)
                    {
                        return(false);
                    }

                    languageServiceId = replInfo.GetValue(LanguageServiceGuidKey) as string;
                    if (languageServiceId == null)
                    {
                        return(false);
                    }
                }
            }

            Guid languageServiceGuid;

            if (!Guid.TryParse(languageServiceId, out languageServiceGuid))
            {
                return(false);
            }

            var contentTypes = model.GetService <IContentTypeRegistryService>();
            var contentType  = contentTypes.GetContentType(contentTypeName);

            if (contentType == null)
            {
                return(false);
            }

            string[] roles;
            var      evaluator = GetReplEvaluator(model, replId, out roles);

            if (evaluator == null)
            {
                return(false);
            }

            CreateReplWindow(evaluator, contentType, roles, id, title, languageServiceGuid, replId);
            return(true);
        }
예제 #39
0
 ///<summary>Registers a MEF container in this ServiceProvider.</summary>
 ///<remarks>
 /// This is used to provide the IComponentModel service, which is used by many parts of Roslyn and the editor.
 /// It's also used by our TextViewHost wrapper control to access the MEF container.
 ///</remarks>
 public void SetMefContainer(IComponentModel container)
 {
     ComponentModel = container;
     AddService(typeof(SComponentModel), ComponentModel);
 }
예제 #40
0
            static async Task <ImmutableArray <IOptionPersisterProvider> > GetOptionPersistersAsync(IComponentModel componentModel, CancellationToken cancellationToken)
            {
                // Switch to a background thread to ensure assembly loads don't show up as UI delays attributed to
                // InitializeAsync.
                await TaskScheduler.Default;

                return(componentModel.GetExtensions <IOptionPersisterProvider>().ToImmutableArray());
            }
예제 #41
0
        /// <summary>
        /// Method to call to cause us to place the file at the given path into our hosted editor.
        /// </summary>
        public Tuple <Control, IVsTextView> SetDisplayedFile(string filePath)
        {
            ClearEditor();
            try
            {
                //Get an invisible editor over the file, this makes it much easier than having to manually figure out the right content type,
                //language service, and it will automatically associate the document with its owning project, meaning we will get intellisense
                //in our editor with no extra work.
                IVsInvisibleEditorManager invisibleEditorManager = (IVsInvisibleEditorManager)GetService(typeof(SVsInvisibleEditorManager));
                ErrorHandler.ThrowOnFailure(invisibleEditorManager.RegisterInvisibleEditor(filePath,
                                                                                           pProject: null,
                                                                                           dwFlags: (uint)_EDITORREGFLAGS.RIEF_ENABLECACHING,
                                                                                           pFactory: null,
                                                                                           ppEditor: out this.invisibleEditor));

                //The doc data is the IVsTextLines that represents the in-memory version of the file we opened in our invisibe editor, we need
                //to extract that so that we can create our real (visible) editor.
                IntPtr docDataPointer   = IntPtr.Zero;
                Guid   guidIVSTextLines = typeof(IVsTextLines).GUID;
                ErrorHandler.ThrowOnFailure(this.invisibleEditor.GetDocData(fEnsureWritable: 1, riid: ref guidIVSTextLines, ppDocData: out docDataPointer));
                try
                {
                    IVsTextLines docData = (IVsTextLines)Marshal.GetObjectForIUnknown(docDataPointer);

                    //Get the component model so we can request the editor adapter factory which we can use to spin up an editor instance.
                    IComponentModel componentModel = (IComponentModel)GetService(typeof(SComponentModel));
                    IVsEditorAdaptersFactoryService editorAdapterFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>();

                    //Create a code window adapter.
                    this.codeWindow = editorAdapterFactoryService.CreateVsCodeWindowAdapter(OleServiceProvider);

                    //Disable the splitter control on the editor as leaving it enabled causes a crash if the user
                    //tries to use it here :(
                    IVsCodeWindowEx codeWindowEx = (IVsCodeWindowEx)this.codeWindow;
                    INITVIEW[]      initView     = new INITVIEW[1];
                    codeWindowEx.Initialize((uint)_codewindowbehaviorflags.CWB_DISABLESPLITTER,
                                            VSUSERCONTEXTATTRIBUTEUSAGE.VSUC_Usage_Filter,
                                            szNameAuxUserContext: "",
                                            szValueAuxUserContext: "",
                                            InitViewFlags: 0,
                                            pInitView: initView);

                    //docData.SetStateFlags((uint)BUFFERSTATEFLAGS.BSF_USER_READONLY); //set read only

                    //Associate our IVsTextLines with our new code window.
                    ErrorHandler.ThrowOnFailure(this.codeWindow.SetBuffer((IVsTextLines)docData));

                    //Get our text view for our editor which we will use to get the WPF control that hosts said editor.
                    ErrorHandler.ThrowOnFailure(this.codeWindow.GetPrimaryView(out this.textView));

                    //Get our WPF host from our text view (from our code window).
                    IWpfTextViewHost textViewHost = editorAdapterFactoryService.GetWpfTextViewHost(this.textView);

                    textViewHost.TextView.Options.SetOptionValue(GitTextViewOptions.DiffMarginId, false);
                    textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.ChangeTrackingId, false);
                    textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false);
                    textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false);
                    textViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false);

                    textViewHost.TextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true);

                    return(Tuple.Create <Control, IVsTextView>(textViewHost.HostControl, this.textView));

                    //Debug.Assert(contentControl != null);
                    //contentControl.Content = textViewHost.HostControl;
                }
                finally
                {
                    if (docDataPointer != IntPtr.Zero)
                    {
                        //Release the doc data from the invisible editor since it gave us a ref-counted copy.
                        Marshal.Release(docDataPointer);
                    }
                }
            }
            catch { }
            return(null);
        }
예제 #42
0
 public ObjectBrowserLibraryManager(IServiceProvider serviceProvider, IComponentModel componentModel, VisualStudioWorkspace workspace)
     : base(LanguageNames.CSharp, Guids.CSharpLibraryId, __SymbolToolLanguage.SymbolToolLanguage_CSharp, serviceProvider, componentModel, workspace)
 {
 }
예제 #43
0
 internal StandaloneCommandFilter(
     IWpfTextView wpfTextView,
     IComponentModel componentModel)
     : base(wpfTextView, componentModel)
 {
 }
예제 #44
0
        private static TService GetComponentModelService <TService>() where TService : class
        {
            IComponentModel componentModel = GetGlobalService <SComponentModel, IComponentModel>();

            return(componentModel.GetService <TService>());
        }
예제 #45
0
 public ComponentAddedEventArgs(IComponentModel componentModel)
 {
     ComponentModel = componentModel;
 }
        /// <summary>
        /// Constructs and Registers ("Advises") for Project retargeting events if the IVsTrackProjectRetargeting service is available
        /// Otherwise, it simply exits
        /// </summary>
        /// <param name="dte"></param>
        public ProjectRetargetingHandler(DTE dte, ISolutionManager solutionManager, IServiceProvider serviceProvider, IComponentModel componentModel)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (dte == null)
            {
                throw new ArgumentNullException(nameof(dte));
            }

            if (solutionManager == null)
            {
                throw new ArgumentNullException(nameof(solutionManager));
            }

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (componentModel == null)
            {
                throw new ArgumentNullException(nameof(componentModel));
            }

            _solutionRestoreWorker = new Lazy <ISolutionRestoreWorker>(
                () => componentModel.GetService <ISolutionRestoreWorker>());

            var vsTrackProjectRetargeting = serviceProvider.GetService(typeof(SVsTrackProjectRetargeting)) as IVsTrackProjectRetargeting;

            if (vsTrackProjectRetargeting != null)
            {
                _vsMonitorSelection = (IVsMonitorSelection)serviceProvider.GetService(typeof(IVsMonitorSelection));
                Debug.Assert(_vsMonitorSelection != null);
                _errorListProvider = new ErrorListProvider(serviceProvider);
                _dte                       = dte;
                _solutionManager           = solutionManager;
                _vsTrackProjectRetargeting = vsTrackProjectRetargeting;

                // Register for ProjectRetargetingEvents
                if (_vsTrackProjectRetargeting.AdviseTrackProjectRetargetingEvents(this, out _cookieProjectRetargeting) == VSConstants.S_OK)
                {
                    Debug.Assert(_cookieProjectRetargeting != 0);
                    _dte.Events.BuildEvents.OnBuildBegin    += BuildEvents_OnBuildBegin;
                    _dte.Events.SolutionEvents.AfterClosing += SolutionEvents_AfterClosing;
                }
                else
                {
                    _cookieProjectRetargeting = 0;
                }

                // Register for BatchRetargetingEvents. Using BatchRetargetingEvents, we need to detect platform retargeting
                if (_vsTrackProjectRetargeting.AdviseTrackBatchRetargetingEvents(this, out _cookieBatchRetargeting) == VSConstants.S_OK)
                {
                    Debug.Assert(_cookieBatchRetargeting != 0);
                    if (_cookieProjectRetargeting == 0)
                    {
                        // Register for dte Events only if they are not already registered for
                        _dte.Events.BuildEvents.OnBuildBegin    += BuildEvents_OnBuildBegin;
                        _dte.Events.SolutionEvents.AfterClosing += SolutionEvents_AfterClosing;
                    }
                }
                else
                {
                    _cookieBatchRetargeting = 0;
                }
            }
        }
 private OpenFileTracker(VisualStudioWorkspaceImpl workspace, IVsRunningDocumentTable runningDocumentTable, IComponentModel componentModel)
 {
     _workspace = workspace;
     _foregroundAffinitization         = new ForegroundThreadAffinitizedObject(workspace._threadingContext, assertIsForeground: true);
     _asyncOperationListener           = componentModel.GetService <IAsynchronousOperationListenerProvider>().GetListener(FeatureAttribute.Workspace);
     _runningDocumentTableEventTracker = new RunningDocumentTableEventTracker(workspace._threadingContext,
                                                                              componentModel.GetService <IVsEditorAdaptersFactoryService>(), runningDocumentTable, this);
 }
예제 #48
0
        public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel componentModel, IExperimentationService experimentationService) : base(optionStore)
        {
            _colorSchemeApplier = componentModel.GetService <ColorSchemeApplier>();

            InitializeComponent();

            BindToOption(Background_analysis_scope_active_file, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.ActiveFile, LanguageNames.CSharp);
            BindToOption(Background_analysis_scope_open_files, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.OpenFilesAndProjects, LanguageNames.CSharp);
            BindToOption(Background_analysis_scope_full_solution, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.FullSolution, LanguageNames.CSharp);
            BindToOption(Enable_navigation_to_decompiled_sources, FeatureOnOffOptions.NavigateToDecompiledSources);
            BindToOption(Use_64bit_analysis_process, RemoteHostOptions.OOP64Bit);
            BindToOption(Enable_file_logging_for_diagnostics, InternalDiagnosticsOptions.EnableFileLoggingForDiagnostics);
            BindToOption(Show_Remove_Unused_References_command_in_Solution_Explorer_experimental, FeatureOnOffOptions.OfferRemoveUnusedReferences, () =>
            {
                // If the option has not been set by the user, check if the option to remove unused references
                // is enabled from experimentation. If so, default to that. Otherwise default to disabled
                return(experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.RemoveUnusedReferences) ?? false);
            });

            BindToOption(PlaceSystemNamespaceFirst, GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
            BindToOption(SeparateImportGroups, GenerationOptions.SeparateImportDirectiveGroups, LanguageNames.CSharp);
            BindToOption(SuggestForTypesInReferenceAssemblies, SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp);
            BindToOption(SuggestForTypesInNuGetPackages, SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp);
            BindToOption(AddUsingsOnPaste, FeatureOnOffOptions.AddImportsOnPaste, LanguageNames.CSharp, () =>
            {
                // If the option has not been set by the user, check if the option to enable imports on paste
                // is enabled from experimentation. If so, default to that. Otherwise default to disabled
                return(experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.ImportsOnPasteDefaultEnabled) ?? false);
            });

            BindToOption(Split_string_literals_on_enter, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);

            BindToOption(EnterOutliningMode, FeatureOnOffOptions.Outlining, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_declaration_level_constructs, BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_code_level_constructs, BlockStructureOptions.ShowOutliningForCodeLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_comments_and_preprocessor_regions, BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, LanguageNames.CSharp);
            BindToOption(Collapse_regions_when_collapsing_to_definitions, BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp);

            BindToOption(Fade_out_unused_usings, FadingOptions.FadeOutUnusedImports, LanguageNames.CSharp);
            BindToOption(Fade_out_unreachable_code, FadingOptions.FadeOutUnreachableCode, LanguageNames.CSharp);

            BindToOption(Show_guides_for_declaration_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_guides_for_code_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, LanguageNames.CSharp);

            BindToOption(GenerateXmlDocCommentsForTripleSlash, DocumentationCommentOptions.AutoXmlDocCommentGeneration, LanguageNames.CSharp);
            BindToOption(InsertSlashSlashAtTheStartOfNewLinesWhenWritingSingleLineComments, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);
            BindToOption(InsertAsteriskAtTheStartOfNewLinesWhenWritingBlockComments, FeatureOnOffOptions.AutoInsertBlockCommentStartString, LanguageNames.CSharp);

            BindToOption(ShowRemarksInQuickInfo, QuickInfoOptions.ShowRemarksInQuickInfo, LanguageNames.CSharp);
            BindToOption(DisplayLineSeparators, FeatureOnOffOptions.LineSeparator, LanguageNames.CSharp);
            BindToOption(EnableHighlightReferences, FeatureOnOffOptions.ReferenceHighlighting, LanguageNames.CSharp);
            BindToOption(EnableHighlightKeywords, FeatureOnOffOptions.KeywordHighlighting, LanguageNames.CSharp);
            BindToOption(RenameTrackingPreview, FeatureOnOffOptions.RenameTrackingPreview, LanguageNames.CSharp);
            BindToOption(Enable_all_features_in_opened_files_from_source_generators, SourceGeneratedFileManager.EnableOpeningInWorkspace, () =>
            {
                // If the option has not been set by the user, check if the option is enabled from experimentation.
                // If so, default to that. Otherwise default to disabled
                return(experimentationService?.IsExperimentEnabled(WellKnownExperimentNames.SourceGeneratorsEnableOpeningInWorkspace) ?? false);
            });

            BindToOption(DontPutOutOrRefOnStruct, ExtractMethodOptions.DontPutOutOrRefOnStruct, LanguageNames.CSharp);

            BindToOption(with_other_members_of_the_same_kind, ImplementTypeOptions.InsertionBehavior, ImplementTypeInsertionBehavior.WithOtherMembersOfTheSameKind, LanguageNames.CSharp);
            BindToOption(at_the_end, ImplementTypeOptions.InsertionBehavior, ImplementTypeInsertionBehavior.AtTheEnd, LanguageNames.CSharp);

            BindToOption(prefer_throwing_properties, ImplementTypeOptions.PropertyGenerationBehavior, ImplementTypePropertyGenerationBehavior.PreferThrowingProperties, LanguageNames.CSharp);
            BindToOption(prefer_auto_properties, ImplementTypeOptions.PropertyGenerationBehavior, ImplementTypePropertyGenerationBehavior.PreferAutoProperties, LanguageNames.CSharp);

            BindToOption(Report_invalid_placeholders_in_string_dot_format_calls, ValidateFormatStringOption.ReportInvalidPlaceholdersInStringDotFormatCalls, LanguageNames.CSharp);

            BindToOption(Colorize_regular_expressions, RegularExpressionsOptions.ColorizeRegexPatterns, LanguageNames.CSharp);
            BindToOption(Report_invalid_regular_expressions, RegularExpressionsOptions.ReportInvalidRegexPatterns, LanguageNames.CSharp);
            BindToOption(Highlight_related_components_under_cursor, RegularExpressionsOptions.HighlightRelatedRegexComponentsUnderCursor, LanguageNames.CSharp);
            BindToOption(Show_completion_list, RegularExpressionsOptions.ProvideRegexCompletions, LanguageNames.CSharp);

            BindToOption(Editor_color_scheme, ColorSchemeOptions.ColorScheme);

            BindToOption(DisplayAllHintsWhilePressingAltF1, InlineHintsOptions.DisplayAllHintsWhilePressingAltF1);
            BindToOption(ColorHints, InlineHintsOptions.ColorHints, LanguageNames.CSharp);

            BindToOption(DisplayInlineParameterNameHints, InlineHintsOptions.EnabledForParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForLiterals, InlineHintsOptions.ForLiteralParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForNewExpressions, InlineHintsOptions.ForObjectCreationParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForEverythingElse, InlineHintsOptions.ForOtherParameters, LanguageNames.CSharp);
            BindToOption(SuppressHintsWhenParameterNameMatchesTheMethodsIntent, InlineHintsOptions.SuppressForParametersThatMatchMethodIntent, LanguageNames.CSharp);
            BindToOption(SuppressHintsWhenParameterNamesDifferOnlyBySuffix, InlineHintsOptions.SuppressForParametersThatDifferOnlyBySuffix, LanguageNames.CSharp);

            BindToOption(DisplayInlineTypeHints, InlineHintsOptions.EnabledForTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForVariablesWithInferredTypes, InlineHintsOptions.ForImplicitVariableTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForLambdaParameterTypes, InlineHintsOptions.ForLambdaParameterTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForImplicitObjectCreation, InlineHintsOptions.ForImplicitObjectCreation, LanguageNames.CSharp);
        }
예제 #49
0
 private INuGetProjectServices CreateCoreProjectSystemServices(
     IVsProjectAdapter vsProjectAdapter, IComponentModel componentModel)
 {
     return(new VsManagedLanguagesProjectSystemServices(vsProjectAdapter, componentModel));
 }
 public AbstractVsTextViewFilter(
     IWpfTextView wpfTextView,
     IComponentModel componentModel)
     : base(wpfTextView, componentModel)
 {
 }
예제 #51
0
        public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel componentModel) : base(optionStore)
        {
            _colorSchemeApplier = componentModel.GetService <ColorSchemeApplier>();

            InitializeComponent();

            BindToOption(Background_analysis_scope_active_file, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.ActiveFile, LanguageNames.CSharp);
            BindToOption(Background_analysis_scope_open_files, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.OpenFilesAndProjects, LanguageNames.CSharp);
            BindToOption(Background_analysis_scope_full_solution, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.FullSolution, LanguageNames.CSharp);
            BindToOption(Enable_navigation_to_decompiled_sources, FeatureOnOffOptions.NavigateToDecompiledSources);
            BindToOption(Run_code_analysis_in_separate_process, RemoteHostOptions.OOP64Bit);
            BindToOption(Enable_file_logging_for_diagnostics, InternalDiagnosticsOptions.EnableFileLoggingForDiagnostics);
            BindToOption(Skip_analyzers_for_implicitly_triggered_builds, FeatureOnOffOptions.SkipAnalyzersForImplicitlyTriggeredBuilds);
            BindToOption(Show_Remove_Unused_References_command_in_Solution_Explorer_experimental, FeatureOnOffOptions.OfferRemoveUnusedReferences, () =>
            {
                // If the option has not been set by the user, check if the option to remove unused references
                // is enabled from experimentation. If so, default to that.
                return(optionStore.GetOption(FeatureOnOffOptions.OfferRemoveUnusedReferencesFeatureFlag));
            });

            BindToOption(PlaceSystemNamespaceFirst, GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
            BindToOption(SeparateImportGroups, GenerationOptions.SeparateImportDirectiveGroups, LanguageNames.CSharp);
            BindToOption(SuggestForTypesInReferenceAssemblies, SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp);
            BindToOption(SuggestForTypesInNuGetPackages, SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp);
            BindToOption(AddUsingsOnPaste, FeatureOnOffOptions.AddImportsOnPaste, LanguageNames.CSharp, () =>
            {
                // This option used to be backed by an experimentation flag but is no longer.
                // Having the option still a bool? keeps us from running into storage related issues,
                // but if the option was stored as null we want it to respect this default
                return(false);
            });

            BindToOption(Split_string_literals_on_enter, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);

            BindToOption(EnterOutliningMode, FeatureOnOffOptions.Outlining, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_declaration_level_constructs, BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_code_level_constructs, BlockStructureOptions.ShowOutliningForCodeLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_comments_and_preprocessor_regions, BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, LanguageNames.CSharp);
            BindToOption(Collapse_regions_when_collapsing_to_definitions, BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp);

            BindToOption(Fade_out_unused_usings, FadingOptions.FadeOutUnusedImports, LanguageNames.CSharp);
            BindToOption(Fade_out_unreachable_code, FadingOptions.FadeOutUnreachableCode, LanguageNames.CSharp);

            BindToOption(Show_guides_for_declaration_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_guides_for_code_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, LanguageNames.CSharp);

            BindToOption(GenerateXmlDocCommentsForTripleSlash, DocumentationCommentOptions.AutoXmlDocCommentGeneration, LanguageNames.CSharp);
            BindToOption(InsertSlashSlashAtTheStartOfNewLinesWhenWritingSingleLineComments, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);
            BindToOption(InsertAsteriskAtTheStartOfNewLinesWhenWritingBlockComments, FeatureOnOffOptions.AutoInsertBlockCommentStartString, LanguageNames.CSharp);

            BindToOption(ShowRemarksInQuickInfo, QuickInfoOptions.ShowRemarksInQuickInfo, LanguageNames.CSharp);
            BindToOption(DisplayLineSeparators, FeatureOnOffOptions.LineSeparator, LanguageNames.CSharp);

            // Quick Actions
            BindToOption(ComputeQuickActionsAsynchronouslyExperimental, SuggestionsOptions.Asynchronous, () =>
            {
                // If the option has not been set by the user, check if the option is enabled from experimentation.
                // If so, default to that.
                return(optionStore.GetOption(SuggestionsOptions.AsynchronousFeatureFlag));
            });

            // Highlighting
            BindToOption(EnableHighlightReferences, FeatureOnOffOptions.ReferenceHighlighting, LanguageNames.CSharp);
            BindToOption(EnableHighlightKeywords, FeatureOnOffOptions.KeywordHighlighting, LanguageNames.CSharp);

            BindToOption(RenameTrackingPreview, FeatureOnOffOptions.RenameTrackingPreview, LanguageNames.CSharp);
            BindToOption(Underline_reassigned_variables, ClassificationOptions.ClassifyReassignedVariables, LanguageNames.CSharp);
            BindToOption(Enable_all_features_in_opened_files_from_source_generators, SourceGeneratedFileManager.Options.EnableOpeningInWorkspace, () =>
            {
                // If the option has not been set by the user, check if the option is enabled from experimentation.
                // If so, default to that.
                return(optionStore.GetOption(SourceGeneratedFileManager.Options.EnableOpeningInWorkspaceFeatureFlag));
            });

            BindToOption(DontPutOutOrRefOnStruct, ExtractMethodOptions.DontPutOutOrRefOnStruct, LanguageNames.CSharp);

            BindToOption(with_other_members_of_the_same_kind, ImplementTypeOptions.InsertionBehavior, ImplementTypeInsertionBehavior.WithOtherMembersOfTheSameKind, LanguageNames.CSharp);
            BindToOption(at_the_end, ImplementTypeOptions.InsertionBehavior, ImplementTypeInsertionBehavior.AtTheEnd, LanguageNames.CSharp);

            BindToOption(prefer_throwing_properties, ImplementTypeOptions.PropertyGenerationBehavior, ImplementTypePropertyGenerationBehavior.PreferThrowingProperties, LanguageNames.CSharp);
            BindToOption(prefer_auto_properties, ImplementTypeOptions.PropertyGenerationBehavior, ImplementTypePropertyGenerationBehavior.PreferAutoProperties, LanguageNames.CSharp);

            BindToOption(Report_invalid_placeholders_in_string_dot_format_calls, ValidateFormatStringOption.ReportInvalidPlaceholdersInStringDotFormatCalls, LanguageNames.CSharp);

            BindToOption(Colorize_regular_expressions, RegularExpressionsOptions.ColorizeRegexPatterns, LanguageNames.CSharp);
            BindToOption(Report_invalid_regular_expressions, RegularExpressionsOptions.ReportInvalidRegexPatterns, LanguageNames.CSharp);
            BindToOption(Highlight_related_components_under_cursor, RegularExpressionsOptions.HighlightRelatedRegexComponentsUnderCursor, LanguageNames.CSharp);
            BindToOption(Show_completion_list, RegularExpressionsOptions.ProvideRegexCompletions, LanguageNames.CSharp);

            BindToOption(Editor_color_scheme, ColorSchemeOptions.ColorScheme);

            BindToOption(DisplayAllHintsWhilePressingAltF1, InlineHintsOptions.DisplayAllHintsWhilePressingAltF1);
            BindToOption(ColorHints, InlineHintsOptions.ColorHints, LanguageNames.CSharp);

            BindToOption(DisplayInlineParameterNameHints, InlineHintsOptions.EnabledForParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForLiterals, InlineHintsOptions.ForLiteralParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForNewExpressions, InlineHintsOptions.ForObjectCreationParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForEverythingElse, InlineHintsOptions.ForOtherParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForIndexers, InlineHintsOptions.ForIndexerParameters, LanguageNames.CSharp);
            BindToOption(SuppressHintsWhenParameterNameMatchesTheMethodsIntent, InlineHintsOptions.SuppressForParametersThatMatchMethodIntent, LanguageNames.CSharp);
            BindToOption(SuppressHintsWhenParameterNamesDifferOnlyBySuffix, InlineHintsOptions.SuppressForParametersThatDifferOnlyBySuffix, LanguageNames.CSharp);

            BindToOption(DisplayInlineTypeHints, InlineHintsOptions.EnabledForTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForVariablesWithInferredTypes, InlineHintsOptions.ForImplicitVariableTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForLambdaParameterTypes, InlineHintsOptions.ForLambdaParameterTypes, LanguageNames.CSharp);
            BindToOption(ShowHintsForImplicitObjectCreation, InlineHintsOptions.ForImplicitObjectCreation, LanguageNames.CSharp);

            // Leave the null converter here to make sure if the option value is get from the storage (if it is null), the feature will be enabled
            BindToOption(ShowInheritanceMargin, FeatureOnOffOptions.ShowInheritanceMargin, LanguageNames.CSharp, () => true);
            BindToOption(InheritanceMarginCombinedWithIndicatorMargin, FeatureOnOffOptions.InheritanceMarginCombinedWithIndicatorMargin);
        }
예제 #52
0
 public MockServiceProvider(IComponentModel componentModel)
 {
     ComponentModel = componentModel;
     Services[typeof(SComponentModel).GUID] = componentModel;
 }
예제 #53
0
 public VisualStudioAbstraction(DTE dte, IComponentModel componentModel = null, IWpfTextView textView = null)
 {
     this.dte            = dte ?? throw new ArgumentNullException(nameof(dte));
     this.componentModel = componentModel;
     this.textView       = textView;
 }
        /// <summary>
        /// Fetches a MEF registered service if available.
        /// This method should be called from a background thread only.
        /// </summary>
        /// <typeparam name="TService"></typeparam>
        /// <returns>The instance of the service request, <see langword="null"/> otherwise. </returns>
        /// <remarks>
        /// This method should only be preferred when using MEF imports is not easily achievable.
        /// Prefer this over <see cref="GetInstanceAsync{TService}"/> when the service requesting a MEF service.
        /// A general rule is that internal NuGet services should call this method over <see cref="GetInstanceAsync{TService}"/>.
        /// This method can be called from the UI thread, but that's unnecessary and a bad practice. Never do things that don't need the UI thread, on the UI thread.
        /// </remarks>
        public static async Task <TService> GetComponentModelServiceAsync <TService>() where TService : class
        {
            IComponentModel componentModel = await GetGlobalServiceFreeThreadedAsync <SComponentModel, IComponentModel>();

            return(componentModel?.GetService <TService>());
        }
        public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel componentModel) : base(optionStore)
        {
            _colorSchemeApplier = componentModel.GetService <ColorSchemeApplier>();

            InitializeComponent();

            BindToOption(Background_analysis_scope_active_file, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.ActiveFile, LanguageNames.CSharp);
            BindToOption(Background_analysis_scope_open_files, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.OpenFilesAndProjects, LanguageNames.CSharp);
            BindToOption(Background_analysis_scope_full_solution, SolutionCrawlerOptions.BackgroundAnalysisScopeOption, BackgroundAnalysisScope.FullSolution, LanguageNames.CSharp);
            BindToOption(Enable_navigation_to_decompiled_sources, FeatureOnOffOptions.NavigateToDecompiledSources);
            BindToOption(Use_64bit_analysis_process, RemoteHostOptions.OOP64Bit);

            BindToOption(PlaceSystemNamespaceFirst, GenerationOptions.PlaceSystemNamespaceFirst, LanguageNames.CSharp);
            BindToOption(SeparateImportGroups, GenerationOptions.SeparateImportDirectiveGroups, LanguageNames.CSharp);
            BindToOption(SuggestForTypesInReferenceAssemblies, SymbolSearchOptions.SuggestForTypesInReferenceAssemblies, LanguageNames.CSharp);
            BindToOption(SuggestForTypesInNuGetPackages, SymbolSearchOptions.SuggestForTypesInNuGetPackages, LanguageNames.CSharp);
            BindToOption(Split_string_literals_on_enter, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);

            BindToOption(EnterOutliningMode, FeatureOnOffOptions.Outlining, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_declaration_level_constructs, BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_code_level_constructs, BlockStructureOptions.ShowOutliningForCodeLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_outlining_for_comments_and_preprocessor_regions, BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, LanguageNames.CSharp);
            BindToOption(Collapse_regions_when_collapsing_to_definitions, BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp);

            BindToOption(Fade_out_unused_usings, FadingOptions.FadeOutUnusedImports, LanguageNames.CSharp);
            BindToOption(Fade_out_unreachable_code, FadingOptions.FadeOutUnreachableCode, LanguageNames.CSharp);

            BindToOption(Show_guides_for_declaration_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, LanguageNames.CSharp);
            BindToOption(Show_guides_for_code_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, LanguageNames.CSharp);

            BindToOption(GenerateXmlDocCommentsForTripleSlash, FeatureOnOffOptions.AutoXmlDocCommentGeneration, LanguageNames.CSharp);
            BindToOption(InsertSlashSlashAtTheStartOfNewLinesWhenWritingSingleLineComments, SplitStringLiteralOptions.Enabled, LanguageNames.CSharp);
            BindToOption(InsertAsteriskAtTheStartOfNewLinesWhenWritingBlockComments, FeatureOnOffOptions.AutoInsertBlockCommentStartString, LanguageNames.CSharp);

            BindToOption(DisplayInlineParameterNameHints, InlineHintsOptions.EnabledForParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForLiterals, InlineHintsOptions.ForLiteralParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForNewExpressions, InlineHintsOptions.ForObjectCreationParameters, LanguageNames.CSharp);
            BindToOption(ShowHintsForEverythingElse, InlineHintsOptions.ForOtherParameters, LanguageNames.CSharp);

            BindToOption(ShowRemarksInQuickInfo, QuickInfoOptions.ShowRemarksInQuickInfo, LanguageNames.CSharp);
            BindToOption(DisplayLineSeparators, FeatureOnOffOptions.LineSeparator, LanguageNames.CSharp);
            BindToOption(EnableHighlightReferences, FeatureOnOffOptions.ReferenceHighlighting, LanguageNames.CSharp);
            BindToOption(EnableHighlightKeywords, FeatureOnOffOptions.KeywordHighlighting, LanguageNames.CSharp);
            BindToOption(RenameTrackingPreview, FeatureOnOffOptions.RenameTrackingPreview, LanguageNames.CSharp);

            BindToOption(DontPutOutOrRefOnStruct, ExtractMethodOptions.DontPutOutOrRefOnStruct, LanguageNames.CSharp);

            BindToOption(with_other_members_of_the_same_kind, ImplementTypeOptions.InsertionBehavior, ImplementTypeInsertionBehavior.WithOtherMembersOfTheSameKind, LanguageNames.CSharp);
            BindToOption(at_the_end, ImplementTypeOptions.InsertionBehavior, ImplementTypeInsertionBehavior.AtTheEnd, LanguageNames.CSharp);

            BindToOption(prefer_throwing_properties, ImplementTypeOptions.PropertyGenerationBehavior, ImplementTypePropertyGenerationBehavior.PreferThrowingProperties, LanguageNames.CSharp);
            BindToOption(prefer_auto_properties, ImplementTypeOptions.PropertyGenerationBehavior, ImplementTypePropertyGenerationBehavior.PreferAutoProperties, LanguageNames.CSharp);

            BindToOption(Report_invalid_placeholders_in_string_dot_format_calls, ValidateFormatStringOption.ReportInvalidPlaceholdersInStringDotFormatCalls, LanguageNames.CSharp);

            BindToOption(Colorize_regular_expressions, RegularExpressionsOptions.ColorizeRegexPatterns, LanguageNames.CSharp);
            BindToOption(Report_invalid_regular_expressions, RegularExpressionsOptions.ReportInvalidRegexPatterns, LanguageNames.CSharp);
            BindToOption(Highlight_related_components_under_cursor, RegularExpressionsOptions.HighlightRelatedRegexComponentsUnderCursor, LanguageNames.CSharp);
            BindToOption(Show_completion_list, RegularExpressionsOptions.ProvideRegexCompletions, LanguageNames.CSharp);

            BindToOption(Editor_color_scheme, ColorSchemeOptions.ColorScheme);
        }
예제 #56
0
 public PreviewEngine(IThreadingContext threadingContext, string title, string helpString, string description, string topLevelItemName, Glyph topLevelGlyph, Solution newSolution, Solution oldSolution, IComponentModel componentModel, bool showCheckBoxes = true)
     : this(threadingContext, title, helpString, description, topLevelItemName, topLevelGlyph, newSolution, oldSolution, componentModel, null, showCheckBoxes)
 {
 }
예제 #57
0
 public BraceMatcher(ITextView view, IComponentModel componentModel)
 {
     _textView  = view;
     _compModel = componentModel;
 }