|
| 1 | +# ResultR VS Toolkit |
| 2 | + |
| 3 | +Supercharge your ResultR development workflow with instant navigation from requests to handlers and one-click scaffolding of new request/handler pairs. The ResultR VS Toolkit is the essential companion extension for developers using the ResultR library. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +### From Visual Studio Marketplace |
| 8 | + |
| 9 | +1. Open Visual Studio 2022 |
| 10 | +2. Go to **Extensions** → **Manage Extensions** |
| 11 | +3. Search for "ResultR" |
| 12 | +4. Click **Download** and restart Visual Studio |
| 13 | + |
| 14 | +### From GitHub Releases |
| 15 | + |
| 16 | +1. Download the `.vsix` file from the [releases page](https://github.com/AlanBarber/ResultR/releases) |
| 17 | +2. Double-click to install |
| 18 | +3. Restart Visual Studio |
| 19 | + |
| 20 | +## Requirements |
| 21 | + |
| 22 | +- Visual Studio 2022 (17.0 or later) |
| 23 | +- Projects using the [ResultR](https://www.nuget.org/packages/ResultR) library |
| 24 | + |
| 25 | +## Features |
| 26 | + |
| 27 | +### Go to Handler Navigation |
| 28 | + |
| 29 | +Instantly navigate from any `IRequest` or `IRequest<T>` type to its corresponding handler implementation. |
| 30 | + |
| 31 | +#### How to Use |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +1. Place your cursor on any `IRequest` type (variable, parameter, or class definition) |
| 36 | +2. Use one of these methods: |
| 37 | + - **Keyboard**: Press `Ctrl+R, Ctrl+H` |
| 38 | + - **Context Menu**: Right-click and select **"Go to Handler..."** |
| 39 | + |
| 40 | +#### What It Finds |
| 41 | + |
| 42 | +The toolkit searches your entire solution for handlers that implement: |
| 43 | +- `IRequestHandler<TRequest>` for `IRequest` types |
| 44 | +- `IRequestHandler<TRequest, TResponse>` for `IRequest<TResponse>` types |
| 45 | + |
| 46 | +It works across projects, so your handler can be in a completely different assembly. |
| 47 | + |
| 48 | +#### Example |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +```csharp |
| 53 | +// Place cursor on HelloWorldRequest and press Ctrl+R, Ctrl+H |
| 54 | +var request = new HelloWorldRequest(); |
| 55 | +var result = await dispatcher.Dispatch(request); |
| 56 | +``` |
| 57 | + |
| 58 | +The toolkit will navigate to: |
| 59 | + |
| 60 | +```csharp |
| 61 | +public class HelloWorldHandler : IRequestHandler<HelloWorldRequest> |
| 62 | +{ |
| 63 | + public async ValueTask<Result> HandleAsync(HelloWorldRequest request, CancellationToken cancellationToken) |
| 64 | + { |
| 65 | + // Handler implementation |
| 66 | + } |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +### Scaffold Request/Handler Pairs |
| 71 | + |
| 72 | +Quickly create new request and handler classes with proper namespaces and structure. |
| 73 | + |
| 74 | +#### How to Use |
| 75 | + |
| 76 | +1. In **Solution Explorer**, right-click on a project or folder |
| 77 | +2. Select **Add** → **ResultR Request / Handler...** |
| 78 | +3. Enter the request name (e.g., "HelloWorld") |
| 79 | +4. Click **Create** |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +#### What Gets Generated |
| 88 | + |
| 89 | +The toolkit creates a single `.cs` file containing both the request and handler: |
| 90 | + |
| 91 | +```csharp |
| 92 | +using ResultR; |
| 93 | + |
| 94 | +namespace HelloWorldApp |
| 95 | +{ |
| 96 | + public record HelloWorldRequest() : IRequest; |
| 97 | + |
| 98 | + public class HelloWorldHandler : IRequestHandler<HelloWorldRequest> |
| 99 | + { |
| 100 | + public async ValueTask<Result> HandleAsync(HelloWorldRequest request, CancellationToken cancellationToken) |
| 101 | + { |
| 102 | + throw new NotImplementedException(); |
| 103 | + } |
| 104 | + } |
| 105 | +} |
| 106 | +``` |
| 107 | + |
| 108 | +#### Smart Namespace Detection |
| 109 | + |
| 110 | +The toolkit automatically: |
| 111 | +- Detects your project's namespace conventions |
| 112 | +- Uses file-scoped namespaces if your project uses them |
| 113 | +- Uses block-scoped namespaces if that's your convention |
| 114 | +- Places the file in the correct folder with the correct namespace |
| 115 | + |
| 116 | +## Keyboard Shortcuts |
| 117 | + |
| 118 | +| Action | Shortcut | |
| 119 | +|--------|----------| |
| 120 | +| Go to Handler | `Ctrl+R, Ctrl+H` | |
| 121 | + |
| 122 | +## Troubleshooting |
| 123 | + |
| 124 | +### "No handler found" message |
| 125 | + |
| 126 | +This can happen if: |
| 127 | +- The handler doesn't exist yet |
| 128 | +- The handler is in a project that isn't loaded |
| 129 | +- The handler doesn't implement the correct interface |
| 130 | + |
| 131 | +### Navigation goes to wrong handler |
| 132 | + |
| 133 | +Ensure your handler implements the exact interface for your request type. For example: |
| 134 | +- `GetUserRequest : IRequest<User>` should have a handler implementing `IRequestHandler<GetUserRequest, User>` |
| 135 | + |
| 136 | +### Scaffold menu item not visible |
| 137 | + |
| 138 | +The "ResultR Request / Handler..." menu item only appears when you right-click on: |
| 139 | +- A C# project |
| 140 | +- A folder within a C# project |
| 141 | + |
| 142 | +## Links |
| 143 | + |
| 144 | +- [ResultR on NuGet](https://www.nuget.org/packages/ResultR) |
| 145 | +- [ResultR.Validation on NuGet](https://www.nuget.org/packages/ResultR.Validation) |
| 146 | +- [VS Marketplace](https://marketplace.visualstudio.com/items?itemName=AlanBarber.ResultR-VSToolkit) |
| 147 | +- [GitHub Repository](https://github.com/AlanBarber/ResultR) |
| 148 | +- [Report Issues](https://github.com/AlanBarber/ResultR/issues) |
0 commit comments