-
Notifications
You must be signed in to change notification settings - Fork 0
ResultR.VSToolkit
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.
- Open Visual Studio 2022
- Go to Extensions → Manage Extensions
- Search for "ResultR"
- Click Download and restart Visual Studio
- Download the
.vsixfile from the releases page - Double-click to install
- Restart Visual Studio
- Visual Studio 2022 (17.0 or later)
- Projects using the ResultR library
Instantly navigate from any IRequest or IRequest<T> type to its corresponding handler implementation.
- Place your cursor on any
IRequesttype (variable, parameter, or class definition) - Use one of these methods:
-
Keyboard: Press
Ctrl+R, Ctrl+H - Context Menu: Right-click and select "Go to Handler..."
-
Keyboard: Press
The toolkit searches your entire solution for handlers that implement:
-
IRequestHandler<TRequest>forIRequesttypes -
IRequestHandler<TRequest, TResponse>forIRequest<TResponse>types
It works across projects, so your handler can be in a completely different assembly.
// Place cursor on HelloWorldRequest and press Ctrl+R, Ctrl+H
var request = new HelloWorldRequest();
var result = await dispatcher.Dispatch(request);The toolkit will navigate to:
public class HelloWorldHandler : IRequestHandler<HelloWorldRequest>
{
public async ValueTask<Result> HandleAsync(HelloWorldRequest request, CancellationToken cancellationToken)
{
// Handler implementation
}
}Quickly create new request and handler classes with proper namespaces and structure.
- In Solution Explorer, right-click on a project or folder
- Select Add → ResultR Request / Handler...
- Enter the request name (e.g., "HelloWorld")
- Click Create
The toolkit creates a single .cs file containing both the request and handler:
using ResultR;
namespace HelloWorldApp
{
public record HelloWorldRequest() : IRequest;
public class HelloWorldHandler : IRequestHandler<HelloWorldRequest>
{
public async ValueTask<Result> HandleAsync(HelloWorldRequest request, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
}
}The toolkit automatically:
- Detects your project's namespace conventions
- Uses file-scoped namespaces if your project uses them
- Uses block-scoped namespaces if that's your convention
- Places the file in the correct folder with the correct namespace
| Action | Shortcut |
|---|---|
| Go to Handler | Ctrl+R, Ctrl+H |
This can happen if:
- The handler doesn't exist yet
- The handler is in a project that isn't loaded
- The handler doesn't implement the correct interface
Ensure your handler implements the exact interface for your request type. For example:
-
GetUserRequest : IRequest<User>should have a handler implementingIRequestHandler<GetUserRequest, User>
The "ResultR Request / Handler..." menu item only appears when you right-click on:
- A C# project
- A folder within a C# project
Built with ❤️ for the C# / DotNet community.