コード例 #1
0
        public void ChangeSignatureCommandDisabledInSubmission()
        {
            var exportProvider = ExportProviderCache
                                 .GetOrCreateExportProviderFactory(
                TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic.WithParts(typeof(InteractiveSupportsFeatureService.InteractiveTextBufferSupportsFeatureService)))
                                 .CreateExportProvider();

            using var workspace = TestWorkspace.Create(XElement.Parse(@"
                <Workspace>
                    <Submission Language=""C#"" CommonReferences=""true"">  
                        class C
                        {
                            void M$$(int x)
                            {
                            }
                        }
                    </Submission>
                </Workspace> "),
                                                       workspaceKind: WorkspaceKind.Interactive,
                                                       exportProvider: exportProvider);
            // Force initialization.
            workspace.GetOpenDocumentIds().Select(id => workspace.GetTestDocument(id).GetTextView()).ToList();

            var textView = workspace.Documents.Single().GetTextView();

            var handler = new CSharpChangeSignatureCommandHandler(workspace.GetService <IThreadingContext>());

            var state = handler.GetCommandState(new RemoveParametersCommandArgs(textView, textView.TextBuffer));

            Assert.True(state.IsUnspecified);

            state = handler.GetCommandState(new ReorderParametersCommandArgs(textView, textView.TextBuffer));
            Assert.True(state.IsUnspecified);
        }
コード例 #2
0
ファイル: RemoveParametersTests.cs プロジェクト: zouql/roslyn
        public void ChangeSignatureCommandDisabledInSubmission()
        {
            using var workspace = TestWorkspace.Create(XElement.Parse(@"
                <Workspace>
                    <Submission Language=""C#"" CommonReferences=""true"">  
                        class C
                        {
                            void M$$(int x)
                            {
                            }
                        }
                    </Submission>
                </Workspace> "),
                                                       workspaceKind: WorkspaceKind.Interactive,
                                                       composition: EditorTestCompositions.EditorFeaturesWpf);
            // Force initialization.
            workspace.GetOpenDocumentIds().Select(id => workspace.GetTestDocument(id).GetTextView()).ToList();

            var textView = workspace.Documents.Single().GetTextView();

            var handler = new CSharpChangeSignatureCommandHandler(workspace.GetService <IThreadingContext>());

            var state = handler.GetCommandState(new RemoveParametersCommandArgs(textView, textView.TextBuffer));

            Assert.True(state.IsUnspecified);

            state = handler.GetCommandState(new ReorderParametersCommandArgs(textView, textView.TextBuffer));
            Assert.True(state.IsUnspecified);
        }
コード例 #3
0
        public async Task ChangeSignatureCommandDisabledInSubmission()
        {
            var exportProvider = MinimalTestExportProvider.CreateExportProvider(
                TestExportProvider.EntireAssemblyCatalogWithCSharpAndVisualBasic.WithParts(typeof(InteractiveDocumentSupportsFeatureService)));

            using (var workspace = await TestWorkspace.CreateAsync(XElement.Parse(@"
                <Workspace>
                    <Submission Language=""C#"" CommonReferences=""true"">  
                        class C
                        {
                            void M$$(int x)
                            {
                            }
                        }
                    </Submission>
                </Workspace> "),
                                                                   workspaceKind: WorkspaceKind.Interactive,
                                                                   exportProvider: exportProvider))
            {
                // Force initialization.
                workspace.GetOpenDocumentIds().Select(id => workspace.GetTestDocument(id).GetTextView()).ToList();

                var textView = workspace.Documents.Single().GetTextView();

                var handler                     = new CSharpChangeSignatureCommandHandler(TestWaitIndicator.Default);
                var delegatedToNext             = false;
                Func <CommandState> nextHandler = () =>
                {
                    delegatedToNext = true;
                    return(CommandState.Unavailable);
                };

                var state = handler.GetCommandState(new Commands.RemoveParametersCommandArgs(textView, textView.TextBuffer), nextHandler);
                Assert.True(delegatedToNext);
                Assert.False(state.IsAvailable);

                delegatedToNext = false;
                state           = handler.GetCommandState(new Commands.ReorderParametersCommandArgs(textView, textView.TextBuffer), nextHandler);
                Assert.True(delegatedToNext);
                Assert.False(state.IsAvailable);
            }
        }