private static MethodDeclarationContext CreateContext(string testInput, AnalyzerLanguage language, string methodName)
        {
            var testCode = new SnippetCompiler(testInput, false, language);
            var symbol   = testCode.GetMethodSymbol("Sample." + methodName);

            return(new MethodDeclarationContext(symbol, testCode.SemanticModel.Compilation));
        }
Esempio n. 2
0
        public void Symbol_IsPublicApi()
        {
            ISymbol symbol = testCode.GetMethodSymbol("Base.Method1");

            SymbolHelper.IsPubliclyAccessible(symbol).Should().BeTrue();

            symbol = testCode.GetMethodSymbol("Base.Method2");
            symbol.IsPubliclyAccessible().Should().BeTrue();

            symbol = testCode.GetPropertySymbol("Base.Property");
            symbol.IsPubliclyAccessible().Should().BeTrue();

            symbol = testCode.GetPropertySymbol("IInterface.Property2");
            symbol.IsPubliclyAccessible().Should().BeTrue();

            symbol = testCode.GetPropertySymbol("Derived1.Property");
            symbol.IsPubliclyAccessible().Should().BeFalse();
        }