From 71d0f8d8483767a823e2f69b355ac6e2915b34e8 Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Date: Sat, 25 Oct 2025 23:48:28 +0000 Subject: [PATCH] Fix issue Adding `UsedImplicitly` to `ExecutableAttribute` Fixes #281 --- readme.md | 11 ++++++++++- .../ExecutableAttribute/ExecutableAttribute.cs | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 684e3c40..10ad5c22 100644 --- a/readme.md +++ b/readme.md @@ -110,6 +110,15 @@ which gives you a report like: Then the ATM should retain the card And the atm should say the card has been retained +## IDE annotations + +This repository contains a small set of in-repo code-analysis annotations (see `src/TestStack.BDDfy/Properties/Annotations.cs`). + +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. + +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). + + This is only the tip of iceberg. Absolutely everything you do with BDDfy is extensible and customizable. You might see full documentation of BDDfy on the [TestStack documentation website](http://bddfy.teststack.net/). 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 * [Jake Ginnivan](https://github.com/JakeGinnivan) ## License -BDDfy is released under the MIT License. See the bundled license.txt file for details. +BDDfy is released under the MIT License. See the bundled license.txt file for details. \ No newline at end of file diff --git a/src/TestStack.BDDfy/Scanners/StepScanners/ExecutableAttribute/ExecutableAttribute.cs b/src/TestStack.BDDfy/Scanners/StepScanners/ExecutableAttribute/ExecutableAttribute.cs index d7e03dc0..7b64b30f 100644 --- a/src/TestStack.BDDfy/Scanners/StepScanners/ExecutableAttribute/ExecutableAttribute.cs +++ b/src/TestStack.BDDfy/Scanners/StepScanners/ExecutableAttribute/ExecutableAttribute.cs @@ -1,7 +1,19 @@ using System; +using TestStack.BDDfy.Annotations; namespace TestStack.BDDfy { + /// + /// This attribute is marked with + /// so that any method decorated with [Executable] (or derived GWT attributes) + /// is treated as "used implicitly" by code-analysis tools (ReSharper/Rider/etc). + /// + /// Reason: step methods are discovered via reflection at runtime, which can trigger + /// "unused" inspections in IDEs; marking the attribute with MeansImplicitUse prevents + /// those false positives and keeps IDE/test explorers tidy without requiring per-method + /// annotations such as [UsedImplicitly]. + /// + [MeansImplicitUse] [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class ExecutableAttribute(ExecutionOrder order, string stepTitle): Attribute {