This post originated from an RSS feed registered with .NET Buzz
by Adrian Florea.
Original Post: The following custom attribute is added automatically
Feed Title: Web Log di Adrian Florea
Feed URL: /error.aspx?aspxerrorpath=/adrian/Rss.aspx
Feed Description: "You know you've achieved perfection in design, not when you have nothing more to add, but when you have nothing more to take away." Antoine de Saint-Exupery
cioè i parametri isJITTrackingEnabled e isJITOptimizerDisabled a false, ottenete in C# l'errore CS0647:
error CS0647: Error emitting 'System.Diagnostics.DebuggableAttribute' attribute -- 'Assembly custom attribute 'System.Diagnostics.DebuggableAttribute' was specified multiple times with different values'
Questo perché il compilatore emette comunque questo attributo! - bisogna quindi avere coerenza tra le opzioni di compilazione e le eventuali decorazioni dell'assembly.
Un'altra prova? Il seguente snippet non compila:
namespace System.Diagnostics { class DebuggableAttribute{} }
se compilato semplicemente con:
csc /t:library foo.cs
però compila se compilato con:
csc /t:library /debug- /o+ foo.cs
L'errore che si ottiene nel primo caso è CS1501:
error CS1501: No overload for method 'DebuggableAttribute' takes '2' arguments
appunto perché "il nuovo" DebuggableAttribute (non quello di mscorlib) non ha un costruttore con due parametri.
Mi sono risposto così alla domanda di un altro mio post di qualche mese fa.