Repository navigation
fix: resolve MediatR/Mediator request types from referenced assemblies - #121
Conversation
|
Thanks for this. I want to make sure I understand the failure mode before merging, since I couldn't reproduce it. A few questions: On the module-name lookup: I checked what's actually inside these packages: Both On reproducing it: #122 (merged into Does that match the setup you were hitting the bug in, or was yours meaningfully different (multi-project solution, a specific package combination, etc.)? If you can point me to a minimal repro, I can turn it into a regression test. On On Once I know which of these is doing the actual work, happy to help get a regression test in and get this merged. |
|
Thanks for looking into this! So the MaxInheritors number was just pulled out of thin air really, the reason why things weren't quite working for me was that 50 was to low for the solutions I'm working on, I've reduced it 300. One of my solutions goes to 167 IRequestHandler implementations, wouldn't be surprised if some of our older ones goes beyond 300... I think your latest round of fixes, have helped with the module name look up stuff as well so I've dropped that. I also see you're looking at the Go To Handler stuff for .Send()? (yay!) |
…ating the handler search
4787a44 to
14d28cb
Compare
Well, I saw your PR, liked the idea but realized I was not comfortable not having any automated tests. So I added some yesterday and thought why not try add more tests related the feature you suggested :) |
…ating the handler search (#121)
…ler file Go to Handler resolves for a MediatR request (#123) * chore(deps): bump actions/setup-java in /.github/workflows (#124) Bumps [actions/setup-java](https://github.com/actions/setup-java) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](actions/setup-java@v6.0.0...v6.0.1) --- updated-dependencies: - dependency-name: actions/setup-java dependency-version: 6.0.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: navigate to handler from a Send/Publish call site and stop truncating the handler search (#121) * test: add file-resolution and caret-based lookup tests for MediatR Go to Handler Adds a way to verify which handler file the plugin resolves for a given request, both by name lookup (AssertHandlerFilesFor, run across the shared MediatR v12/v13/v14 fixture) and by placing a real caret via SDK text-control support and resolving the PSI node under it, mirroring how GoToHandlerAction gets its selected identifier in production. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0184Nxbg3pykkbbRL1E1o15M * fix: reset the other lookup expectation field to stop cross-test leakage The JetBrains test framework reuses one LookupTestBase instance across every [Test] method in a fixture (solution loading is too expensive to redo per test), so _expectedHandlerNames and _expectedHandlerFilePaths survived from whichever assertion ran last. Once a caret-file-lookup test set _expectedHandlerFilePaths, every later name-based test in the same fixture instance silently ran the file-path branch of DoTest against its stale expectation instead of its own assertion, failing CI with mismatched expected/actual handler paths. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0184Nxbg3pykkbbRL1E1o15M * fix: correct namespace and class name in GoToHandlerCaretTests request file * test: expand GoToHandlerCaretTests with additional caret-based resolution scenarios Adds tests for caret placement scenarios on identifiers not resolving to handlers, including namespace identifiers and MediatR `Send` calls. Refactors test logic to handle cases with no expected handler matches. * fix: rename variable in GoToHandlerCaretTests to improve test clarity Renames `TestName` to `TestMethodName` for better alignment with its purpose and to prevent ambiguity in test logic. * feat: add MediatR callsite classes for DotNetCore6 integration Introduces `MediatRCallsite` and `MediatorCallsite` classes to handle MediatR request sending with `CustomClassRequest` and `NewMediatorRequest`. * refactor: rename GoToHandlerCaretTests classes for consistency with MediatR naming conventions Renames classes and file references in GoToHandlerCaretTests to align with the MediatR naming standard, ensuring uniformity across test files. * chore: update changelog version header to 26.09.19XX * chore: ignore `TestResult.xml` test output in .gitignore --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yatmund Christiansen <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
Basically I just wanted to be able to use ALT + H / Go To handler directly from Mediator.Send() or the command within it and it wasn't quite working
Description
Go-to-handler did nothing on modern MediatR (12+) and Mediator setups. IsRequestTypeSupported looked up a PSI module named exactly "MediatR" or "Mediator" and resolved IBaseRequest/INotification from it, and Library.InitializeTypeElementsIfNeeded scoped the handler-interface lookup to that same single assembly. Since MediatR 10 those interfaces ship in MediatR.Contracts.dll, and Mediator's ship in Mediator.Abstractions.dll, so the types never resolved. IsRequest then returned false and FindHandlers returned nothing.
Resolve both the marker interfaces and the handler interfaces from the project module plus its references instead of a pinned assembly, and drop the now-unused moduleName plumbing.
Also: