You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/extensibility/how-to-provide-brokered-service.md
+7-9Lines changed: 7 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -552,7 +552,7 @@ The default <xref:Microsoft.VisualStudio.Shell.ServiceBroker.ProvideBrokeredServ
552
552
By setting <xref:Microsoft.VisualStudio.Shell.ServiceBroker.ServiceAudience.Local?displayProperty=nameWithType>, you opt in to exposing your brokered service to other processes belonging to the same Visual Studio session.
553
553
554
554
If your brokered service *must* be exposed to Live Share guests, the <xref:Microsoft.VisualStudio.Shell.ServiceBroker.ProvideBrokeredServiceAttribute.Audience> must include <xref:Microsoft.VisualStudio.Shell.ServiceBroker.ServiceAudience.LiveShareGuest?displayProperty=nameWithType> and the <xref:Microsoft.VisualStudio.Shell.ServiceBroker.ProvideBrokeredServiceAttribute.AllowTransitiveGuestClients?displayProperty=nameWithType> property set to `true`.
555
-
**Setting these flags can introduce serious security vulnerabilities** and should not be done without first conforming to the guidance in [How to Secure a Brokered Service](how-to-secure-brokered-service.md).
555
+
**Setting these flags can introduce serious security vulnerabilities** and shouldn't be done without first conforming to the guidance in [How to Secure a Brokered Service](how-to-secure-brokered-service.md).
556
556
557
557
When you increment the version on your <xref:Microsoft.ServiceHub.Framework.ServiceMoniker>, you must register each version of your brokered service that you intend to respond to client requests for.
558
558
By supporting more than the most recent version of your brokered service, you help maintain backward compatibility for clients of your older brokered service version, which may be especially useful when considering the Live Share scenario where each version of Visual Studio that is sharing the session may be a different version.
@@ -574,7 +574,7 @@ Cross-platform readiness | ⚠️ Visual Studio for Windows specific code must b
574
574
575
575
To export your brokered service via MEF instead of using VS packages:
576
576
577
-
1. Confirm you have no code related to the last two sections. In particular, you should have no code that calls into <xref:Microsoft.VisualStudio.Shell.ServiceBroker.IBrokeredServiceContainer.Proffer%2A?displayProperty=nameWithType> and should not apply the <xref:Microsoft.VisualStudio.Shell.ServiceBroker.ProvideBrokeredServiceAttribute> to your package (if any).
577
+
1. Confirm you have no code related to the last two sections. In particular, you should have no code that calls into <xref:Microsoft.VisualStudio.Shell.ServiceBroker.IBrokeredServiceContainer.Proffer%2A?displayProperty=nameWithType> and shouldn't apply the <xref:Microsoft.VisualStudio.Shell.ServiceBroker.ProvideBrokeredServiceAttribute> to your package (if any).
578
578
1. Implement the `IExportedBrokeredService` interface on your brokered service class.
579
579
1. Avoid any main thread dependencies in your constructor or importing property setters. Use the `IExportedBrokeredService.InitializeAsync` method for initializing your brokered service, where main thread dependencies are allowed.
580
580
1. Apply the `ExportBrokeredServiceAttribute` to your brokered service class, specifying the information about your service moniker, audience, and any other registration-related information required.
@@ -650,7 +650,7 @@ internal class MefBrokeredService : IExportedBrokeredService, ICalculator
650
650
651
651
### Exporting multiple versions of your brokered service
652
652
653
-
The `ExportBrokeredServiceAttribute`may be applied to your brokered service multiple times to offer multiple versions of your brokered service.
653
+
The `ExportBrokeredServiceAttribute`can be applied to your brokered service multiple times to offer multiple versions of your brokered service.
654
654
655
655
Your implementation of the `IExportedBrokeredService.Descriptor` property should return a descriptor with a moniker that matches the one the client requested.
656
656
@@ -686,15 +686,13 @@ internal class MefBrokeredService : IExportedBrokeredService, ICalculator
686
686
}
687
687
```
688
688
689
-
A `null` versioned service may be exported to match any client request for the service regardless of version including a request with a `null` version.
690
-
691
-
Visual Studio 2022 Update 12 (17.12) and later allows an exported brokered service to return `null` from the `Descriptor` property in order to reject a client request.
692
-
This may be because the service is exported with a `null` catch-all version and doesn't offer an implementation of the version the client actually requested.
689
+
Beginning with Visual Studio 2022 Update 12 (17.12), a `null` versioned service can be exported to match any client request for the service regardless of version including a request with a `null` version.
690
+
Such a service can return `null` from the `Descriptor` property in order to reject a client request when it doesn't offer an implementation of the version the client requested.
693
691
694
692
### Rejecting a service request
695
693
696
-
A brokered service may reject a client's activation request by throwing from the <xref:Microsoft.VisualStudio.Shell.ServiceBroker.IExportedBrokeredService.InitializeAsync%2A> method.
697
-
Throwing will lead to a <xref:Microsoft.ServiceHub.Framework.ServiceActivationFailedException>being thrown back to the client.
694
+
A brokered service can reject a client's activation request by throwing from the <xref:Microsoft.VisualStudio.Shell.ServiceBroker.IExportedBrokeredService.InitializeAsync%2A> method.
695
+
Throwing causes a <xref:Microsoft.ServiceHub.Framework.ServiceActivationFailedException>to be thrown back to the client.
698
696
699
697
## Related content
700
698
-[Best Practices for Designing a Brokered Service](best-practices-design-brokered-service.md)
0 commit comments