예제 #1
0
        private Task CheckResultAsync(
            string text,
            int position,
            bool absent,
            CSharpParseOptions options,
            int?matchPriority
            )
        {
            var tree        = SyntaxFactory.ParseSyntaxTree(text, options: options);
            var compilation = CSharpCompilation.Create(
                "test",
                syntaxTrees: new[] { tree },
                references: new[] { TestMetadata.Net451.mscorlib }
                );

            if (tree.IsInNonUserCode(position, CancellationToken.None) && !absent)
            {
                Assert.False(true, "Wanted keyword, but in non-user code position: " + keywordText);
            }

            var semanticModel = compilation.GetSemanticModel(tree);
            var context       = CSharpSyntaxContext.CreateContext_Test(
                semanticModel,
                position,
                CancellationToken.None
                );

            return(CheckResultAsync(absent, position, context, matchPriority));
        }
예제 #2
0
        private void CheckResult(string text, int position, bool absent, CSharpParseOptions options)
        {
            var tree        = SyntaxFactory.ParseSyntaxTree(text, options: options);
            var compilation = CSharpCompilation.Create(
                "test",
                syntaxTrees: new[] { tree },
                references: new[] { TestReferences.NetFx.v4_0_30319.mscorlib });

            if (tree.IsInNonUserCode(position, CancellationToken.None) && !absent)
            {
                Assert.False(true, "Wanted keyword, but in non-user code position: " + keywordText);
            }

            var semanticModel = compilation.GetSemanticModel(tree);
            var context       = CSharpSyntaxContext.CreateContext_Test(semanticModel, position, CancellationToken.None);

            CheckResult(absent, position, context, semanticModel);
        }