Поделиться через


/debug, /optimize

MSDN has articles about these two compiler switches. However, people have been always confused by the statements in this article. What does that exactly mean? Following are some experiment results for your references.

BTW, here is a great post cover more details around this topic.

Hope this helps,

Command

PDB?

DebuggableAttribute

Csc Program.cs

No

No

Csc Program.cs /debug

Yes

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default)]

Csc Program.cs /debug+

Csc Program.cs /debug:full

Csc Program.cs /debug:pdbonly

Yes

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]

Csc Program.cs /optimize

No

No

Csc Program.cs /optimize+

Csc Program.cs /debug /optimize

Yes

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default)]

Csc Program.cs /debug:pdbonly /optimize

Yes

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]