<commit_before>﻿// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
    public class AccessTests : CSharpTestBase
    {
        // Namespaces implicitly have public declared accessibility.
        [Fact]
        public void Access_3_5_1_a()
        {
            var text =
@"
namespace A {}
";
            var tree = Parse(text);
            var comp = CreateCompilation(tree);
            var global = comp.GlobalNamespace;
            var a = global.GetMembers("A").Single() as NamespaceSymbol;
            Assert.Equal(Accessibility.Public, a.DeclaredAccessibility);
            var errs = comp.GetSemanticModel(tree).GetDeclarationDiagnostics();
            Assert.Equal(0, errs.Count());
        }

        // No access modifiers are allowed on namespace declarations
        [Fact]
        public void Access_3_5_1_b()
        {
            var text =
@"
public namespace A {}
";
            var tree = Parse(text);
            var comp = CreateCompilation(tree);
            var global = comp.GlobalNamespace;
            var a = global.GetMembers("A").Single() as NamespaceSymbol;
            var errs = tree.GetDiagnostics();
            Assert.Equal(0, errs.Count());

            comp.VerifyDiagnostics(
                Diagnostic(ErrorCode.ERR_BadModifiersOnNamespace, "public").WithLocation(2, 1));
        }

        // Types declared in compilation units or namespaces can have public or internal declared accessibility.
        [Fact]<commit_msg>Add docs<commit_after>﻿// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Test.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
    public class AccessTests : CSharpTestBase
    {
        // Namespaces implicitly have public declared accessibility.
        [Fact]
        public void Access_3_5_1_a()
        {
            var text =
@"
namespace A {}
";
            var tree = Parse(text);
            var comp = CreateCompilation(tree);
            var global = comp.GlobalNamespace;
            var a = global.GetMembers("A").Single() as NamespaceSymbol;
            Assert.Equal(Accessibility.Public, a.DeclaredAccessibility);
            var errs = comp.GetSemanticModel(tree).GetDeclarationDiagnostics();
            Assert.Equal(0, errs.Count());
        }

        // No access modifiers are allowed on namespace declarations
        [Fact]
        public void Access_3_5_1_b()
        {
            var text =
@"
public namespace A {}
";
            var tree = Parse(text);
            var comp = CreateCompilation(tree);
            var global = comp.GlobalNamespace;
            var a = global.GetMembers("A").Single() as NamespaceSymbol;
            var errs = tree.GetDiagnostics();
            Assert.Equal(0, errs.Count());

            comp.VerifyDiagnostics(
                // (2,1): error CS1671: A namespace declaration cannot have modifiers or attributes
                // public namespace A {}
                Diagnostic(ErrorCode.ERR_BadModifiersOnNamespace, "public").WithLocation(2, 1));
        }

        // Types declared in compilation units or namespaces can have public or internal declared accessibility.
        [Fact]
{'fraction_non_alphanumeric': 0.0914034179181771, 'fraction_numerical': 0.007767995857068877, 'mean_word_length': 2.4460303300624444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6719365', 'n_tokens_mistral': 1013, 'n_tokens_neox': 991, 'n_words': 281}