# Thursday, 08 March 2012
« Lang.NEXT | Main | New Development Snapshot »
CLR Supported Custom Attributes

After working with the CLR for more than a decade, once in a while I still run into surprising behavior.

It turns out that the (non pseudo-) custom attributes that CLR recognizes are only matched by name, not assembly.

So you can do this for example:

using System;
using System.Threading;

namespace System {
  class ThreadStaticAttribute : global::System.Attribute { }

class Program {
  static int foo;

  public static void Main() {
    foo = 42;
    new Thread(WriteFoo).Start();

  static void WriteFoo() {

On the CLR the foo static variable is a thread local, but on Mono it isn't.

Thursday, 08 March 2012 14:35:51 (W. Europe Standard Time, UTC+01:00)  #    Comments [5]