Skip to content

Reconsider using Moq in testing #90222

@GerardSmit

Description

@GerardSmit

I'm not sure if .NET is aware of the current situation with Moq, but they've added a analyzer in version 4.20 that asks the developer in the IDE through warnings to support the project through an external closed-source library "SponsorLink".

This is done by checking if you're a sponsor of the GitHub maintainer by getting the hash of the developer, and checking through an infrastructure that is unknown by the public. If you're not an supporter, the first time the build is delayed by 1 second, then by 100ms (so you read the message).

This means the analyzer does the following:

  1. Get the e-mail from your computer
  2. Hash the e-mail and send it to an unknown server
    Note: As noted by other people this could also be an GDPR issue...
  3. Write and read files to check if you already seen the message
    Note: This had a bug in Mac/Linux (see https://github.com/moq/moq/issues/1369) which caused the build to fail...
  4. Add an warning to the error list and delay the build
    Note: If WarnAsError is enabled, you'll get an error instead.

An .NET/Roslyn maintainer (@sharwell) already reached out 4 months ago to the developer that this should not be done through analyzers: devlooped/SponsorLink#10, but this was ignored.

Moq is used by the testing infrastructure (this can be checked here: https://github.com/search?q=repo%3Adotnet%2Fruntime+language%3AXML+Moq&type=code). The used version, 4.18.4, does not include SponsorLink. Version 4.20 or higher is affected.

For more information, see the active issue: https://github.com/moq/moq/issues/1372

An example of SponsorLink blocking the build:

image

More information about SponsorLink can be found here: https://github.com/devlooped/SponsorLink/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions