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

Access modifiers need reviewing #19

Open
bentorkington opened this issue Oct 4, 2022 · 1 comment
Open

Access modifiers need reviewing #19

bentorkington opened this issue Oct 4, 2022 · 1 comment

Comments

@bentorkington
Copy link
Collaborator

Generally, the public access modifier is overused in this project, which makes it difficult to determine which modifications will be safe and which will be breaking, as well as indicating which audience should be considered when documenting members.

Anything not expected to be exposed to end users should use the more restrictive modifiers internal, protected and private as appropriate.

The System.Runtime.CompilerServices.InternalsVisibleTo assembly attribute makes it possible for unit tests to access members that otherwise would be private-ish in a production library.

@maetl
Copy link
Contributor

maetl commented Oct 5, 2022

The System.Runtime.CompilerServices.InternalsVisibleTo assembly attribute makes it possible for unit tests to access members that otherwise would be private-ish in a production library.

Okay, that is a feature I haven’t had access to in other languages before and is something I can definitely see myself going too far with, but it offers some interesting opportunities to be much more tightly constrained and intentional about what is exposed and callable publicly.

I am fairly sure I have a solid mental model of which methods are supposed to be private and not part of the surface area of the library, so I can probably give quite direct advice here. The registry is a bit of a ‘god’ class so may be somewhat of an exception, but most things should have a clear audience and purpose and therefore a well-defined visibility level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants