Bug 149 - RegexOptions.Compiled is not available on MonoDroid
Summary: RegexOptions.Compiled is not available on MonoDroid
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 1.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-08-02 17:07 UTC by anthony taranto
Modified: 2011-08-09 21:35 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description anthony taranto 2011-08-02 17:07:41 UTC
I understand that compiling regexes may not be possible on all platforms, but including the Compiled flag on all platforms would improve portability. Compiled can be equivalent to None on unsupported platforms.
Comment 1 Jonathan Pobst 2011-08-02 17:35:42 UTC
Our class libraries target the same subset as Silverlight.  Even if we add Compiled, it still will not exist for Silverlight or WinPhone7, so I'm afraid portability is never going to be accomplished.

Your best bet is probably to store the correct enum value as an int based on whether you are on the desktop or mobile, and pass that to your Regex.

int options = 0;
Regex r = new Regex ("", (RegexOptions)options);
Comment 2 anthony taranto 2011-08-02 18:17:35 UTC
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regexoptions%28v=vs.95%29.aspx

The docs describe Compiled as being "Present only in Silverlight for Windows Phone, but not supported."
Comment 3 Aaron Bockover 2011-08-02 19:05:13 UTC
The reason we filed this bug was that our code works on WP7, but does not work on MonoDroid. Silverlight and Silverlight for Windows Phone are similar, but not the same.

Having the enum value present in MonoDroid would be welcome, especially since AFAIK Reflection Emit works on MonoDroid (JIT), but not on MonoTouch (AOT). On MonoTouch, the Compiled option could just be ignored by the runtime.

Please reconsider this.
Comment 4 Jonathan Pobst 2011-08-02 19:15:33 UTC
Sorry, I only double checked the Silverlight profile.  I didn't realize it was in the WinPhone7 profile.

Mono does not have compiled RegularExpressions enabled so it will be like WinPhone7 and won't actually provide any benefit, other than allowing your app to compile.

But I agree that we should match the WinPhone7 API.
Comment 5 Jonathan Pryor 2011-08-08 08:54:21 UTC
Perusing https://github.com/mono/mono/tree/master/mcs/class/System/System.Text.RegularExpressions
it looks like adding the RegexOptions.Compiled value while ignoring it wouldn't be too difficult.

The question thus becomes, should we do this (add RegexOptions.Compiled but ignore it), and should we do the same to MonoTouch?
Comment 6 Miguel de Icaza [MSFT] 2011-08-08 10:33:35 UTC
We should just support the public API (with no aborts), but on MonoTouch this should just be ignored, since we can not JIT.
Comment 7 Jonathan Pryor 2011-08-09 21:35:08 UTC
Fixed.

Committed to mono/master: 298a6c4ef99dea45508aebf177244eadbdc3c4ea
Committed to mono/mono-2-10: a95adaf53dec56a7e0ea63506fc948e7040f411b