Skip to content

Commit 56b2598

Browse files
authored
Fix issue Adding UsedImplicitly to ExecutableAttribute (#291)
Fixes #281
1 parent 49585ea commit 56b2598

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

readme.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ which gives you a report like:
110110
Then the ATM should retain the card
111111
And the atm should say the card has been retained
112112

113+
## IDE annotations
114+
115+
This repository contains a small set of in-repo code-analysis annotations (see `src/TestStack.BDDfy/Properties/Annotations.cs`).
116+
117+
Notably, the attribute classes used for step discovery (for example `ExecutableAttribute` and the GWT attribute variants) are marked with a local `MeansImplicitUse` attribute. That makes methods decorated with `[Executable]` (or `[Given]`, `[When]`, `[Then]`, etc.) be treated as "used implicitly" by IDEs such as ReSharper or Rider. The effect: you won't see "unused" inspections on step methods even though they're invoked via reflection at runtime.
118+
119+
If you prefer to use the official `JetBrains.Annotations` NuGet package instead of the in-repo annotations, you can replace the local attributes and add the package as a development-only dependency (use `PrivateAssets="all"` on the package reference so it doesn't become transitive).
120+
121+
113122
This is only the tip of iceberg. Absolutely everything you do with BDDfy is extensible and customizable.
114123
You might see full documentation of BDDfy on the [TestStack documentation website](http://bddfy.teststack.net/).
115124
Oh and while you are there don't forget to checkout other cool projects from [TestStack](http://www.teststack.net/).
@@ -120,4 +129,4 @@ Oh and while you are there don't forget to checkout other cool projects from [Te
120129
* [Jake Ginnivan](https://github.com/JakeGinnivan)
121130

122131
## License
123-
BDDfy is released under the MIT License. See the bundled license.txt file for details.
132+
BDDfy is released under the MIT License. See the bundled license.txt file for details.

src/TestStack.BDDfy/Scanners/StepScanners/ExecutableAttribute/ExecutableAttribute.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
using System;
2+
using TestStack.BDDfy.Annotations;
23

34
namespace TestStack.BDDfy
45
{
6+
/// <summary>
7+
/// This attribute is marked with <see cref="TestStack.BDDfy.Annotations.MeansImplicitUseAttribute"/>
8+
/// so that any method decorated with <c>[Executable]</c> (or derived GWT attributes)
9+
/// is treated as "used implicitly" by code-analysis tools (ReSharper/Rider/etc).
10+
///
11+
/// Reason: step methods are discovered via reflection at runtime, which can trigger
12+
/// "unused" inspections in IDEs; marking the attribute with MeansImplicitUse prevents
13+
/// those false positives and keeps IDE/test explorers tidy without requiring per-method
14+
/// annotations such as <c>[UsedImplicitly]</c>.
15+
/// </summary>
16+
[MeansImplicitUse]
517
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
618
public class ExecutableAttribute(ExecutionOrder order, string stepTitle): Attribute
719
{

0 commit comments

Comments
 (0)