Table of Contents

ISB004 Optional interfaces on exported brokered services are implemented

When a type is annotated with the [ExportBrokeredService] attribute, it may provide a list of optional interfaces that clients may also use.

All interfaces in the list must be implemented by the type.

Examples of patterns that are flagged by this analyzer

The following code generates a diagnostic.

[ExportBrokeredService("name", "1.0", typeof(IBar))] // IBar isn't actually implemented by the Foo class.
class Foo : IExportedBrokeredService, IFoo
{
}

Solution

Fix the error by implementing the IBar interface.

[ExportBrokeredService("name", "1.0", typeof(IBar))]
class Foo : IExportedBrokeredService, IFoo, IBar
{
}

Or remove the IBar interface from the list of optional interfaces.

[ExportBrokeredService("name", "1.0")]
class Foo : IExportedBrokeredService, IFoo
{
}