This project is read-only.

new ushort GenericParameterCount { get; }

Topics: Metadata Model
May 11, 2010 at 11:33 PM
Edited May 12, 2010 at 4:33 PM

Why there is a 

new ushort GenericParameterCount { get; }

in INamedTypeDefinition? Can it be different than the value for the parameter count of ITypeDefinition interface?

May 12, 2010 at 1:01 AM

Since an INamedTypeDefinition is both an ITypeDefinition and an INamedTypeReference, it inherits the GenericParameterCount property twice, which leads the compiler to complain about an ambiguity. The additional declaration gets rid of the error. The same concrete property is always used implement all the different interface versions.

May 12, 2010 at 5:21 PM
Edited May 16, 2010 at 2:55 AM

Even if this it not a real problem with CCI, I usually do something like this:


public interface ISomethingGeneric {
    ushort GenericParameterCount { get; }

public interface IReference : ISomethingGeneric { }

public interface IDefinition : IReference { }

public interface ISomethingElse : ISomethingGeneric { }

public interface INamedDefinition : IDefinition, IReference, ISomethingElse {
    string Name { get; }

public class NamedDefinition : INamedDefinition {
    #region INamedDefinition Members
    public string Name { get { return "Hello"; } }

    #region ISomethingGeneric Members
    public ushort GenericParameterCount { get { return 1000; } }



 I do it without thinking. That's why I never encountered the interface inheritance problem you mentioned. I posted this Just for the sake of curiosity.

May 12, 2010 at 5:24 PM
Edited May 15, 2010 at 3:29 AM

The code and the message above was properly formatted but CodePlex rearranges it. Sorry.


In short: if I have some property or method collision I just create a specific interface and include it in the interfaces that I was using. That way the compiler understand that there is no collision but it's just the same property/method.

May 16, 2010 at 12:56 AM
Edited May 16, 2010 at 2:55 AM

I found the button to insert some code.