Example #1
0
        public void DontTriggerInAttributeConstructor_FirstArgument()
        {
            // Due to strange default behavior with suggestion non-static members

            const string source = @"
                public class Test {
                    [Some(]
                    public static bool DoSmth(Test testInstance)
                    {
                    }
                }

                public SomeAttribute : System.Attribute
                {
                    public SomeAttribute(string v) { }
                }";

            bool triggerCompletion = Provider.ShouldTriggerCompletion(
                text: SourceText.From(source),
                caretPosition: source.IndexOf("[Some(") + 6,
                trigger: CompletionTrigger.CreateInsertionTrigger('('),
                options: null);

            Assert.That(!triggerCompletion);
        }
Example #2
0
        public void TriggerCompletionAfterAssignment()
        {
            const string source = @"
                public class Test {
                    public static bool DoSmth(Test testInstance)
                    {
                        Test v1 = 
                    }
                }";

            bool triggerCompletion = Provider.ShouldTriggerCompletion(
                text: SourceText.From(source),
                caretPosition: source.IndexOf(" = ") + 3,
                trigger: CompletionTrigger.CreateInsertionTrigger(' '),
                options: null);

            Assert.That(triggerCompletion);
        }
Example #3
0
        private async Task VerifyTextualTriggerCharacterWorkerAsync(string markup, bool expectedTriggerCharacter, bool triggerOnLetter)
        {
            using (var workspace = await TestWorkspace.CreateCSharpAsync(markup))
            {
                var document = workspace.Documents.Single();
                var position = document.CursorPosition.Value;
                var text     = document.TextBuffer.CurrentSnapshot.AsText();
                var options  = workspace.Options.WithChangedOption(CompletionOptions.TriggerOnTypingLetters, LanguageNames.CSharp, triggerOnLetter);
                var trigger  = CompletionTrigger.CreateInsertionTrigger(text[position]);

                var isTextualTriggerCharacterResult = CompletionProvider.ShouldTriggerCompletion(text, position + 1, trigger, options);

                if (expectedTriggerCharacter)
                {
                    var assertText = "'" + text.ToString(new Microsoft.CodeAnalysis.Text.TextSpan(position, 1)) + "' expected to be textual trigger character";
                    Assert.True(isTextualTriggerCharacterResult, assertText);
                }
                else
                {
                    var assertText = "'" + text.ToString(new Microsoft.CodeAnalysis.Text.TextSpan(position, 1)) + "' expected to NOT be textual trigger character";
                    Assert.False(isTextualTriggerCharacterResult, assertText);
                }
            }
        }