Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.14.40254" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.14.40254" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.14.40608" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.14.40608" PrivateAssets="all" />
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.6.36389" ExcludeAssets="runtime" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions New_Extensibility_Model/Samples/AsyncPackageAndMEF/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading