I have many many functions (100+ estimated) and more then half are only needed in the file its defined. Is there a way to define functions so it scope is at a file level?
No. There's no way to restrict access to a single "file". You can put all the functions in a single class and make the ones you want to protect private
. Alternatively, you may put all the functions inside another assembly and make the protected ones internal
.
You can restrict scope to an assembly using internal
, but not to file level.
Firstly; C# has methods, not functions ;-p
Methods are scoped to the type; if you are trying to restrict to a file, can I therefore assume that this is a partial class (or maybe a set of nested types) that is (/are) split over multiple files? If not (and it is a single file) just make the methods private. If it is currently partial, then no: there is no way to avoid cross-calling between different files that are the same type. You could create some nested static types per partial portion, but that seems ugly, hacky, and just wrong.
If it isn't actively hurting you - perhaps don't change it?