This could be either for the .NET or Mono compilers.
I know that under certain conditions the compiler can inline functions (e.g. small, single call site, etc.) as an optimization. However, if the function is public, then it needs to have an external entry point.
In these cases, is duplicated code generated (public entry point which isn't used by the internal code since the internal code uses the inlined version), or does marking it as public prevent the compiler from doing such an optimization?
Best Answer
I found this interesting article on C# inline methods.
Scope of a method doesn't appear to change when a function becomes an inline candidate. Here is a summary of that article.
There is no
inline
keyword in C#, but there is an inline compiler directive that was introduced in .NET 4.5 called MethodImplOptions.AggressiveInliningIt can be used like this.
You can't know for sure if the compiler will inline a function. This isn't feature C# developers have control over.