.NET http://blogs.ugidotnet.org/andrew/category/.NET.aspx .NET it-IT Andrea Sansottera Subtext Version 2.6.0.0 C++ Express: compatibilità, terminazioni di linea e codifica Unicode http://blogs.ugidotnet.org/andrew/archive/2005/11/24/30490.aspx <P>Nelle ultime settimane mi sono imbattuto in tre features di Visual C++ Express.&nbsp;Sono caratteristiche&nbsp;poco "appariscenti", sulle quali sarebbe sprecato fare marketing, ma che si sono rivelate particolarmente utili.</P> <P>1. E' possibile aprire&nbsp;vecchi progetti per Visual C++ 6. La procedura di conversione &#232; pressoch&#232; indolore. Naturalmente, a causa degli allineamenti agli standard C++, &#232; possibile che il nuovo compilatore generi messaggi di avviso, indicando che vengono usati costrutti sintattici deprecati.</P> <P><IMG src="/images/blogs_ugidotnet_org/andrew/1627/o_visualCpp6_01.jpg"></P> <P>2.&nbsp;Durante l'apertura di un file, l'editor&nbsp;rileva automaticamente&nbsp;se la&nbsp;convenzione di terminazione linea &#232; consistente e, in caso contrario, propone un allineamento con lo standard per Windows, Unix o Macintosh.</P> <P><IMG src="/images/blogs_ugidotnet_org/andrew/1627/o_lineEndings_01.jpg"></P> <P>3. Per impostazione definita i file sorgenti vengono salvati con codifica a 8 bit. Tuttavia, durante l'editing &#232; possibile&nbsp;inserire caratteri Unicode. Al momento del salvataggio, verra chiesto se si vuole passare alla codifica Unicode a 16 bit&nbsp;o ad una diversa codifica ASCII estesa. E'&nbsp;inoltre possibile applicare la stessa scelta agli altri file del progetto.</P> <P><IMG src="/images/blogs_ugidotnet_org/andrew/1627/o_encoding_01.jpg"></P><img src="http://blogs.ugidotnet.org/andrew/aggbug/30490.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/11/24/30490.aspx Thu, 24 Nov 2005 16:33:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/11/24/30490.aspx#feedback http://blogs.ugidotnet.org/andrew/comments/commentRss/30490.aspx NUnit 2.2.3 http://blogs.ugidotnet.org/andrew/archive/2005/11/19/30213.aspx <P>E'&nbsp;stato rilasciato <A href="http://www.nunit.org">NUnit</A> <A href="http://nunit.com/blogs/?p=15">2.2.3</A>, una nuova "iteration release", che include significative correzioni di bugs e&nbsp;nuove asserzioni. E' possibile leggere le <A href="http://nunit.com/testweb/index.php?p=releaseNotes&amp;r=2.2.3">release notes</A> e scaricarlo a <A href="http://nunit.sf.net/">questo indirizzo</A>.&nbsp;Sebbene sia stato compilato&nbsp;con Visual Studio 2003,&nbsp;funziona sul runtime di .NET 2.0. In realt&#224;, anche con le versioni precedenti di NUnit, previa modifica del file di configurazione, non ho&nbsp;riscontrato problemi. La buona notizia &#232; che, passando&nbsp;una semplice opzione&nbsp;a linea di comando, &#232; ora possibile eseguire NUnit su una qualunque versione&nbsp;del framework disponibile sulla macchina.&nbsp;Altrimenti, per testare assembly creati con&nbsp;Visual Studio 2005,&nbsp;&#232; sufficiente&nbsp;decommentare la sezione "startup" <STARTUP />del file di configurazione "nunit-gui.exe.config". Happy testing! :)</P><img src="http://blogs.ugidotnet.org/andrew/aggbug/30213.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/11/19/30213.aspx Sat, 19 Nov 2005 16:57:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/11/19/30213.aspx#feedback http://blogs.ugidotnet.org/andrew/comments/commentRss/30213.aspx Cleanup deterministico e finalizers in C++/CLI http://blogs.ugidotnet.org/andrew/archive/2005/05/06/15704.aspx <FONT face=Verdana size=2> <P>Vediamo il seguente codice.&nbsp;Viene definito&nbsp;un reference type (typeid = <EM>Person</EM>), con un metodo publico, <EM>ReadMessage</EM>. Al suo interno viene utilizzato in tre modi diversi un oggetto di tipo <EM>System::IO::StreamReader</EM>, classe che implementa <EM>System::IDisposable</EM>.</P> <DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"><SPAN style="FONT-SIZE: 10pt; COLOR: #808080; FONT-FAMILY: Courier New">public&nbsp;</SPAN><SPAN style="COLOR: #006400; FONT-FAMILY: Courier New">ref&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New">class&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Person<BR></SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">{<BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #808080; FONT-FAMILY: Courier New">public</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">:<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">Person&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #006400; FONT-FAMILY: Courier New">String</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">name</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">,&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #006400; FONT-FAMILY: Courier New">String</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">surname</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New">void&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">ReadMessage&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #006400; FONT-FAMILY: Courier New">String</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">path</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Stream</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">stream&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Person::</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">typeid</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">)-&gt;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Assembly</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">-&gt;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">GetManifestResourceStream&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">path</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR><BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">#ifdef&nbsp;MANUAL_DETERMINISTIC_CLEANUP<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008080; FONT-FAMILY: Courier New">//&nbsp;I&nbsp;manually&nbsp;call&nbsp;the&nbsp;distructor.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">StreamReader</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008b8b; FONT-FAMILY: Courier New">gcnew&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">StreamReader&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">stream</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console::</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">-&gt;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">ReadLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008b8b; FONT-FAMILY: Courier New">delete&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">;<BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">#endif<BR><BR>#ifdef&nbsp;AUTOMATIC_CLEANUP<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008080; FONT-FAMILY: Courier New">//&nbsp;Garabace&nbsp;collector&nbsp;will&nbsp;call&nbsp;the&nbsp;dispose&nbsp;methods&nbsp;before&nbsp;finalizing&nbsp;the&nbsp;reader.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">StreamReader</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008b8b; FONT-FAMILY: Courier New">gcnew&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">StreamReader&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">stream</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console::</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">-&gt;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">ReadLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">());<BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">#endif<BR><BR>#ifdef&nbsp;AUTOMATIC_DETERMINISTIC_CLEANUP<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008080; FONT-FAMILY: Courier New">//&nbsp;The&nbsp;compiler&nbsp;automatic&nbsp;inserts&nbsp;a&nbsp;method&nbsp;call&nbsp;to&nbsp;dispose.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;The&nbsp;reference&nbsp;type&nbsp;instance&nbsp;has&nbsp;value&nbsp;semantic&nbsp;in&nbsp;this&nbsp;context.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">StreamReader&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">reader&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">stream</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console::</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">.</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">ReadLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">());<BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">#endif<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">}<BR>};<BR></DIV></SPAN> </FONT> <FONT face=Verdana size=2><P>Decompiliamo con <A title="" href="http://www.aisto.com/roeder/dotnet" target="" name="">Reflector</A> e vediamo come apparirebbe, nei diversi casi,&nbsp;il&nbsp;metodo <EM>ReadMessage</EM>&nbsp;se fosse scritto in C#.</P> <P>Nel primo caso <EM>reader </EM>è stato dichiarato come un&nbsp;handle, al quale&nbsp;abbiamo è stato assegnato un oggetto <STRONG>allocato sul managed heap</STRONG> tramite l'operatore <EM>gcnew</EM> .&nbsp;Dopo&nbsp;essere stato&nbsp;utilizzato, l'oggetto viene "distrutto"&nbsp;con l'<STRONG>operatore <EM>delete</EM></STRONG>. Tale operatore viene&nbsp;sostanzialmente <STRONG> tradotto in un'eventuale chiamata al metodo <EM>Dispose</EM></STRONG> (per gli oggetti il cui tipo implementa <EM>IDisposable</EM>*). Come noto, tale metodo nasce con lo scopo fondamentale di <STRONG>rilascare le risorse</STRONG> utilizzate dal nostro oggetto, <STRONG>non la memoria</STRONG>. La deallocazione sarà <STRONG>gestita dal garbage collector</STRONG>, che in questo caso, vedendo che è già stato eseguito il cleanup, non chiamerà&nbsp; <STRONG>il distruttore o l'eventuale finalizzatore **</STRONG>. Codice C#:</P> <DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">public&nbsp;void&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">ReadMessage(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">string&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">path)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">int&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">num1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stream&nbsp;stream1&nbsp;=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">null</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamReader&nbsp;reader1&nbsp;=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">null</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream1&nbsp;=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">typeof</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">(Person).Assembly.GetManifestResourceStream(path);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader1&nbsp;=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">new&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">StreamReader(stream1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(reader1.ReadLine());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IDisposable&nbsp;disposable1&nbsp;=&nbsp;reader1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">if&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">(disposable1&nbsp;!=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">null</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;disposable1.Dispose();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;num1&nbsp;=&nbsp;0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;num1&nbsp;=&nbsp;0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR></DIV></SPAN> <P>Nel secondo caso, invece, non distruggendo l'oggetto, <STRONG>lasciamo che sia il garbage collector a scaricare le risorse</STRONG> invocando il distruttore prima della finalizzazione. Ciò signfica che <STRONG>fino a un tempo imprecisato</STRONG> le nostre risorse <STRONG>rimarrano utilizzate</STRONG> .&nbsp;Codice C#:</P> <DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">public&nbsp;void&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">ReadMessage(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">string&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">path)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stream&nbsp;stream1&nbsp;=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">null</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StreamReader&nbsp;reader1&nbsp;=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">null</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream1&nbsp;=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">typeof</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">(Person).Assembly.GetManifestResourceStream(path);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader1&nbsp;=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">new&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">StreamReader(stream1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(reader1.ReadLine());<BR>}<BR></DIV></SPAN> <P>Nel terzo caso invece vediamo un reference type object dichiarato <STRONG>come se fosse&nbsp;di un&nbsp;tipo valore</STRONG>. In realtà, questa è una semplice "illusione" propinataci dal compilatore. Il nostro oggetto <STRONG>è allocato sul managed heap</STRONG>, ma la semantica che esso assume, dal nostro punto di vista, è quella di un oggetto sullo stack. Questo ha un'importante implicazione: <STRONG>il compilatore genera automaticamente il codice per rilasciare le risorse usate dal nostro oggetto </STRONG>(ovviamente solo se necessario, ovvero se implementa <EM>IDisposable</EM> ), esattamente come il C++ nativo inserisce una chiamata ai distruttori delle variabili automatiche alla fine del metodo. Questo idioma, noto come <STRONG>deterministic finalization</STRONG>,<STRONG> </STRONG>è diventato in C++/CLI un nuovo&nbsp;idioma, analogo ma differente&nbsp;(a causa della&nbsp;diversa implementazione dell'operatore delete), detto&nbsp;<STRONG>deterministic cleanup</STRONG> . Codice C#: </P> <DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"><SPAN style="FONT-SIZE: 10pt; COLOR: #808080; FONT-FAMILY: Courier New">public&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New">void&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">ReadMessage</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">string&nbsp;path</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Stream&nbsp;stream1&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">null</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">StreamReader&nbsp;reader1&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">null</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">stream1&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">typeof</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Person</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">).</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Assembly</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">.</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">GetManifestResourceStream</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">path</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">StreamReader&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">modopt</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">IsConst</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">)&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">local1&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">StreamReader&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">modopt</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">IsConst</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">))&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008b8b; FONT-FAMILY: Courier New">new&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">StreamReader</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">stream1</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008080; FONT-FAMILY: Courier New">try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader1&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">local1</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">.</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader1</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">.</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">ReadLine</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">fault<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader1</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">.</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">Dispose</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">reader1</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">.</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">Dispose</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">();<BR>}<BR></DIV></SPAN> <P>* In C++/CLI una classe dichiarata con un distruttore, è mappata automaticamente in una classe che implementa <EM>IDisposable </EM>e il suo distruttore è <STRONG> mappato nel metodo <EM>Dispose</EM></STRONG>.</P> <P>** In C++/CLI è possibile dichiarare un <STRONG>finalizzatore</STRONG> . In questo modo, quando l'oggetto sta per essere&nbsp;distrutto non in maniera deterministica,&nbsp;bensì&nbsp;appena prima di una garbage collection&nbsp;è possibile svolgere un po' di custom behavior (per esempio tracciarlo)... oltre a invocare, com'è naturale, il distruttore affinchè vengano rilasciate le risorse.</P> <P>Questo è possibile perchè il compilatore <STRONG>genera in questo modo il metodo <EM>Dispose</EM></STRONG>:</P> <DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">protected&nbsp;virtual&nbsp;void&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Dispose([MarshalAs(UnmanagedType.U1)]&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">bool&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">flag1)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">if&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">(flag1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">this</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">.~Person();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">try<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">this</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">.!Person();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">finally<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">base</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">.Finalize();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR></DIV></SPAN> <P>Anzichè quello che avremmo <STRONG>in assenza di un finalizzatore</STRONG> :</P> <DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">protected&nbsp;virtual&nbsp;void&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Dispose([MarshalAs(UnmanagedType.U1)]&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">bool&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">flag1)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">if&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">(flag1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">this</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">.~Person();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">base</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">.Finalize();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}<BR></DIV></SPAN> <P>Vediamo quindi il seguente esempio:</P> <DIV style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: black 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: gainsboro"><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">using&nbsp;namespace&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">System</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">;<BR><BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #808080; FONT-FAMILY: Courier New">public&nbsp;</SPAN><SPAN style="COLOR: #006400; FONT-FAMILY: Courier New">ref&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New">class&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Person<BR></SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">{<BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #808080; FONT-FAMILY: Courier New">private</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">:<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #006400; FONT-FAMILY: Courier New">String</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">name_</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">;<BR><BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #808080; FONT-FAMILY: Courier New">public</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">:<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">Person&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #006400; FONT-FAMILY: Courier New">String</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">name</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">)</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">:&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">name_&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">name</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;~</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">Person&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">()<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console::</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">name_&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">+&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #ff00ff; FONT-FAMILY: Courier New">":&nbsp;I'm&nbsp;releasing&nbsp;resources...!"</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;!</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">Person&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">()<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console::</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">name_&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">+&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #ff00ff; FONT-FAMILY: Courier New">":&nbsp;I'm&nbsp;going&nbsp;to&nbsp;be&nbsp;finalized...!"</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console::</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">name_&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">+&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #ff00ff; FONT-FAMILY: Courier New">":&nbsp;I&nbsp;will&nbsp;call&nbsp;the&nbsp;destructor...!"</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008b8b; FONT-FAMILY: Courier New">delete&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Courier New">this</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>};<BR><BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New">void&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">DeterministicCleanupBehavior&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Person&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">person&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #ff00ff; FONT-FAMILY: Courier New">"Guy&nbsp;on&nbsp;the&nbsp;heap&nbsp;with&nbsp;stack&nbsp;semantic"</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>}<BR><BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New">void&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">NonDeterministicCleanupBehavior&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">()<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Person</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">person&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">=&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008b8b; FONT-FAMILY: Courier New">gcnew&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">Person&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #ff00ff; FONT-FAMILY: Courier New">"Guy&nbsp;on&nbsp;the&nbsp;heap"</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>}<BR><BR></SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #008000; FONT-FAMILY: Courier New">int&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">main</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">array</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">&lt;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">System::</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #006400; FONT-FAMILY: Courier New">String&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">^&gt;&nbsp;^</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">args</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console::</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #ff00ff; FONT-FAMILY: Courier New">"Began!"</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">DeterministicCleanupBehavior&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">();<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">NonDeterministicCleanupBehavior&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">();<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000000; FONT-FAMILY: Courier New">Console::</SPAN><SPAN style="COLOR: #191970; FONT-FAMILY: Courier New">WriteLine&nbsp;</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">(</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #ff00ff; FONT-FAMILY: Courier New">"Ended!"</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #000080; FONT-FAMILY: Courier New">return&nbsp;</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: #00008b; FONT-FAMILY: Courier New">0</SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New">;<BR>}<BR></DIV></SPAN><SPAN style="COLOR: #000000; FONT-FAMILY: Courier New"> <P>Produrrà il seguente output:</P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P>Began!<BR>Guy on the heap with stack semantic: I'm releasing resources...!<BR>Ended!<BR>Guy on the heap: I'm going to be finalized...!<BR>Guy on the heap: I will call the destructor...!<BR>Guy on the heap: I'm releasing resources...!</P></BLOCKQUOTE> <P dir=ltr>In realtà <STRONG>non potremmo prevedere</STRONG> quando viene finalizzato dal garbage collector il nostro "guy on the heap"... ma essendo il programma molto breve è naturale che&nbsp;venga scaricato soltanto alla fine dell'esecuzione (è ovvio che se dopo la chiamata a <EM>NonDeterministicCleanupBehavior</EM> il nostro programma&nbsp;eseguisse una lunga serie di istruzioni&nbsp;sarebbe probabile che il "guy on the heap" venga finalizzato in un qualche istante prima della terminazione del processo).</SPAN></P></FONT><!-- Powered by IMHO Instant Blogger Copyright (c) 2004 A.Boschin - http://www.elite.boschin.it --> <img src="http://blogs.ugidotnet.org/andrew/aggbug/15704.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/05/06/15704.aspx Fri, 06 May 2005 02:05:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/05/06/15704.aspx#feedback http://blogs.ugidotnet.org/andrew/comments/commentRss/15704.aspx Membership Provider for Firebird http://blogs.ugidotnet.org/andrew/archive/2005/05/02/15474.aspx <P>Ispirato e istruito dalla <A href="http://http://www.ugidotnet.org/workshops/workshops_detail.aspx?ID=ac7a6434-99c5-43e0-bf26-5bf238d5a52b">sessione</A> di <A href="http://blogs.ugidotnet.org/pape">Andrea</A>, spero di poter iniziare questa settimana questo piccolo progetto.</P> <P>Si tratta&nbsp;innanzitutto di creare uno script per la creazione del database e poi codare il membership provider.</P> <P>Appena lo comincio apro un nuovo workspace su <A href="http://www.gotdotnet.com">GotDotNet</A>!</P><img src="http://blogs.ugidotnet.org/andrew/aggbug/15474.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/05/02/15474.aspx Mon, 02 May 2005 12:33:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/05/02/15474.aspx#feedback http://blogs.ugidotnet.org/andrew/comments/commentRss/15474.aspx Enterprise Library for Firebird: moved http://blogs.ugidotnet.org/andrew/archive/2005/05/02/15473.aspx <P>Ho deciso di spostare il progetto su <A href="http://www.gotdotnet.com">GotDotNet</A>. Pubblicher&#242; l&#236;&nbsp;news (con feeds RSS!),&nbsp;nuove releases, etc.. Ci sono&nbsp;anche un forum e un bug tracker, che naturalmente potete utilizzare.</P> <P>Ho gi&#224; pubblicato le due "vecchie" releases (0.6 e 0.7.0) e i sorgenti sfruttando il sistema di source control (integrato tramite plugin&nbsp;in Visual Studio!).</P> <P>Ora vorrei creare un installer (in bundle con l'Enterprise Library e il provider ADO.NET per Firebird). Devo soltanto trovare il tempo di leggere le licenze e realizzarlo.</P> <P>Putroppo non sono ancora riuscito a fare una pagina di redirect sul vecchio sito perch&#232; ho dimenticato la password... trover&#242; un sistema per farlo (spero!).</P> <P>Nome workspace: Enterprise Library for Firebird</P> <P>Indirizzo: <A href="http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=1f216647-4011-40cd-8dc7-174eda97aad1">http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=1f216647-4011-40cd-8dc7-174eda97aad1</A></P> <P>&nbsp;</P><img src="http://blogs.ugidotnet.org/andrew/aggbug/15473.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/05/02/15473.aspx Mon, 02 May 2005 12:30:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/05/02/15473.aspx#feedback 4 http://blogs.ugidotnet.org/andrew/comments/commentRss/15473.aspx n-mila versioni di Visual Studio http://blogs.ugidotnet.org/andrew/archive/2005/04/27/15285.aspx <FONT face=Verdana size=2> <P>Condividendo le <A title="" HREF="/pape/archive/2005/03/26/13045.aspx" target="" name="">opinioni</A> di <A title="" HREF="/pape" target="" name="">Andrea</A> in merito all'inclusione nei soli prodotti <A title="" href="http://lab.msdn.microsoft.com/vs2005/teamsystem/" target="" name=""><EM>Team System</EM></A> degli strumenti per lo unit testing, volevo ora portare il ragionamento un po' oltre.</P> <P>Per quale motivo <A title="" HREF="/aldod/archive/2005/04/19/14347.aspx" target="" name="">tutte queste versioni </A>di Visual Studio? Probabilmente ci avrete gi&#224; pensato: perch&#232; non rilasciare una piattaforma, che potremmo chiamare "Visual Studio Foundation", e poi tutti i plugin del caso, acquistabili <U>separatamente e in ogni momento</U>? Insomma un modello &#224;la <A title="" href="http://www.eclipse.org/" target="" name="">Eclipse</A> o <A title="" href="http://www.netbeans.org/" target="" name="">Netbeans</A>...</P> <P>Immaginate di avvicinarvi alla programmazione in ambiente Windows. Ad oggi, probabilmente su consiglio di qualche amico, compreresti uno dei prodotti express, diciamo <EM>C# Express</EM>. Se non avete mai fatto unit testing, e un giorno decideste di imparare a farlo, molto difficilmente acquistereste i <EM>Team System</EM>, dopo una breve ricerca su <A title="" href="http://www.google.com/" target="" name="">Google</A> troverete probabilmente <A title="" href="http://www.nunit.org/" target="" name="">NUnit</A>. A un certo punto potrebbe nascere l'esigenza di sviluppare un'applicazione web... a quel punto tornereste dal rivenditore di fiducia e comprare <EM>Visual Web Developer</EM>... o magari la versione&nbsp;<EM>Professional</EM>. E se un giorno doveste iniziare a lavorare in un gruppo di 5 o 10 persone? Oppure se voleste semplicemente progettare un software e vorreste usare il class designer? Un nuovo acquisto probabilmente... </P> <P>E se invece bastasse una semplice puntatina sul nuovo scintillante "Visual Studio Extensibility Center" di Microsoft... un paio di click, il numero di carta di credito... qualche minuto di download... per avere immediatamente integrati nel vostro "Visual Studio Foundation" i plugin che soddisfano le vostre esigenze? Un plugin per C#, poi uno per le Windows forms, un altro per le web forms... poi quello per lo unit testing, magari un giorno potreste desiderare il class designer... o magari un collega potrebbe passarvi del codice VB, o C++... e allora scegliereste l'estensione oppurtuna per il vostro ambiente. Tutto questo andrebbe ad affiancarsi, naturalmente, ai numerosi plugin, gi&#224; esistenti,&nbsp;di terze parti (ad esempio,&nbsp;quello per <A href="http://www.eiffel.com/">Eiffel</A>).</P></FONT><img src="http://blogs.ugidotnet.org/andrew/aggbug/15285.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/04/27/15285.aspx Wed, 27 Apr 2005 10:31:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/04/27/15285.aspx#feedback 4 http://blogs.ugidotnet.org/andrew/comments/commentRss/15285.aspx Visual C++ 2005 and *.vcproj http://blogs.ugidotnet.org/andrew/archive/2005/04/20/14495.aspx <FONT face=Verdana size=2> <P>Se state usando <STRONG>Visual C++ 2005</STRONG>, vi sarete probabilmente accorti che l'ambiente non &#232; ancora del tutto completo. Esistono alcune limitazioni nella gestione del progetto (file di risorsa, file di soluzione, etc.). Non so se queste rimarranno limitazioni del prodotto <STRONG>Express</STRONG> definitivo, ad ogni modo potete ovviare a questi problemi scrivendo manualmente il file di progetto e <STRONG>vcbuild.exe</STRONG> per compilarlo. Qui potete trovate lo schema XML:</P> <P><A href="http://msdn2.microsoft.com/library/y4sy8216(en-us,vs.80).aspx">http://msdn2.microsoft.com/library/y4sy8216(en-us,vs.80).aspx</A></P> <P>Il designer &#232; decisamente migliorato, tuttavia, a mio parere, genera un pessimo codice. Sarebbe stato importante, per lo meno, che separasse le implementazioni dei&nbsp;metodi&nbsp;(in particolare, del costruttore e dei delegati che gestiscono gli eventi) dalla loro dichiarazione, come &#232; comune fare nei progetti C/C++.</P> <P>Tra le note completamente positive, potrei citare l'intellisense, perfettamente funzionante, la comoda "start page" e le performance complessive dell'ambiente di sviluppo, che risulta decisamente pi&#249; veloce e leggero di Visual Studio 2003 Professional o di altri IDE per Java.</P> <P>Il lavoro svolto da&nbsp; <A href="http://www.pluralsight.com/blogs/hsutter/default.aspx">Sutter</A>, <A href="http://blogs.msdn.com/slippman">Lipman</A> e colleghi &#232; veramente eccezionale. Ora manca solo la <A href="http://msdn.microsoft.com/visualc/homepageheadlines/ecma/default.aspx">standardizzazione da parte dell'ECMA</A>. La nuova sintassi &#232; un'ottimo compromesso tra eleganza, integrazione con le funzionalit&#224; offerte dal CLR e mantenimento degli idiomi tipici del C++. Confrontando alcune semplici classi che ho scritto sia in C#, sia&nbsp;in C++/CLI l'impressione &#232; che il secondo linguaggio abbia dato al mio codice una forma estremamente pi&#249; elegante e mantenibile. I motivi principali sono i seguenti:</P> <P>1. <U>Distinzione tra dichiarazione</U> (in un file header) <U>e implementazione</U>. In questo modo, guardando il file header&nbsp;risulta immediatamente visibile com'&#232; strutturata una classe, senza bisogno di scorrere tra tutte le linee di codice. Ok, il class viewer fa anch'esso un ottimo lavoro in merito, ma supportare questo stile di programmazione a livello di codice,&nbsp;secondo me &#232; molto importante.</P> <P>2. <U>Tipi valore e tipi riferimento sono dichiarati e costruiti in maniera diversa</U>. Questo, a mio parere &#232; fondamentale su una piattaforma come il CLR che, a differenza di Java,&nbsp;ci offre la possibilit&#224; di creare tipi valori customizzati (struct in C#, value class o value struct in C++/CLI). La scelta, inoltre, di distinguere gli operatori "<STRONG>gcnew</STRONG>"<STRONG> e </STRONG>"<STRONG>^</STRONG>"&nbsp; da "<STRONG>new</STRONG>" e "<STRONG>*</STRONG>" &#232; veramente ben pensata.</P> <P>3.&nbsp;<U>I tre operatori per l'accesso a membro "<STRONG>::</STRONG>", "-&gt;"<STRONG> </STRONG>e "<STRONG>.</STRONG>" aggiungono chiarezza e auto-esplicativit&#224; al codice</U>.</P> <P>4. <U>Esistono i costruttori statici</U>! Spesso rimpianti in Java e C# quando si deve inizializzare in maniera non banale i membri statici di una classe.</P> <P>5. Come <A href="http://blogs.ugidotnet.org/pape/archive/2004/12/20/7418.aspx">gi&#224; fatto notare</A> da <A href="http://blogs.ugidotnet.org/pape">Andrea</A>&nbsp;il compilatore C++/CLI <U>espande&nbsp;automaticamente le propriet&#224;</U> per le quali non sono dichiarati i metodi get/set (sostanzialmente inserisce un membro privato e l'implementazione banale di get/set).</P> <P>6. <U>La possibilit&#224; di dicharare lo specificatore di accesso </U>(public, private, protected, internal) <U>su una serie di dichiarazioni successive</U> ci&nbsp;evita un po' di battitura e favorisce il raggruppamento dei membri (buona norma da molti utilizzata).</P> <P>7. <U>Viva la standard template library</U>! Ora esiste una STL per il CLR... personalmente System::Collections non mi &#232; mai piaciuta... </P> <P><EM>More info and examples to come...</EM></P> <P>Inoltre il&nbsp;team di <STRONG>cl.exe</STRONG> ha svolto un gran lavoro affinch&#232; le stesse possibilit&#224; di ottimizazzione che anni di esperienza hanno permesso di attribuire al compilatore C++ ora possano venire applicate anche al codice gestito. Naturalmente esistono delle differenze, dovute al fatto che il CLR &#232; una macchina virtuale stack-based, ma il codice IL generato da cl.exe&nbsp;&#232; mediamente pi&#249; performante di quello prodotto da csc.exe o vbc.exe. </P></FONT><!-- Powered by IMHO Instant Blogger Copyright (c) 2004 A.Boschin - http://www.elite.boschin.it --><img src="http://blogs.ugidotnet.org/andrew/aggbug/14495.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/04/20/14495.aspx Wed, 20 Apr 2005 12:37:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/04/20/14495.aspx#feedback 3 http://blogs.ugidotnet.org/andrew/comments/commentRss/14495.aspx "What is Indigo?" http://blogs.ugidotnet.org/andrew/archive/2005/04/11/13924.aspx <P>Un'ottima introduzione (e dimostrazione) da parte di uno dei software architect che lo hanno ideato:</P> <P><A href="http://channel9.msdn.com/ShowPost.aspx?PostID=56397">http://channel9.msdn.com/ShowPost.aspx?PostID=56397</A></P> <P>42 minuti circa</P><img src="http://blogs.ugidotnet.org/andrew/aggbug/13924.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/04/11/13924.aspx Mon, 11 Apr 2005 16:25:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/04/11/13924.aspx#feedback http://blogs.ugidotnet.org/andrew/comments/commentRss/13924.aspx NUnit... MBUnit o CSUnit? http://blogs.ugidotnet.org/andrew/archive/2005/04/10/13840.aspx <P>Uso NUnit con discreta soddisfazione, ma mi chiedevo se qualcuno di voi abbia provato&nbsp;i due progetti open-source "concorrenti".</P> <P>Non ho molto tempo attualmente per provarli, qualcuno che li ha gi&#224; usati sa darmi un parere?</P><img src="http://blogs.ugidotnet.org/andrew/aggbug/13840.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/04/10/13840.aspx Sun, 10 Apr 2005 00:10:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/04/10/13840.aspx#feedback 3 http://blogs.ugidotnet.org/andrew/comments/commentRss/13840.aspx Enterprise Library for Firebird 0.7.0 http://blogs.ugidotnet.org/andrew/archive/2005/04/05/13646.aspx <FONT face=Verdana size=2> <P>Ho effettuato qualche&nbsp;piccola modifica al pacchetto. Grazie ad <A title="" href="http://blogs.ugidotnet.org/microISV/" target="" name="">Alessandro Petrelli </A>per le sue correzioni sullo script sql per la creazione del database Northwind.</P> <P>Dal changelog:</P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P><EM>5th April 2005 - version 0.7.0 released</EM></P> <BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"> <P><EM>&nbsp;* License changed into LGPL<BR>&nbsp;<BR>&nbsp;* Cleaned up "bin" and "obj" directories&nbsp; from some files which were used during the initial development process</EM></P> <P><EM>&nbsp;* Minor changes to "NorthwindForFirebird.sql" (thanks to Alessandro Petrelli)</EM></P> <P><EM>&nbsp;* Minor changes to "Readme.txt"</EM></P> <P><EM>&nbsp;* Added "Changelog.txt"<BR>&nbsp;<BR>&nbsp;* Version changed into 0.7.0</EM></P></BLOCKQUOTE></BLOCKQUOTE> <P>La potete scaricare qui:<A title="" href="http://digilander.libero.it/Syscall/Andrew.EnterpriseLibrary-20050405.zip" target="" name="">http://digilander.libero.it/Syscall/Andrew.EnterpriseLibrary-20050405.zip</P></A> <P>Se riesco in questi giorni farò richiesta presso <A title="" href="http://www.sourceforge.net/" target="" name="">SourceForge</A>.</P> </FONT><!-- Powered by IMHO Instant Blogger Copyright (c) 2004 A.Boschin - http://www.elite.boschin.it --> <img src="http://blogs.ugidotnet.org/andrew/aggbug/13646.aspx" width="1" height="1" /> Andrea Sansottera http://blogs.ugidotnet.org/andrew/archive/2005/04/05/13646.aspx Tue, 05 Apr 2005 22:49:00 GMT http://blogs.ugidotnet.org/andrew/archive/2005/04/05/13646.aspx#feedback http://blogs.ugidotnet.org/andrew/comments/commentRss/13646.aspx