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

Default value ILookup<> in loose mode is null #1391

Open
ggirard07 opened this issue Aug 11, 2023 · 1 comment
Open

Default value ILookup<> in loose mode is null #1391

ggirard07 opened this issue Aug 11, 2023 · 1 comment

Comments

@ggirard07
Copy link

Based on wiki, and as ILookup<> inherits from IEnumerable<>, I would expect the default value in loose mode to be an empty lookup, not null.

returns default values or empty arrays, enumerables, etc

Am I missing something here?

@stakx
Copy link
Contributor

stakx commented Aug 11, 2023

Hi @ggirard07, IIRC the code behind DefaultValue.Empty performs a strict type check and doesn't take type inheritance into account.

Before you ask: yes, of course this could be changed. We've had similar requests in the past. (If I find the time, I'll link to some of them later.) However, I have been hesitant to change the behavior of DefaultValue.Empty because it is a core part of Moq and functional changes to it it could affect much pre-existing user code.

Now that Moq vNext has been shelved (for the time being) and we're free to do a new major version, perhaps we'll be able to change that behavior in v5.

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

No branches or pull requests

2 participants