ExternalAnnotations
ExternalAnnotations copied to clipboard
Add MediatR
Adds annotations for MediatR, a widely used mediator library.
It marks as implicitly used all implementations of MediatR services implicitly added to the DI with services.AddMediatR()
.
May I suggest two more annotations? These get rid of the 'class' is never instantiated green suggestion.
<member name="T:MediatR.IRequest">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
<member name="T:MediatR.IRequest`1">
<attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" />
</member>
May I suggest two more annotations? These get rid of the 'class' is never instantiated green suggestion.
<member name="T:MediatR.IRequest"> <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> </member> <member name="T:MediatR.IRequest`1"> <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> </member>
Hey, @victor-borges .
You have two errors:
-
MeansImplicitUseAttribute
cannot be applied to interfaces, butUsedImplicitlyAttribute
will suffice -
IRequest
is not declared in "MediatR" assembly, it is from "MediatR.Contracts" (yes, it is located in the "Mediatr" namespace, but is packed into separate assembly, see here)
so, let me correct you: probably we need another file (MediatR.Contracts.xml
) with the following contents:
<?xml version="1.0" encoding="utf-8"?>
<assembly name="MediatR.Contracts">
<member name="T:MediatR.INotification">
<attribute ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>4</argument>
</attribute>
</member>
<member name="T:MediatR.IRequest">
<attribute ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>4</argument>
</attribute>
</member>
<member name="T:MediatR.IRequest`1">
<attribute ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>4</argument>
</attribute>
</member>
</assembly>
Please note I've added INotification
as well.
@hadrienbecle It would be nice of you if you'll add "Mediatr.Contracts.xml" to your PR.
May I suggest two more annotations? These get rid of the 'class' is never instantiated green suggestion.
<member name="T:MediatR.IRequest"> <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> </member> <member name="T:MediatR.IRequest`1"> <attribute ctor="M:JetBrains.Annotations.MeansImplicitUseAttribute.#ctor" /> </member>
Hey, @victor-borges .
You have two errors:
1. `MeansImplicitUseAttribute` cannot be applied to interfaces, but `UsedImplicitlyAttribute` will suffice 2. `IRequest` is not declared in "MediatR" assembly, it is from "MediatR.Contracts" (yes, it is located in the "Mediatr" _namespace_, but is packed into separate _assembly_, see [here](https://github.com/jbogard/MediatR/blob/master/src/MediatR.Contracts/IRequest.cs))
so, let me correct you: probably we need another file (
MediatR.Contracts.xml
) with the following contents:<?xml version="1.0" encoding="utf-8"?> <assembly name="MediatR.Contracts"> <member name="T:MediatR.INotification"> <attribute ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseTargetFlags)"> <argument>4</argument> </attribute> </member> <member name="T:MediatR.IRequest"> <attribute ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseTargetFlags)"> <argument>4</argument> </attribute> </member> <member name="T:MediatR.IRequest`1"> <attribute ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseTargetFlags)"> <argument>4</argument> </attribute> </member> </assembly>
Please note I've added
INotification
as well.@hadrienbecle It would be nice of you if you'll add "Mediatr.Contracts.xml" to your PR.
Thanks for the heads-up! I didn't pay attention to the changes made to the IRequest assembly location, I took those annotations out of a project made before 2022, back then it still lived in the main Mediatr assembly.