Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Conversation

@kzu
Copy link
Member

@kzu kzu commented Oct 21, 2020

No description provided.

kzu added 3 commits October 21, 2020 02:41
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.
@kzu kzu force-pushed the dev/codeanalysis branch from c623b7b to 135276b Compare October 21, 2020 08:12
kzu added 9 commits October 21, 2020 05:19
.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.
@kzu kzu force-pushed the dev/codeanalysis branch from e24d2dc to 3c39eef Compare October 23, 2020 21:00
@kzu kzu changed the base branch from master to main October 23, 2020 21:01
kzu added 4 commits October 23, 2020 19:57
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.
@moq moq deleted a comment from codecov-io Oct 23, 2020
kzu added 10 commits October 23, 2020 20:47
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.
kzu added 10 commits October 26, 2020 15:37
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.
@kzu kzu merged commit ea56825 into main Oct 26, 2020
@kzu kzu deleted the dev/codeanalysis branch October 26, 2020 22:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant