﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Avish commented on Can you hack this out? Hint #1</title><description>Ooh, nice solution. I was thinking about this:
  
  
using MyFunnyType = System.Nullable
&lt;int; 
  
  
As far as I recall, Nullable structs are not applicable for the "struct" constraint (which is actually defined as "non-nullable value type"), so I guess they might be applicable for the "class" constraint. I'm probably wrong, but it'd be a nice solution. 
&gt;</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment19</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment19</guid><pubDate>Mon, 30 Nov 2009 21:08:57 GMT</pubDate></item><item><title>Mark Rogers commented on Can you hack this out? Hint #1</title><description>Cool post, I hate to say but I think you misspelled 'instance' as 'instnace' in your code example.
  
  
Peace!
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment18</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment18</guid><pubDate>Mon, 30 Nov 2009 15:17:49 GMT</pubDate></item><item><title>Chris Wright commented on Can you hack this out? Hint #1</title><description>I've used a programming language in which you can return a value from a constructor, even null. Insanity :)
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment17</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment17</guid><pubDate>Sat, 28 Nov 2009 14:34:52 GMT</pubDate></item><item><title>Wil commented on Can you hack this out? Hint #1</title><description>Looks like this would work.   
  
  
 public class InterceptionProxy : RealProxy
  
    {
  
        public InterceptionProxy() : base(typeof(MyFunnyType)) { }
  
  
         public override IMessage Invoke(IMessage msg)
  
        {
  
             // Does not get here
  
              ....
  
        }
  
  
        public override object GetTransparentProxy()
  
        {
  
            return null;
  
        }
  
  }
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment16</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment16</guid><pubDate>Wed, 25 Nov 2009 15:48:28 GMT</pubDate></item><item><title>Marc Gravell commented on Can you hack this out? Hint #1</title><description>@Reshef - it isn't that the T is unknown; it is that the operator can't be resolved via static analysis (which it must) to a single implementation. Similar to how +-*/ don't work (unless you cheat, like in MiscUtil's Operator class). I suspect there is some scenarios (involving subclassing and a constraint like T : SomeType) where it /would/ pick up the operator, but that ("T : SomeType") isn't in the question.
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment15</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment15</guid><pubDate>Wed, 25 Nov 2009 15:02:14 GMT</pubDate></item><item><title>Reshef commented on Can you hack this out? Hint #1</title><description>Right. When creating the object with new T() somehow the type is unknown and it won't call the != operator. Generics oddity...
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment14</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment14</guid><pubDate>Wed, 25 Nov 2009 13:55:46 GMT</pubDate></item><item><title>Ayende Rahien commented on Can you hack this out? Hint #1</title><description>Reshef,
  
Try that, it won't work :-)
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment13</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment13</guid><pubDate>Wed, 25 Nov 2009 13:41:48 GMT</pubDate></item><item><title>Reshef Mann commented on Can you hack this out? Hint #1</title><description>Apparently this will do the trick:
  
  
            public static bool operator !=(object left, MyFunnyType right)
  
            {
  
                return false;
  
            }
  
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment12</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment12</guid><pubDate>Wed, 25 Nov 2009 13:37:57 GMT</pubDate></item><item><title>Marc Gravell commented on Can you hack this out? Hint #1</title><description>Indeed - pure evil; and definitely worthy of an update to my similar corner-case on stackoverflow: 
[http://stackoverflow.com/questions/194484#194671](http://stackoverflow.com/questions/194484#194671)</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment11</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment11</guid><pubDate>Wed, 25 Nov 2009 12:06:09 GMT</pubDate></item><item><title>liviu commented on Can you hack this out? Hint #1</title><description>I did not know that ProxyAttribute exists :)
  
It opens so many possibilities!!!
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment10</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment10</guid><pubDate>Wed, 25 Nov 2009 11:58:53 GMT</pubDate></item><item><title>Dennis commented on Can you hack this out? Hint #1</title><description>Damn, thats a NASTY solution :S
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment9</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment9</guid><pubDate>Wed, 25 Nov 2009 11:14:01 GMT</pubDate></item><item><title>Ayende Rahien commented on Can you hack this out? Hint #1</title><description>Dennis,
  
Yes.
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment8</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment8</guid><pubDate>Wed, 25 Nov 2009 11:03:22 GMT</pubDate></item><item><title>Dennis commented on Can you hack this out? Hint #1</title><description>Do you mean to break
  
var instnace = new 
&lt;whatever;
  
object.ReferenceEquals(instnace, null) == false?
&gt;</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment7</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment7</guid><pubDate>Wed, 25 Nov 2009 11:00:15 GMT</pubDate></item><item><title>Ayende Rahien commented on Can you hack this out? Hint #1</title><description>Marc,
  
:-)
  
Yeah.
  
Once the previous hack was solved, this is pretty easy.
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment6</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment6</guid><pubDate>Wed, 25 Nov 2009 10:53:47 GMT</pubDate></item><item><title>Marc Gravell commented on Can you hack this out? Hint #1</title><description>class MyFunnyTypeAttribute : ProxyAttribute {
  
    public override MarshalByRefObject CreateInstance(Type serverType) { return null; }
  
}
  
[MyFunnyType] class MyFunnyType : ContextBoundObject{}
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment5</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment5</guid><pubDate>Wed, 25 Nov 2009 10:46:36 GMT</pubDate></item><item><title>Ayende Rahien commented on Can you hack this out? Hint #1</title><description>Hazzik,
  
No :-)
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment4</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment4</guid><pubDate>Wed, 25 Nov 2009 10:46:36 GMT</pubDate></item><item><title>hazzik commented on Can you hack this out? Hint #1</title><description>Can we modify CanThisHappen method of program?
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment3</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment3</guid><pubDate>Wed, 25 Nov 2009 10:43:12 GMT</pubDate></item><item><title>Ayende Rahien commented on Can you hack this out? Hint #1</title><description>Hazzik,
  
That would work, yes, but that doesn't match the challenge that I set.
</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment2</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment2</guid><pubDate>Wed, 25 Nov 2009 10:39:10 GMT</pubDate></item><item><title>hazzik commented on Can you hack this out? Hint #1</title><description>perhaps like this:
  
  
public class Program {
  
	private static void Main() {
  
		CanThisHappen
&lt;myfunnytype();
  
	}
  
  
	public static void CanThisHappen
&lt;t() where T : class, new() {
  
		var instnace = new T();
  
		Debug.Assert(!instnace.Equals(null), "How did we break the CLR?");
  
		}
  
	}
  
  
internal class MyFunnyType {
  
	public override bool Equals(object obj) {
  
		return true;
  
	}
  
}
  
  
&gt;</description><link>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment1</link><guid>http://ayende.com/4307/can-you-hack-this-out-hint-1#comment1</guid><pubDate>Wed, 25 Nov 2009 10:33:27 GMT</pubDate></item></channel></rss>