Esempio n. 1
0
        public void Symbol_IsPublicApi()
        {
            var method = baseClassDeclaration.DescendantNodes().OfType <MethodDeclarationSyntax>()
                         .First(m => m.Identifier.ValueText == "Method1");
            var symbol = semanticModel.GetDeclaredSymbol(method);

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

            method = baseClassDeclaration.DescendantNodes().OfType <MethodDeclarationSyntax>()
                     .First(m => m.Identifier.ValueText == "Method2");
            symbol = semanticModel.GetDeclaredSymbol(method);

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

            var property = baseClassDeclaration.DescendantNodes().OfType <PropertyDeclarationSyntax>()
                           .First(m => m.Identifier.ValueText == "Property");

            symbol = semanticModel.GetDeclaredSymbol(property);

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

            property = interfaceDeclaration.DescendantNodes().OfType <PropertyDeclarationSyntax>()
                       .First(m => m.Identifier.ValueText == "Property2");
            symbol = semanticModel.GetDeclaredSymbol(property);

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

            property = derivedClassDeclaration1.DescendantNodes().OfType <PropertyDeclarationSyntax>()
                       .First(m => m.Identifier.ValueText == "Property");
            symbol = semanticModel.GetDeclaredSymbol(property);

            symbol.IsPubliclyAccessible().Should().BeFalse();
        }
Esempio n. 2
0
        public void Symbol_IsPublicApi()
        {
            ISymbol symbol = this.testCode.GetMethodSymbol("Base.Method1");

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

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

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

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

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