The Artima Developer Community
Sponsored Link

.NET Buzz Forum
The following custom attribute is added automatically

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Adrian Florea

Posts: 206
Nickname: adrian11
Registered: Jul, 2004

Adrian Florea is a .NET developer from Italy
The following custom attribute is added automatically Posted: Apr 25, 2005 7:12 PM
Reply to this message Reply

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
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Adrian Florea
Latest Posts From Web Log di Adrian Florea

Advertisement

Ve ne siete probabilmente accorti di questo commento nei vostri file IL disassemblati:

// --- The following custom attribute is added automatically, do not uncomment -------
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(bool, bool) = ( 01 00 00 01 00 00 )

Per farlo sparire basta compilare con le opzioni /debug- ("do not emit debugging information") e /o+ ("enable optimizations").

Interessante è il fatto che se non compilate con queste opzioni un assembly decorato con:

[assembly: System.Diagnostics.Debuggable(false, false)]

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.

Read: The following custom attribute is added automatically

Topic: Troubleshooting IIS SMTP issues Previous Topic   Next Topic Topic: INDA - Event Reminder - INDIGO - presented by Paul Fallon

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use