<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Capi's Corner &#187; .net</title>
	<atom:link href="http://www.dont-panic.cc/capi/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dont-panic.cc/capi</link>
	<description>Development, Network, Security, Ideas &#038; Opinions</description>
	<lastBuildDate>Sat, 10 Dec 2011 19:31:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>.NET strings are not always immutable!</title>
		<link>http://www.dont-panic.cc/capi/2007/10/03/net-strings-are-not-always-immutable/</link>
		<comments>http://www.dont-panic.cc/capi/2007/10/03/net-strings-are-not-always-immutable/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 14:17:45 +0000</pubDate>
		<dc:creator>Martin Carpella</dc:creator>
				<category><![CDATA[computer]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.dont-panic.cc/capi/2007/10/03/net-strings-are-not-always-immutable/</guid>
		<description><![CDATA[Strings are immutable. If you want to modify a sequence of characters, use StringBuilder. At least, that&#8217;s whats officially said. But in the framework there is at least one method that does modify a string: TextRenderer.MeasureText() with ModifyString and EndEllipses will modify your string to match the ellipsed text if ellipsing happens. You can look [...]]]></description>
			<content:encoded><![CDATA[<p><code>Strings</code> are immutable. If you want to modify a sequence of characters, use <code>StringBuilder</code>. At least, that&#8217;s whats officially said. But in the framework there is at least one method that does modify a string:</p>
<p><code>TextRenderer.MeasureText()</code> with <code>ModifyString</code> and <code>EndEllipses</code>  will modify your string  to match the ellipsed text if ellipsing happens. You can look at this <a href="http://www.codeproject.com/useritems/NewPathCompactPath.asp" aiotitle="VB# example on codeproject using TextRenderer.MeasureText() for trimming text">VB# example on codeproject using <code>TextRenderer.MeasureText()</code> for trimming text</a> on how it is used.</p>
<p>The string seems to be modified directly in native code by <code>DrawTextEx</code> from <code>user32.dll</code>. Additionally to the scary fact that strings are not immutable, the length of the string is not updated, regardless if the resulting string is shorter!</p>
<p>For instance if you have a string &#8220;<code>aaaaaaa</code>&#8221; which will be truncated to &#8220;<code>aa...</code>&#8220;, the <code>Length</code> property will still return 7 for the shortened string.  The debugger shows that the string will in fact be &#8220;aa&#8230;\0a&#8221; after the operation. So maybe it might be right that the string is still 7 characters long but most outputting functionality like <code>Console.Out.WriteLine()</code> gets confused sometimes and stops any further output to the debugger or console under certain conditions.</p>
<p>A very quick investigation of the System.Drawing assembly using Lutz Roeder&#8217;s fabulous <a href="http://www.aisto.com/roeder/dotnet">.NET Reflector</a> showed that at least there should be no memory corruption in case &#8220;<code>WW</code>&#8221; would get ellipsed to &#8220;<code>W...</code>&#8220;, as <code>DrawTextEx</code> takes the length of the buffer and should result only in &#8220;<code>W.</code>&#8220;.</p>
<p>Summing up, I find the <em>corruption</em> of an immutable string <em>by an official Microsoft API</em> very troubling.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dont-panic.cc/capi/2007/10/03/net-strings-are-not-always-immutable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VisualStudio.NET: Text-Editor Guide at 80</title>
		<link>http://www.dont-panic.cc/capi/2006/04/21/visualstudionet-text-editor-guide-at-80/</link>
		<comments>http://www.dont-panic.cc/capi/2006/04/21/visualstudionet-text-editor-guide-at-80/#comments</comments>
		<pubDate>Fri, 21 Apr 2006 12:54:55 +0000</pubDate>
		<dc:creator>Martin Carpella</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[registry-hack]]></category>
		<category><![CDATA[userinterface]]></category>
		<category><![CDATA[vs.net]]></category>

		<guid isPermaLink="false">http://www.dont-panic.cc/capi/archives/33</guid>
		<description><![CDATA[It is still considered good style to keep code-lines within a certain bound (e.g. 80 characters). IDEs like Eclipse offer to display a red guiding line at the chosen offset to help developers keep within this bound. By modifying the registry a similar guide can be enabled for Visual Studio 2003 / 2005. Add a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.dont-panic.cc/capi/wp-content/uploads/2006/04/screenshot.JPG"><img align="right" style="margin-left: 10px; width: 257px; height: 121px" id="image35" alt="Guiding lines in VS.NET 2005" title="Guiding lines in VS.NET 2005" src="http://www.dont-panic.cc/capi/wp-content/uploads/2006/04/screenshot.JPG" /></a>It is still considered good style to keep code-lines within a certain bound (e.g. 80 characters). IDEs like <a href="http://www.eclipse.org">Eclipse</a> offer to display a red guiding line at the chosen offset to help developers keep within this bound.</p>
<p>By modifying the registry a similar guide can be enabled for <a href="http://msdn.microsoft.com/vstudio/">Visual Studio</a> 2003 / 2005. Add a string value <strong><code>Guides</code></strong> to the key (VS.NET 2005, VS 2003 has version 7.1)</p>
<blockquote><p><code> HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\Text Editor</code>.</p></blockquote>
<p>Set the value to</p>
<blockquote><p><code>RGB(128,0,0) 80</code></p></blockquote>
<p>To have multiple guides (like in the <a href="http://www.dont-panic.cc/capi/wp-content/uploads/2006/04/screenshot.JPG">screenshot</a>), add the additional columns space delimited, e.g.</p>
<blockquote><p><code>RGB(128,0,0) 80 100</code></p></blockquote>
<p>Ackn.: This information has been provided by <em>Hannes Pavelka</em> in Microsoft&#8217;s newsgroup <em>microsoft.public.dotnet.languages.csharp</em>, Message-ID: <em>&lt;e1jag7$qk7$02$1@news.t-online.com&gt;</em> (<a href="http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/571b30f9a9feb524/b1b7813f0a26af51">Article in Google Groups</a>):</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dont-panic.cc/capi/2006/04/21/visualstudionet-text-editor-guide-at-80/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft: Shared Source Common Language Infrastructure 2.0 Release</title>
		<link>http://www.dont-panic.cc/capi/2006/03/25/microsoft-shared-source-common-language-infrastructure-20-release/</link>
		<comments>http://www.dont-panic.cc/capi/2006/03/25/microsoft-shared-source-common-language-infrastructure-20-release/#comments</comments>
		<pubDate>Sat, 25 Mar 2006 11:43:32 +0000</pubDate>
		<dc:creator>Martin Carpella</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://www.dont-panic.cc/capi/archives/32</guid>
		<description><![CDATA[Just came accross this: seems like Microsoft has released some parts of the CLI under one of their &#8220;free&#8221; licenses. Download details: Shared Source Common Language Infrastructure 2.0 Release Update 2006/03/26: As I just noticed at Mono&#8217;s &#8220;Contributing&#8221; page, they won&#8217;t accept any contributions from people who had a look at the download.]]></description>
			<content:encoded><![CDATA[<p>Just came accross this: seems like Microsoft has released some parts of the CLI under one of their &#8220;free&#8221; licenses.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=8C09FD61-3F26-4555-AE17-3121B4F51D4D&amp;displaylang=en">Download details: Shared Source Common Language Infrastructure 2.0 Release</a></p>
<p><strong>Update 2006/03/26:</strong> As I just noticed at Mono&#8217;s &#8220;<a href="http://www.mono-project.com/Contributing">Contributing</a>&#8221; page, they won&#8217;t accept any contributions from people who had a look at the download.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dont-panic.cc/capi/2006/03/25/microsoft-shared-source-common-language-infrastructure-20-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IKVM.NET: Interaction between C# and Java</title>
		<link>http://www.dont-panic.cc/capi/2005/12/12/ikvmnet-interaction-between-c-and-java/</link>
		<comments>http://www.dont-panic.cc/capi/2005/12/12/ikvmnet-interaction-between-c-and-java/#comments</comments>
		<pubDate>Mon, 12 Dec 2005 12:38:35 +0000</pubDate>
		<dc:creator>Martin Carpella</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[interop]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[virtual-machine]]></category>

		<guid isPermaLink="false">http://www.dont-panic.cc/capi/archives/24</guid>
		<description><![CDATA[A nice project, everyone coming from Java and migrating to C#: IKVM.NET Home Page It is a JVM implemented in .NET, contains a .NET implementation of a lot classes from the Java class libraries (JDK), compliance of 1.4 almost complete and contains tools for interop between Java and .NET.]]></description>
			<content:encoded><![CDATA[<p>A nice project, everyone coming from Java and migrating to C#:<br />
<a href="http://www.ikvm.net/index.html">IKVM.NET Home Page</a></p>
<p>It is a JVM implemented in .NET, contains a .NET implementation of a lot classes from the Java class libraries (JDK), compliance of 1.4 almost complete and contains tools for interop between Java and .NET.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dont-panic.cc/capi/2005/12/12/ikvmnet-interaction-between-c-and-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

