File tree Expand file tree Collapse file tree
New_Extensibility_Model/Samples/AsyncPackageAndMEF Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 </PropertyGroup >
1212
1313 <ItemGroup >
14- <PackageReference Include =" Microsoft.VisualStudio.Extensibility.Sdk" Version =" 17.14.40254 " PrivateAssets =" all" />
15- <PackageReference Include =" Microsoft.VisualStudio.Extensibility.Build" Version =" 17.14.40254 " PrivateAssets =" all" />
14+ <PackageReference Include =" Microsoft.VisualStudio.Extensibility.Sdk" Version =" 17.14.40608 " PrivateAssets =" all" />
15+ <PackageReference Include =" Microsoft.VisualStudio.Extensibility.Build" Version =" 17.14.40608 " PrivateAssets =" all" />
1616 <PackageReference Include =" Microsoft.VisualStudio.SDK" Version =" 17.6.36389" ExcludeAssets =" runtime" />
1717 </ItemGroup >
1818</Project >
Original file line number Diff line number Diff line change @@ -208,6 +208,18 @@ protected override void InitializeServices(IServiceCollection serviceCollection)
208208}
209209```
210210
211+ We also need to declare that `MyBrokeredService ` is provided by this extension . This information is provided by a `BrokeredServices ` entry in the pkgdef file . But we can
212+ have that automatically generated by adding the following attribute to the `AsyncPackage ` class :
213+
214+ ```cs
215+ [ProvideBrokeredServiceHubService (IMyBrokeredService .Configuration .ServiceName , Audience = ServiceAudience .Local | ServiceAudience .RemoteExclusiveClient )]
216+ public sealed class MyPackage : AsyncPackage
217+ {
218+ ```
219+
220+ Note that the brokered service is provided by the VisualStudio .Extensibility part of the extension . We simply leverage the ability of attributes on the `AsyncPackge ` to
221+ automatically generate the necessary pkgdef entries .
222+
211223Now the `AsyncPackage ` can retrieve a [proxy of the brokered service ](https :// microsoft.github.io/vs-streamjsonrpc/docs/proxies.html#proxy-traits) and interact with it:
212224
213225```cs
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ namespace AsyncPackageAndMEF;
1313[ PackageRegistration ( UseManagedResourcesOnly = true , AllowsBackgroundLoading = true ) ]
1414[ Guid ( MyPackage . PackageGuidString ) ]
1515[ ProvideService ( typeof ( MyService ) , IsAsyncQueryable = true ) ]
16+ [ ProvideBrokeredServiceHubService ( IMyBrokeredService . Configuration . ServiceName , Audience = ServiceAudience . Local | ServiceAudience . RemoteExclusiveClient ) ]
1617public sealed class MyPackage : AsyncPackage
1718{
1819 public const string PackageGuidString = "ac1de0e2-bc69-4a63-bb7e-15f3274448c7" ;
You can’t perform that action at this time.
0 commit comments