microsoft / vs-servicehub

The service broker libraries used by Visual Studio to exchange intra- and inter-process services
MIT License
20 stars 8 forks source link

Registration-driven additional interfaces on brokered service proxies #234

Closed AArnott closed 1 month ago

AArnott commented 1 month ago

Add interfaces to the client proxy based on brokered service registration

When a brokered service is registered, it now has the opportunity to identify which optional interfaces it implements so that its client will be able to simply cast the proxy to that interface to use it (or test for it). This registration uses type names rather that Type objects themselves so as to not defeat lazy loading of the assemblies that may declare these interfaces.

I also add a constructor to ExportBrokeredServiceAttribute to allow MEF-exported brokered services to indicate which optional interfaces they implement.

When used in Visual Studio, this change will need to be combined with a change to the VS host to offer this registration data and read it at startup for the pkgdef-based brokered services.

Closes #225

Rename AdditionalClientInterfaces to AdditionalServiceInterface

Because after all, the collection describes interfaces that the service is expected to implement.

While the purpose of the property is to inform which interfaces the client proxy should implement, in the event that we offer the reverse as well where client callbacks may have multiple interfaces, it will be important to be able to distinguish which interfaces are on the client vs. the service. And I'm thinking this wording will be more clear.

AArnott commented 1 month ago

@RyanToth3 Thanks for jumping on this so fast. I pushed another commit that you may want to look at. It allows MEF exported brokered services to easily opt-in to these optional interfaces.

@BertanAygun Do you think Gladstone could do something to register optional interfaces appropriately too?

RyanToth3 commented 1 month ago

@RyanToth3 Thanks for jumping on this so fast. I pushed another commit that you may want to look at. It allows MEF exported brokered services to easily opt-in to these optional interfaces.

@BertanAygun Do you think Gladstone could do something to register optional interfaces appropriately too?

I pinged Bertan about this change right after I reviewed it the first time. I think we do something very similiar in Gladstone already that we could now replace with this implementation. I'm not 100% though so I'll let Bertan comment.