Masstransit Analyzers

344 views Asked by At

In a brand new c# project Using Masstransit.Analyzers nuget package (https://masstransit-project.com/learn/analyzers.html#message-initializers)

If i call IPublishEndpoint.Publish<ISomeInterface>(new { random="fields"}) as expected a message is generated

Anonymous type is missing properties that are in the message contract 'ISomeInterface'. The following properties are missing: Name, Surname, etc,

If i create my own publisher using the decorator pattern

public interface IMyOwnPublishEndpoint{

  Task Publish<T>(object values, CancellationToken cancellationToken = default)
            where T : class;
}

public class MyOwnPublishEndpoint : IMyOwnPublishEndpoint
{
    private readonly IPublishEndpoint endpoint;
    MyOwnPublishEndpoint (IPublishEndpoint endpoint)
    {
        this.endpoint = endpoint;
    }

 public async Task Publish<T>(object values, CancellationToken cancellationToken = default)
            where T : class
    {
        await endpoint.Publish<T>(values,cancellationToken )
    }

}

When i call IMyOwnPublishEndpoint.Publish<ISomeInterface>(new { random="fields"})

The same message does not get generated

Why is this the case? Is perhaps the MassTransit Analyzer limited to a certain set of interfaces?

0

There are 0 answers