Proposal: External ReSharper Annotations
See original GitHub issueReSharper or Rider - two very commonly used utilities for programming in c# - looks through your code to determine whether or not something is used or not, and “complains” if it’s not. .
And since Endpoints(And Validators) are never directly accessed in the code, this warning will always show up on all endpoints and validator classes
There are three ways of removing this warning:
- Actually using it (which does not make sense in this context)
- Adding the [UsedImplicitly] Attribute from JetBrains.Annotations to the class directly*, or to the base class using the
ImplicitUseTargetFlags.WithInheritors
parameter on the Attribute - Using so-called External Annotations. Jetbrains has some built-in ones, which they share on GitHub
As these Attributes do not get compiled when you build - as they’re entirely there to help the developer - I do not believe simply adding these to the base classes does anything (Although, I might be wrong). Because of this, I believe you, as a library author, realistically only have one way of adding them, and that’s option 3 - External Annotations.
Now, I don’t know how to distribute these External Annotations - if you have to make a separate FastEndpoints.ExternalAnnotations
NuGet package, or if you could add them to the base FastEndpoints
package, or what have you. You could also maybe send a Pull Request to JetBrains’ own list of External Annotations and ask them to add it to their list. However you do it is up to you, really.
I have an ExternalAnnotations file I made yesterday (This does not include the new features added in 4.5.0, so you’d have to add those yourself, or I could help if this is something you want to pursue).
Here’s the 4.4.0 file (This makes Access
implicit for all inheritors of the various Endpoints/Validators(That’s what the 1
and 4
means respectively)). I never considered before writing this that maybe I could add it to the BaseEndpoint
directly, removing a lot of boilerplate. I’ll test this and update the post
<?xml version="1.0" encoding="utf-8"?>
<assembly name="FastEndpoints">
<!-- <Endpoints> -->
<member name="T:FastEndpoints.Endpoint`3">
<attribute
ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseKindFlags,JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>1</argument>
<argument>4</argument>
</attribute>
</member>
<member name="T:FastEndpoints.Endpoint`2">
<attribute
ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseKindFlags,JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>1</argument>
<argument>4</argument>
</attribute>
</member>
<member name="T:FastEndpoints.EndpointWithoutRequest">
<attribute
ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseKindFlags,JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>1</argument>
<argument>4</argument>
</attribute>
</member>
<member name="T:FastEndpoints.EndpointWithoutRequest`1">
<attribute
ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseKindFlags,JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>1</argument>
<argument>4</argument>
</attribute>
</member>
<member name="T:FastEndpoints.EndpointWithMapping`3">
<attribute
ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseKindFlags,JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>1</argument>
<argument>4</argument>
</attribute>
</member>
<!-- </End...points> -->
<!-- <Validators> -->
<member name="T:FastEndpoints.Validator`1">
<attribute
ctor="M:JetBrains.Annotations.UsedImplicitlyAttribute.#ctor(JetBrains.Annotations.ImplicitUseKindFlags,JetBrains.Annotations.ImplicitUseTargetFlags)">
<argument>1</argument>
<argument>4</argument>
</attribute>
</member>
<!-- <Validators/>-->
</assembly>
* This is what I’ve been doing so far. For reference, these attributes can also be applied to fields, properties (including specifically on get
, set
, init
), methods, and so on - practically everywhere you can add Attributes
Issue Analytics
- State:
- Created a year ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
yep sounds like a plan. will push a new beta out first thing tomorrow morning. gonna doze off for the day now. ciao!
beautiful… i’ll close the issue for now. feel free to reopen if needed.