Search code examples
c#.netnamingcil

What are the naming rules for CIL Classes and Methods


And how do they differ from C#?

Is there any standard way of writing a name for a method in CIL that can not conflict with any C# method, as the CIL name is illegal in C#?

Could such a name cause issues with other .net languages such as F# or Visual Basic?

An example of a naming rule in C# is: Method2 is a legal name for a method in C#, but 2Method is an illegal method name since names cannot start with a digit, but may contain digits. What naming rules are there for CIL?

I'm writing an auto-generated method that is only used by Il, and I want to make sure it doesn't conflict with any C# name.


Solution

  • To write code that can interop with any .NET Language you follow the guidelines of the Common Language Specification, and ensure that your publicly-visible types are "CLS Compliant":

    To fully interact with other objects written in any language, objects must expose to callers only those features that are common to all languages. This common set of features is defined by the Common Language Specification (CLS), which is a set of rules that apply to generated assemblies. The Common Language Specification is defined in Partition I, Clauses 7 through 11 of the ECMA-335 Standard: Common Language Infrastructure.

    Language Independence and Language-Independent Components