Naming convention of local functions? #8852
-
Hi, I've been wondering whether local functions should be named in camelCase or PascalCase. My personal preference and sense strongly leans toward camelCase, the reason is that a local function is a "local lambda variable". But there is no clear convention about it and even the docs sample code as well as local functions throghout the BCL appear to be mixed and non-conventional. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There is no set convention on this. Roslyn compiler, for example, uses camelCase, as it views these just as locals, and locals are camelCased names. Roslyn IDE, on the other hand, used PascalCase to distinguish non-captured local-functions vs captured delegates. That way casing can indicacte if you expect this to just be a function that is called, versus a delegate instance that will be allocated and passed around. Use whatever you prefer. |
Beta Was this translation helpful? Give feedback.
There is no set convention on this. Roslyn compiler, for example, uses camelCase, as it views these just as locals, and locals are camelCased names.
Roslyn IDE, on the other hand, used PascalCase to distinguish non-captured local-functions vs captured delegates. That way casing can indicacte if you expect this to just be a function that is called, versus a delegate instance that will be allocated and passed around.
Use whatever you prefer.