feat: migrate NSubstitute Raise.Event/EventWith to Mock.Raise#46
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds NSubstitute Raise.Event / Raise.EventWith migration support to the NSubstitute code fix provider, aligning event-raising patterns with Mockolate’s Mock.Raise API.
Changes:
- Introduces new unit tests covering core
Raise.EventandRaise.EventWithrewrite scenarios. - Extends
NSubstituteCodeFixProviderto detect+= Raise.*(...)patterns on tracked substitutes and rewrite them tosub.Mock.Raise.<EventName>(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| Tests/Mockolate.Migration.Tests/NSubstituteCodeFixProviderTests.RaiseTests.cs | Adds test coverage for Raise-to-Mock.Raise migrations. |
| Source/Mockolate.Migration.Analyzers.CodeFixers/NSubstituteCodeFixProvider.cs | Implements Raise replacement detection and argument translation logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
This is addressed in release v0.5.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request adds support for migrating NSubstitute
Raise.EventandRaise.EventWithevent-raising patterns to the equivalent Mockolate event-raising syntax in the code fixer. It introduces logic to correctly translate various usages of event raising, handling different argument patterns, and adds comprehensive tests to ensure correctness.NSubstitute event raising migration:
FindAndBuildRaiseReplacementsto identify and translateRaise.EventandRaise.EventWithusages on event subscriptions to the appropriateMock.Raise.EventName(...)syntax, handling different argument scenarios (e.g., no arguments, only event args, or sender plus event args).ConvertAssertionAsync.Testing:
RaiseTestsinNSubstituteCodeFixProviderTests.RaiseTests.cswith multiple test cases covering all supported event-raising patterns, ensuring correct translation for delegate-type events, no-argument events, events with only event args, and events with both sender and event args.