OptimizationLevel Enum

Definition

Determines the level of optimization of the generated code.

C#
public enum OptimizationLevel
Inheritance
OptimizationLevel

Fields

Name Value Description
Debug 0

Disables all optimizations and instruments the generated code to improve debugging experience.

The compiler prefers debuggability over performance. Do not use for code running in a production environment.

  • JIT optimizations are disabled via assembly level attribute (DebuggableAttribute).
  • Edit and Continue is enabled.
  • Slots for local variables are not reused, lifetime of local variables is extended to make the values available during debugging.

Corresponds to command line argument /optimize-.

Release 1

Enables all optimizations, debugging experience might be degraded.

The compiler prefers performance over debuggability. Use for code running in a production environment.

  • JIT optimizations are enabled via assembly level attribute (DebuggableAttribute).
  • Edit and Continue is disabled.
  • Sequence points may be optimized away. As a result it might not be possible to place or hit a breakpoint.
  • User-defined locals might be optimized away. They might not be available while debugging.

Corresponds to command line argument /optimize+.

Applies to

Product Versions
Roslyn 4.2.0, 4.3.0, 4.4.0, 4.5.0, 4.6.0, 4.7.0, 4.8.0, 4.9.2, 3.0.0, 3.1.0, 3.2.0, 3.2.1, 3.3.1, 3.4.0, 3.5.0, 3.6.0, 3.7.0, 3.8.0, 3.9.0, 3.10.0, 3.11.0, 4.0.1, 4.1.0, 4.12.2, 4.13.0