This repository was archived by the owner on Jun 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 75
Migrating to Stunts and Roslyn source generator proxies #48
Merged
Conversation
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
Lots of changes, but mostly to accomodate API changes in Stunts, removing all old sources from it from Moq repo, and adapting to the new ways with centralized package versioning and simplified targets layouts, also enabled by a shiny new nugetizer too. This is still using the DynamicProxy-based factory, pending migration to the new Roslyn-based source generator approach in Stunts.
.NETCore doesn't check for the strong-name on ubuntu/mac.
The Stunts project provides sample source-code based manual stunts that can be used for testing or exploration, without depending on generated proxies at all, which can simplify some testing scenarios.
At least initially, it doesn't make sense to force users to install the Moq.DynamicProxy when they are not on a C# 9 project does not seem like a great idea. So we drop the standalone package, make it built-in via the Moq.Package project, and register the factory automatically whenever C# 9 isn't supported.
This makes things not only more discoverable and predictable, but also means a linker won't link away the dependency and it will perform better too since there is no reflection involved. This follows the Stunts design too.
Cleanup CodeAnalysis with just the stuff we need, move CodeFix stuff over to Moq.StaticProxy. Add tests for the codegen too.
For some weird reason, we're getting empty coverage reports, so turn it off for now. Keep generating and uploading the reports as artifacts so we can check every now and then to see if it's (hopefully) fixed by RTM.
We had this extra folder level because we had Stunts in the same repository before, but we don't need that anymore.
Support both regular fluent mock setup:
mock.Foo.Bar.Baz.Returns("hi");
as well as setup-style for strict mocks:
mock.Setup(x => x.Foo.Bar.Baz).Returns("hi");
Now that Stunts doesn't force the multitargeting, we don't need to multitarget either in Moq.
Both static and dynamic generators should automatically be available for transitive packages too, to simplify deployment and consumption. This follows the Stunts model too.
This is a remaining from pre-NS2 API era.
Not entirely sure why, but this is the only instance where TypeInfo seems to behave different than Type and causes the RefOutTests to break.
We are not using the attribute for codegen or at run-time, to just remove it.
This mimics the Syntax.Setup(), and a future analyzer will later on suggest a refactoring to add `using Moq.Syntax` and replace the extension method invocation with simply `Setup()`.
This ensures minimal disruption for projects using published stable versions of Moq, while still allowing rapid iteration and convenient local dogfooding of locally-produced packages.
The condition was buggy, since the RegisterStaticMockFactory property isn't even set if source generators aren't supported. The right check is to check for non-true instead. Also, the EmitMoqSource isn't necessary since the EmitStuntSource will already write the sources to %TEMP%.
Otherwise, fixup only replaces the pragmas too.
This is where we'll add the diagnostic and codefix tests, just like we have in Stunts
They should pass on all supported platforms before we push a package to the CI feed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.