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

Support for Xamarin.iOS and Xamarin.Android #102

Closed
JamWils opened this issue Mar 21, 2014 · 15 comments
Closed

Support for Xamarin.iOS and Xamarin.Android #102

JamWils opened this issue Mar 21, 2014 · 15 comments

Comments

@JamWils
Copy link

JamWils commented Mar 21, 2014

I've tried using Moq for unit testing on these platforms and seem unable to do so. Has anyone checked whether this is feasible or not? I think trying to move this to a PCL would help with this matter. I can look into it myself if that is fine? I'm new to helping out with an open source project. I love using moq for testing and would like to use it on those platforms.

@kzu
Copy link
Contributor

kzu commented Mar 21, 2014

I'm not sure those platforms support Reflection.Emit, required to generate
the dynamic proxies at run-time.

I'm pretty sure it won't be feasible in iOS, may work on Android though.

I'd first try to port Castle DynamicProxy, as that would be the major
milestone first.

Thanks!

/kzu

Daniel Cazzulino

On Fri, Mar 21, 2014 at 4:57 PM, JamWils notifications@github.com wrote:

I've tried using Moq for unit testing on these platforms and seem unable
to do so. Has anyone checked whether this is feasible or not? I think
trying to move this to a PCL would help with this matter. I can look into
it myself if that is fine? I'm new to helping out with an open source
project. I love using moq for testing and would like to use it on those
platforms.

Reply to this email directly or view it on GitHubhttps://github.com//issues/102
.

@JamWils
Copy link
Author

JamWils commented May 16, 2014

Hi kzu,

Sorry it took me so long to get back to you. I was pulled off Xamarin for a while and now I am back on it. I will look into the Castle DynamicProxy. I believe that Android support Reflection.Emit, but Xamarin.iOS definitely does not.

I'll get back to you on how I do with Castle DynamicProxy.

Thanks,
James

@kzu
Copy link
Contributor

kzu commented May 16, 2014

We had someone at Xamarin hack it to run on iOS but it will only ever work
on the simulator, not an actual device.

The only way I see this moving forward, is if we move to compile-time
generated proxies, by analyzing the test assembly code (Cecil or whatever),
and generating a [YourAssembly].Proxies.dll that Moq dynamically tries to
find at runtime. If it doesn't (i.e. that would be the case for
non-msbuild-generated proxies (desktop apps), then it would try to
dynamically generate them.

Or we can just say that we don't do anymore dynamic codegen and just fail
at runtime...

/kzu

On Fri, May 16, 2014 at 2:45 PM, JamWils notifications@github.com wrote:

Hi kzu,

Sorry it took me so long to get back to you. I was pulled off Xamarin for
a while and now I am back on it. I will look into the Castle DynamicProxy.
I believe that Android support Reflection.Emit, but Xamarin.iOS definitely
does not.

I'll get back to you on how I do with Castle DynamicProxy.

Thanks,
James

Reply to this email directly or view it on GitHubhttps://github.com//issues/102#issuecomment-43359496
.

@JamWils
Copy link
Author

JamWils commented May 17, 2014

Thanks,

I'll start looking around and playing with it and get back to you.

@machadogj
Copy link

Hi @JamWils, have you guys made a decision yet?

@JamWils
Copy link
Author

JamWils commented Mar 15, 2015

@machadogj, unfortunately, I just don't have the time to look into this like I was hoping too. If I ever get the chance I will let you know. It would be great to have moq running on the clients of both iOS and Android. I am spending most of my time on iOS Swift these days. Thanks!

@jamesathey
Copy link

I've made a lot of progress toward a working Xamarin.Android port of Castle.Core. I've submitted the first pull request, but there will need to be two or three more after that before the work is fully upstreamed.

If moq on Xamarin.Android matters to you as well, let @jonorossi know.

@jonorossi
Copy link

There shouldn't be a need to use Cecil or something else as DynamicProxy on the .NET Framework allows you to persist the dynamic assembly it creates to disk. I recall some people doing this to run NHibernate with proxy support under medium trust deployments many years ago. Take a look at the unit tests (in the base class) and you'll see just about every unit test also does this to run peverify after generating code. This might be a solution for iOS.

@jamesathey
Copy link

FYI, I have completed my moq4 port to Xamarin.Android. It passes all of the unit tests using my android branch of Castle. Once that android branch is merged into Castle, I will submit a pull request here for the changes to Moq.

@kzu
Copy link
Contributor

kzu commented Jan 13, 2016

Sounds great!

On Wed, Jan 13, 2016 at 1:32 PM jamesathey notifications@github.com wrote:

FYI, I have completed my moq4 port to Xamarin.Android
https://github.com/jamesathey/moq4/tree/android. It passes all of the
unit tests using my android branch of Castle. Once that android branch is
merged into Castle, I will submit a pull request here for the changes to
Moq.


Reply to this email directly or view it on GitHub
#102 (comment).

@stakx
Copy link
Contributor

stakx commented Jun 27, 2017

@jamesathey, @JamWils, I would like to close this issue for two reasons:

  1. I think it would be better to track support for Xamarin.iOS and Xamarin.Android separately. Judging from the above information, these two platforms have rather different support for dynamic type generation, and making Moq work on them will likely involve finding different solutions for each.

    May I suggest that, if you are still interested in support for those targets, you re-open a separate issue per specific target?

  2. It seems that work on this has slowed, or even stalled; both here at the Moq repository, and over at Castle.Core's.

    @jamesathey, you appear to have been successful of getting Castle.Core to run on Xamarin.Android. If I interpret Mono: support Xamarin.Android castleproject/Core#135 correctly, it took some modifications based on Castle's .NET Standard 1.3 target? Are you still planning to send PRs towards Castle.Core to get them to support the Xamarin.Android target directly? That would probably be a precondition before more work can be done on Moq.

@karlingen
Copy link

Here's an alternative that should work on Xamarin.iOS, Xamarin.Android, Xamarin.UWP https://github.com/kentcb/PCLMock

@stakx
Copy link
Contributor

stakx commented Jun 13, 2018

Also, stay tuned for Moq 5, which also performs compile-time code generation instead of runtime dynamic proxying.

@karlingen
Copy link

@stakx Where can I subscribe to Moq 5 updates? :)

@stakx
Copy link
Contributor

stakx commented Jun 14, 2018

Subscribe to the https://github.com/moq/moq repo where v5 is being developed. You can also join Moq's Gitter chat at https://gitter.im/moq/moq.

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

No branches or pull requests

7 participants