Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create dedicated setup type for SetupAllProperties #1234

Merged
merged 6 commits into from
Feb 15, 2022

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Feb 13, 2022

This is a continuation of #1204, where a dedicated setup type was created for single stubbed properties' accessors (i.e. SetupProperty). Thanks to #1203, the same can also be done for SetupAllProperties.

A few additional notes:

  • This gets rid of the RemoveAllPropertyAccessorSetups method in SetupCollection, restoring it to an add-only collection, which in turn means its use of lock-ing could be optimized in a similar fashion as was done for InvocationCollection.

  • Gets rid of the AutoSetupPropertiesDefaultValueProvider hack and simplifies the interception pipeline.

  • Moq should become a little more efficient in principle, since there will be fewer setups created overall.

Fixes #1066, likely fixes #1231.

@stakx stakx force-pushed the stubbedpropertiessetup branch 3 times, most recently from c3f00b4 to 24d318d Compare February 13, 2022 21:41
@stakx stakx added this to the 4.17.1 milestone Feb 13, 2022
@stakx stakx force-pushed the stubbedpropertiessetup branch 5 times, most recently from ab1dc7c to ac9de6e Compare February 13, 2022 23:56
@stakx stakx merged commit 4d052c1 into devlooped:main Feb 15, 2022
@stakx stakx deleted the stubbedpropertiessetup branch February 15, 2022 12:11
@stakx stakx restored the stubbedpropertiessetup branch March 6, 2022 09:58
@stakx stakx deleted the stubbedpropertiessetup branch March 6, 2022 09:59
@mo-russo
Copy link

mo-russo commented Aug 3, 2022

Hello @stakx, since we got version 4.18.1, our mocks' subclasses that call SetupAllProperties are crashing.

public class MyInterfaceMock : Mock<IMyInterface>
{
  public MyInterfaceMock ()
  {
    SetupAllProperties(); // Crashes here
  }
}

This isn't allowed anymore?

@stakx
Copy link
Contributor Author

stakx commented Aug 3, 2022

@mo-russo, this is a regression. Could you please report the above again in a new issue, so that we can properly track it? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants