﻿<?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>Patrik commented on Count the interfaces...</title><description>I think it makes perfect sense, I ask for the interfaces the class implements and I get the correct answer. It doesn't have anything to do with the fact that the class directly implements both interfaces, it's the fact that it DOES implement them. Look at the following code, the class B only directly implements ISerializable, but both IDisposable and ISerializable are returned by the GetInterfaces-method.
  
  
class Program
  
    {
  
        static void Main(string[] args)
  
        {
  
            Console.WriteLine(typeof(B).GetInterfaces().Length);
  
        }
  
    }
  
  
    public class A : IDisposable
  
    {
  
        public void Dispose()
  
        {
  
  
        }
  
    }
  
  
    public class B : A, ISerializable
  
    {
  
  
        public void GetObjectData(SerializationInfo info, StreamingContext context)
  
        {
  
  
        }
  
    }
</description><link>http://ayende.com/3091/count-the-interfaces#comment17</link><guid>http://ayende.com/3091/count-the-interfaces#comment17</guid><pubDate>Fri, 11 Jan 2008 10:05:52 GMT</pubDate></item><item><title>Dave commented on Count the interfaces...</title><description>"Without running this code, what does this print?"
  
  
Without running this code, nothing happens.  It is essential that you run the code to make it do something :)
</description><link>http://ayende.com/3091/count-the-interfaces#comment16</link><guid>http://ayende.com/3091/count-the-interfaces#comment16</guid><pubDate>Fri, 11 Jan 2008 09:57:34 GMT</pubDate></item><item><title>Stefan Wenig commented on Count the interfaces...</title><description>&gt; Eber, by that logic, GetBaseTypes() should return an array that contains all the inheritence tree. 
  
  
sure, if such a method existed (which is not the case), you'd expect it to do just that. but not by analogy with GetInterfaces, but simply because there is no multiple inheritance, so that would be about the only way that the plural makes sense.
</description><link>http://ayende.com/3091/count-the-interfaces#comment15</link><guid>http://ayende.com/3091/count-the-interfaces#comment15</guid><pubDate>Fri, 11 Jan 2008 09:20:37 GMT</pubDate></item><item><title>Brian commented on Count the interfaces...</title><description>I agree with Michael Morton, what else do you have in the following code that would implement the inherited interface?  An interface can't implement another interface, it can just inherit from it.  So it is up to the object implementing the interface to also implement each inherited interface of the implemented interface.  (that is hard to say).
  
  
</description><link>http://ayende.com/3091/count-the-interfaces#comment14</link><guid>http://ayende.com/3091/count-the-interfaces#comment14</guid><pubDate>Fri, 11 Jan 2008 02:44:31 GMT</pubDate></item><item><title>Andrey Shchekin commented on Count the interfaces...</title><description>It is interesting that your blog always tells me that I am trying to post a comment twice, and sometimes it actually posts it twice.
  
Maybe there are both AJAX and postback postings at once?
</description><link>http://ayende.com/3091/count-the-interfaces#comment13</link><guid>http://ayende.com/3091/count-the-interfaces#comment13</guid><pubDate>Thu, 10 Jan 2008 23:52:32 GMT</pubDate></item><item><title>Andrey Shchekin commented on Count the interfaces...</title><description>I think it is a simple solution to the following hierarchy:
  
IA
  
IB : IA
  
IC : IA
  
D : IB, IC
  
  
How many times should D implement methods of IA?
  
Once for each method.
  
Also, IB and IC can not implement or override a part of IA.
  
  
So it seems to be a simple solution for complex hierarchies.
</description><link>http://ayende.com/3091/count-the-interfaces#comment11</link><guid>http://ayende.com/3091/count-the-interfaces#comment11</guid><pubDate>Thu, 10 Jan 2008 23:50:47 GMT</pubDate></item><item><title>Andrey Shchekin commented on Count the interfaces...</title><description>I think it is a simple solution to the following hierarchy:
  
IA
  
IB : IA
  
IC : IA
  
D : IB, IC
  
  
How many times should D implement methods of IA?
  
Once for each method.
  
Also, IB and IC can not implement or override a part of IA.
  
  
So it seems to be a simple solution for complex hierarchies.
</description><link>http://ayende.com/3091/count-the-interfaces#comment12</link><guid>http://ayende.com/3091/count-the-interfaces#comment12</guid><pubDate>Thu, 10 Jan 2008 23:50:47 GMT</pubDate></item><item><title>Michael Morton commented on Count the interfaces...</title><description>What else would implement it?
  
  
An interface method cannot have an implementation so there is no way for IStartable to implement IDisposable, so it stands to reason that Pipeline would be providing the implementation for IDisposable, in some way or another.
</description><link>http://ayende.com/3091/count-the-interfaces#comment10</link><guid>http://ayende.com/3091/count-the-interfaces#comment10</guid><pubDate>Thu, 10 Jan 2008 23:44:17 GMT</pubDate></item><item><title>Eber Irigoyen commented on Count the interfaces...</title><description>is it an optimization in this case?
</description><link>http://ayende.com/3091/count-the-interfaces#comment9</link><guid>http://ayende.com/3091/count-the-interfaces#comment9</guid><pubDate>Thu, 10 Jan 2008 23:29:15 GMT</pubDate></item><item><title>Ayende Rahien commented on Count the interfaces...</title><description>Interestingly, yes.
  
But take a look at the generated IL. Pipeline actually implements IDispoable directly.
</description><link>http://ayende.com/3091/count-the-interfaces#comment8</link><guid>http://ayende.com/3091/count-the-interfaces#comment8</guid><pubDate>Thu, 10 Jan 2008 23:25:19 GMT</pubDate></item><item><title>Michael Morton commented on Count the interfaces...</title><description>From the help page for "Type.GetInterfaces Method", under "Return Value":
  
  
"An array of Type objects representing all the interfaces implemented or inherited by the current Type."
  
</description><link>http://ayende.com/3091/count-the-interfaces#comment7</link><guid>http://ayende.com/3091/count-the-interfaces#comment7</guid><pubDate>Thu, 10 Jan 2008 23:16:47 GMT</pubDate></item><item><title>Ayende Rahien commented on Count the interfaces...</title><description>Eber, by that logic, GetBaseTypes() should return an array that contains all the inheritence tree.
</description><link>http://ayende.com/3091/count-the-interfaces#comment6</link><guid>http://ayende.com/3091/count-the-interfaces#comment6</guid><pubDate>Thu, 10 Jan 2008 23:11:19 GMT</pubDate></item><item><title>Eber Irigoyen commented on Count the interfaces...</title><description>I don't know what the rules are, was just taking a logical (for me) guess, for me it does look like it implements 2 interfaces, you can cast that type to any of the two interfaces and pass it around
</description><link>http://ayende.com/3091/count-the-interfaces#comment5</link><guid>http://ayende.com/3091/count-the-interfaces#comment5</guid><pubDate>Thu, 10 Jan 2008 23:06:49 GMT</pubDate></item><item><title>Ayende Rahien commented on Count the interfaces...</title><description>Eber, does it look like it is implementing two interfaces?
  
Take a look at the compiled IL,btw
</description><link>http://ayende.com/3091/count-the-interfaces#comment4</link><guid>http://ayende.com/3091/count-the-interfaces#comment4</guid><pubDate>Thu, 10 Jan 2008 23:03:05 GMT</pubDate></item><item><title>Avish commented on Count the interfaces...</title><description>It's not always evident that GetInterfaces() gets all interfaces, including inherited ones (so the answer should be 2 unless IDisposable inherits another interface). 
  
I only remember this because in Boo's type system, GetInterfaces() only returns the immediate interfaces. You know, just to spice up your development. :)
</description><link>http://ayende.com/3091/count-the-interfaces#comment3</link><guid>http://ayende.com/3091/count-the-interfaces#comment3</guid><pubDate>Thu, 10 Jan 2008 21:31:36 GMT</pubDate></item><item><title>john commented on Count the interfaces...</title><description>Something tells me its not the 1 IStartable interface...
</description><link>http://ayende.com/3091/count-the-interfaces#comment2</link><guid>http://ayende.com/3091/count-the-interfaces#comment2</guid><pubDate>Thu, 10 Jan 2008 21:26:23 GMT</pubDate></item><item><title>Eber Irigoyen commented on Count the interfaces...</title><description>2...
  
what is the surprise?
</description><link>http://ayende.com/3091/count-the-interfaces#comment1</link><guid>http://ayende.com/3091/count-the-interfaces#comment1</guid><pubDate>Thu, 10 Jan 2008 20:55:46 GMT</pubDate></item></channel></rss>