Skip to content

Feature: Change Member Access Modifiers to Allow Inlining #12

@WalkerCodeRanger

Description

@WalkerCodeRanger

I find myself wishing that when I inline a method, I could change the visibility of things it refers to that need to be visible for the inline to work.

Two ways this could work:

  1. An option on the InlineAttribute that allows you to automatically promote the visibility of things referenced by the method being inlined. Most commonly, I expect to want to promote private to internal. But sometimes it may be necessary to promote to public.
  2. A separate attribute that is applied to the thing you want to change the access modifier on. This makes it more explicit.

Why not just make the member more accessible?

  • Because I want to enforce with the compiler that nothing should call the member except the method being inlined. For example, I have a private constructor that is called by a number of static factory methods. I don't want anyone to directly call the constructor because the factory methods exist to make it clear which case is being constructed and enforce certain limits. But all the factory methods are short and ought to be inlined. However, doing so requires that the constructor not be private.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions