Search code examples
c#optimization

What is /optimize C# compiler key intended for?


Is there a full list of optimizations done by the /optimize C# compiler key available anywhere?

EDIT: Why is it disabled by default? Is it worth using in a real-world app? -- it is disabled by default only in Debug configuration and Enabled in Release.


Solution

  • Scott Hanselman has a blog post that shows a few examples of what /optimize (which is enabled in Release Builds) does.

    As a summary: /optimize does many things with no exact number or definition given, but one of the more visible are method inlining (If you have a Method A() which calls B() which calls C() which calls D(), the compiler may "skip" B and C and go from A to D directly), which may cause a "weird" callstack in the Release build.