-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Support ref returns (c# 7) #568
Comments
Hi @tzachshabtay, thank you for reporting this. Quite frankly, my initial gut feeling is that it will be impossible to realize this feature in Moq. First, there are two roadblocks to be overcome before we could even start work in Moq: Road block 1: DynamicProxy does not currently appear to support
|
@stakx can you open an issue for DynamicProxy then? |
@tzachshabtay: Perhaps I will, just to get confirmation what I already suspect (with a fairly high degree of confidence): that DynamicProxy won't be able to support Moq 5 just might be able to support |
Will keep this in mind for v5
|
Refactored matrix updating logic to its own class. This means we can now mock it for our tests which helps us workaround the fact that we can no longer mock the ref return as moq does not support it (devlooped/moq#568).
My interface which I'm trying to mock has a ref return in it:
ref ModelMatrices GetModelMatrices();
The code for the interface is here:
https://github.com/tzachshabtay/MonoAGS/blob/734b13f467d33b5099b81d52f3d391448b41b9eb/Source/AGS.API/Objects/IModelMatrixComponent.cs#L36
If I just create my mock without overriding the behavior and then call
GetModelMatrices
on it, it crashes with:System.InvalidProgramException : Invalid IL code in Castle.Proxies.IObjectProxy:GetModelMatrices (): IL_0030: ret
And I don't see how I can setup the return?
If I do:
_myMock.Setup(m => m.GetModelMatrices()).Returns(ref something);
I get a compile error:
Error CS8153: An expression tree lambda may not contain a call to a method, property, or indexer that returns by reference (CS8153) (Tests)
The text was updated successfully, but these errors were encountered: