Skip to content

GeneratedComClass doesn't apply to inherited classes #94357

@jtschuster

Description

@jtschuster

Placing GeneratedComClass on a base class doesn't enable deriving types to work with source generated COM.

Should we check for base classes that have the IComExposedDetails as well here?
https://github.com/dotnet/runtime/blob/df6fdefa27068126794b253d4d822706221a92db/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/IComExposedDetails.cs#L21C49-L21C49

	[GeneratedComInterface]
	[Guid("c5356681-8f8c-423a-959c-2d91f17215d3")]
	internal partial interface IFoo
	{
		int get();
	}

	[GeneratedComClass]
	[Guid("9f826481-4d92-4499-ab26-c40d9f77435b")]
	internal partial class FooBase : IFoo
	{
		public int get() => 42;
	}

	internal class Foo<T> :FooBase
	{
	}
int Main()
{
                        var cw = new StrategyBasedComWrappers();
			var foo = new Foo<int>();
			nint iptr = cw.GetOrCreateComInterfaceForObject(foo, CreateComInterfaceFlags.None);
			IFoo f = (IFoo)cw.GetOrCreateObjectForComInstance(iptr, CreateObjectFlags.None); // Fails - iptr does not implement IFoo
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions