﻿<?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>Ayende Rahien commented on Do you trust your compiler? Really trust your compiler?</title><description>Anato,
  
Well, this doesn't really work. The interface has to reside in another assembly, and you can't add constraints to such an interface method.
</description><link>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment6</link><guid>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment6</guid><pubDate>Wed, 19 Dec 2007 17:52:14 GMT</pubDate></item><item><title>Ant&amp;#227;o commented on Do you trust your compiler? Really trust your compiler?</title><description>  
I'm sorry but I consider that bad coding. It's not the compilers fault that you accept runtime exceptions...
  
  
If you add a where statement, everything will be fine.
  
  
public Guid Create&lt;T&gt;(T newEntity)
  
        where T : BusinessEntity
  
{
  
	using (CrmService svc = GetCrmService())
  
	{
  
		object cheatCompiler = newEntity;
  
		Guid guid = svc.Create((BusinessEntity) cheatCompiler);
  
		return guid;
  
	}
  
}
</description><link>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment5</link><guid>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment5</guid><pubDate>Wed, 19 Dec 2007 16:37:58 GMT</pubDate></item><item><title>Stefan Wenig commented on Do you trust your compiler? Really trust your compiler?</title><description>you could use some defensiveness (is/throw argumentexception instead of cast), and I don't see the value of using a generic here. do you mean 
  
  Guid Create (BusinessEntity newEntity)
  
in the interface? then what's wrong with this?
  
  Guid Create (object newEntity)
  
  
you might want to consider making the whole interface generic, your class could then just implement IWhatever&lt;BusinessEntity&gt;. 
</description><link>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment4</link><guid>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment4</guid><pubDate>Wed, 19 Dec 2007 08:56:55 GMT</pubDate></item><item><title>Ayende Rahien commented on Do you trust your compiler? Really trust your compiler?</title><description>That would break the assembly that define the interface, that is the problem.
</description><link>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment3</link><guid>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment3</guid><pubDate>Wed, 19 Dec 2007 05:04:10 GMT</pubDate></item><item><title>Jimmy Bogard commented on Do you trust your compiler? Really trust your compiler?</title><description>Shouldn't you constrain that generic method too?  Or would that break the calling assembly?
</description><link>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment2</link><guid>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment2</guid><pubDate>Tue, 18 Dec 2007 22:33:51 GMT</pubDate></item><item><title>Peter w commented on Do you trust your compiler? Really trust your compiler?</title><description>I can tell you one thing about the .NET 1.1 compiler: do not generate your code from an excel spreadsheet function.
  
  
If a function line has roughly 60,000 lines, it will compile, but will yield a stack overflow in execution
</description><link>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment1</link><guid>http://ayende.com/3056/do-you-trust-your-compiler-really-trust-your-compiler#comment1</guid><pubDate>Tue, 18 Dec 2007 21:38:20 GMT</pubDate></item></channel></rss>