diff --git a/New_Extensibility_Model/Samples/AsyncPackageAndMEF/AsyncPackageAndMEF.csproj b/New_Extensibility_Model/Samples/AsyncPackageAndMEF/AsyncPackageAndMEF.csproj index 801e7e55..f378dea0 100644 --- a/New_Extensibility_Model/Samples/AsyncPackageAndMEF/AsyncPackageAndMEF.csproj +++ b/New_Extensibility_Model/Samples/AsyncPackageAndMEF/AsyncPackageAndMEF.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/New_Extensibility_Model/Samples/AsyncPackageAndMEF/README.md b/New_Extensibility_Model/Samples/AsyncPackageAndMEF/README.md index 6b36f1f2..66945a9a 100644 --- a/New_Extensibility_Model/Samples/AsyncPackageAndMEF/README.md +++ b/New_Extensibility_Model/Samples/AsyncPackageAndMEF/README.md @@ -208,6 +208,18 @@ protected override void InitializeServices(IServiceCollection serviceCollection) } ``` +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 +have that automatically generated by adding the following attribute to the `AsyncPackage` class: + +```cs +[ProvideBrokeredServiceHubService(IMyBrokeredService.Configuration.ServiceName, Audience = ServiceAudience.Local | ServiceAudience.RemoteExclusiveClient)] +public sealed class MyPackage : AsyncPackage +{ +``` + +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 +automatically generate the necessary pkgdef entries. + Now 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: ```cs diff --git a/New_Extensibility_Model/Samples/AsyncPackageAndMEF/VSSDK/MyPackage.cs b/New_Extensibility_Model/Samples/AsyncPackageAndMEF/VSSDK/MyPackage.cs index 824260a8..1e25fc29 100644 --- a/New_Extensibility_Model/Samples/AsyncPackageAndMEF/VSSDK/MyPackage.cs +++ b/New_Extensibility_Model/Samples/AsyncPackageAndMEF/VSSDK/MyPackage.cs @@ -13,6 +13,7 @@ namespace AsyncPackageAndMEF; [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] [Guid(MyPackage.PackageGuidString)] [ProvideService(typeof(MyService), IsAsyncQueryable = true)] +[ProvideBrokeredServiceHubService(IMyBrokeredService.Configuration.ServiceName, Audience = ServiceAudience.Local | ServiceAudience.RemoteExclusiveClient)] public sealed class MyPackage : AsyncPackage { public const string PackageGuidString = "ac1de0e2-bc69-4a63-bb7e-15f3274448c7";