Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The file access modifier is only valid on top-level types #40867

Open
BillWagner opened this issue May 13, 2024 · 5 comments
Open

The file access modifier is only valid on top-level types #40867

BillWagner opened this issue May 13, 2024 · 5 comments
Assignees
Labels
doc-bug Problem with the content; needs to be fixed [org][type][category] dotnet-csharp/svc fundamentals/subsvc help wanted Good for community contributors to help [up-for-grabs] okr-health Content-health KR: Concerns article defects/freshness or build warnings. Pri1 High priority, do before Pri2 and Pri3

Comments

@BillWagner
Copy link
Member

Type of issue

Typo

Description

In a couple sentences, the description of the file access modifier could be used on "members", either nested types or member fields, properties, or methods. Neither is allowed. The file access modifier is allowed only on top-level (non-nested) type declarations.

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/classes-and-structs/access-modifiers.md

Document Version Independent Id

76a389f6-b568-3568-6483-6df440f96f0c

Article author

@BillWagner

Metadata

  • ID: 8121f526-cfe4-091d-d031-2cdc274cd8ee
  • Service: dotnet-csharp
  • Sub-service: fundamentals
@issues-automation issues-automation bot added dotnet-csharp/svc fundamentals/subsvc Pri1 High priority, do before Pri2 and Pri3 labels May 13, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label May 13, 2024
@BillWagner BillWagner added help wanted Good for community contributors to help [up-for-grabs] doc-bug Problem with the content; needs to be fixed [org][type][category] labels May 14, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label May 14, 2024
@dotnet-policy-service dotnet-policy-service bot added the okr-health Content-health KR: Concerns article defects/freshness or build warnings. label May 14, 2024
@bigboybamo
Copy link
Contributor

Hi @BillWagner I'd like to pick this up but i'm not sure i fully understand the context of what needs to be done.

@BillWagner
Copy link
Member Author

Hi @bigboybamo

The distinction we're missing is that the file access modifier is not allowed on any nested types:

// This is legal:
file class C
{
    // ...
}

public class C2
{
    // This is not allowed. C3 is not a top level type.
    file class C3
    {
        // ...
    }
}

Let me know if you need more details.
I've assigned this issue to you.

@bigboybamo
Copy link
Contributor

Hi @BillWagner I've checked again.
I didn't see any section where the file example is defined in https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers which is why I said I wasn't sure earlier

@BillWagner
Copy link
Member Author

Hi @bigboybamo

file access isn't super common, so I only added it to the language reference here: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/file

@bigboybamo
Copy link
Contributor

Hi @BillWagner I opened a PR #41399. I didn't add the example code because it would cause a build warning. Unless there's some other way to illustrate that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-bug Problem with the content; needs to be fixed [org][type][category] dotnet-csharp/svc fundamentals/subsvc help wanted Good for community contributors to help [up-for-grabs] okr-health Content-health KR: Concerns article defects/freshness or build warnings. Pri1 High priority, do before Pri2 and Pri3
Projects
None yet
Development

No branches or pull requests

3 participants