Is any of these initialization expressions better than any other?
IFoo foo1 =
new FooClass( );
IFoo foo2 = new Foo( );
Foo foo3 = new FooClass( );
Foo foo4 = new Foo( );
//compiler will do a lot of stuff to translate the CoClass(new Foo). but the generated IL Code is same for the above 4 cases(
newobj instance void *Lib.FooClass::.ctor()).
so they are equal if you dont carethe work of compiler.
Why is the hybrid type definition generated at all?
The original reason is to avoid the confusion of dealing with renamed classes, so user can write code to instantiate an "interface".
Is there a way to suppress the generation of the hybrid type definition?
not yet. There is no way to do so except manually.(both for tlbimp and tlbimp2)
4. Is there a way have methods that take an IFoo interface as a parameter in the IDL take an IFoo interface in the interop assembly instead of the hybrid type definition?
The default behavior: if the ifoo interface isn't default interface, then we will keep it the original one IFoo. but if the ifoo is default interface, we will translate the ifoo into coclass instead
if you want to change the default behavior, you can use other tools, such as tlbimp customization.
5. If tlbimp doesn't do this is there a way to have tlbimp2 do this?
Not sure what the "do" mean?