<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>csharp on Mature Pessimizations - A programming blog by Theodoros Chatzigiannakis</title>
    <link>https://blog.tchatzigiannakis.com/tags/csharp/</link>
    <description>Recent content in csharp on Mature Pessimizations - A programming blog by Theodoros Chatzigiannakis</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sun, 03 Mar 2019 20:00:00 +0300</lastBuildDate>
    
	<atom:link href="https://blog.tchatzigiannakis.com/tags/csharp/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Generics as super-functions</title>
      <link>https://blog.tchatzigiannakis.com/generics-as-super-functions/</link>
      <pubDate>Sun, 03 Mar 2019 20:00:00 +0300</pubDate>
      
      <guid>https://blog.tchatzigiannakis.com/generics-as-super-functions/</guid>
      <description>&lt;p&gt;This post is the beginning of a series in which we will look at generics more closely, we will consider their implementation details across various languages, and we will explore their potential in solving problems we have today (with static analysis in mind).&lt;/p&gt;

&lt;p&gt;As usual, we will use C# as for our examples because its generics syntax will be self-explanatory to developers familiar with C++, Java, Rust, etc. Also, for the purposes of this post we will use the terms &amp;ldquo;function&amp;rdquo; and &amp;ldquo;method&amp;rdquo; interchangeably.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>A look at NDepend</title>
      <link>https://blog.tchatzigiannakis.com/a-look-at-ndepend/</link>
      <pubDate>Mon, 24 Sep 2018 20:00:00 +0300</pubDate>
      
      <guid>https://blog.tchatzigiannakis.com/a-look-at-ndepend/</guid>
      <description>&lt;p&gt;Earlier this year, the developers of &lt;a href=&#34;https://www.ndepend.com/&#34;&gt;NDepend&lt;/a&gt; were kind enough to grant me free of charge a license for their tool. They invited me to try it and consider writing something about it.&lt;/p&gt;

&lt;p&gt;So this post will be a brief pause from the usual content of my blog, as we will be taking a quick look at some of the functionality of this software. I&amp;rsquo;ve also opted to include a few screenshots from the NDepend site, because I preferred them to the ones I took myself.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Changing an object&#39;s type at runtime in C#</title>
      <link>https://blog.tchatzigiannakis.com/changing-an-objects-type-at-runtime-in-c-sharp/</link>
      <pubDate>Mon, 21 Aug 2017 20:00:00 +0300</pubDate>
      
      <guid>https://blog.tchatzigiannakis.com/changing-an-objects-type-at-runtime-in-c-sharp/</guid>
      <description>&lt;p&gt;In most statically typed languages, an object&amp;rsquo;s type is set in stone once the object has been completely constructed. While the object can subsequently be cast to various types, it can never change its runtime type — many aspects of type systems and features (such as virtual dispatch) depend on this.&lt;/p&gt;

&lt;p&gt;In this post, we will see how we can use unsafe code in C# to bypass the type system and change a .NET object&amp;rsquo;s runtime type. Then, we will see an unusual case where it would be neat to have this. Needless to say, don&amp;rsquo;t try this in real code.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Creating a ref alternative in C#</title>
      <link>https://blog.tchatzigiannakis.com/creating-a-ref-alternative-in-c-sharp/</link>
      <pubDate>Mon, 02 Jan 2017 20:00:00 +0300</pubDate>
      
      <guid>https://blog.tchatzigiannakis.com/creating-a-ref-alternative-in-c-sharp/</guid>
      <description>&lt;p&gt;C# has two keywords called &lt;code&gt;ref&lt;/code&gt; and &lt;code&gt;out&lt;/code&gt;. They are not exactly the same, but they both offer the ability to pass a reference to a local variable or a field. At the binary level, what is passed is essentially a pointer.&lt;/p&gt;

&lt;p&gt;This feature is useful, but it has certain technical limitations. We will explore the possibility of constructing an alternative that does not suffer from the same limitations.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Using the new() constraint is a symptom of the XY problem</title>
      <link>https://blog.tchatzigiannakis.com/using-the-new-constraint-is-a-symptom-of-the-xy-problem/</link>
      <pubDate>Mon, 26 Dec 2016 20:00:00 +0300</pubDate>
      
      <guid>https://blog.tchatzigiannakis.com/using-the-new-constraint-is-a-symptom-of-the-xy-problem/</guid>
      <description>&lt;p&gt;C# allows you to write generic code with a few constraints that can&amp;rsquo;t be expressed through the type hierarchy alone. For example, you can require that a generic type parameter only accepts types that are structs, or reference types, or non-abstract types that have a public default constructor:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cs&#34; data-lang=&#34;cs&#34;&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cs&#34; data-lang=&#34;cs&#34;&gt;&lt;span class=&#34;k&#34;&gt;public&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;M&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;T1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T3&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;&amp;gt;()&lt;/span&gt;
    &lt;span class=&#34;k&#34;&gt;where&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T1&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;struct&lt;/span&gt;
    &lt;span class=&#34;nc&#34;&gt;where&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T2&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt;
    &lt;span class=&#34;nc&#34;&gt;where&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T3&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;new&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
    &lt;span class=&#34;cm&#34;&gt;/* code */&lt;/span&gt;
&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;That last case is what we&amp;rsquo;re interested in for this post.&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>