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 { [System.ThreadStaticAttribute] static int foo; public static void Main() { WriteFoo(); foo = 42; WriteFoo(); new Thread(WriteFoo).Start(); } static void WriteFoo() { Console.WriteLine(foo); }}
On the CLR the foo static variable is a thread local, but on Mono it isn't.
Remember Me
I apologize for the lameness of this, but the comment spam was driving me nuts. In order to be able to post a comment, you need to answer a simple question. Hopefully this question is easy enough not to annoy serious commenters, but hard enough to keep the spammers away.
Anti-Spam Question: What method on java.lang.System returns an object's original hashcode (i.e. the one that would be returned by java.lang.Object.hashCode() if it wasn't overridden)? (case is significant)
Powered by: newtelligence dasBlog 2.3.12105.0
© Copyright 2021, Jeroen Frijters
E-mail