OK I've managed to get this working for the most part... bear with me.
say we want to resolve: "Windows.Foundation.Collections.IVector`1<Microsoft.UI.Xaml.Controls.ColumnDefinition>"
broadly speaking, this is what needs to happen.
Create a MetaDataLocator - this is similar to how we're creating our delegates. It doesn't inherit from IUnknown, and has 1 method called "Locate"... but more on this in a bit!
Call RoParseTypeName. This gives us an array of name elements i.e.: ["Windows.Foundation.Collections.IVector`1", "Microsoft.UI.Xaml.Controls.ColumnDefinition"]
Use this info to call RoGetParameterizedTypeInstanceIID.
As RoGetParameterizedTypeInstanceIID does its thing, it'll pump us for information - by you guessed it! calling our "Locate" function.
we are provided with:
a name of a typedef
and a pointer to an IRoSimpleMetaDataBuilder interface. (I've written an interface library for this one).
We need to dig in the metadata for that info, then call the correct method of the builder to send it on.
A call to RoGetMetaDataFile will get us an pointer to a IMetadataImport2 interface. This is what we should use to find stuff.
In our scenario, the first time "Locate" is called we're asked to resolve "Windows.Foundation.Collections.IVector`1" So we need to determine what this is.. (a paramatised interface). Therefore we should call builder.SetParameterizedInterface(PIID, NumParams).
Next time around we get "Microsoft.UI.Xaml.Controls.RowDefinition". This is a class. So this time we should call builder.SetRuntimeClassSimpleDefault(ClassName, DefaultInterface, DefaultInterfaceIID).
DefaultInterfaceIID is optional though can be left null. In this case Locate() would be called a third time asking us to resolve the default interface (Microsoft.UI.Xaml.Controls.IRowDefinition). Because this is a non-paramatised interface, we'd then call builder.SetWinRtInterface(IID).
Once RoGetParameterizedTypeInstanceIID is satisfied it'll spit out what it thinks the IID is. If we call the wrong method on IRoSimpleMetaDataBuilder or provide bad info, then unsurprisingly we get an incorrect IID as a result!
I'll do a bit of a tidy up, and pop some code up in a day or two