[System] Bring .NET implementation of System.Text.RegularExpressions
authorMiguel de Icaza <miguel@gnome.org>
Mon, 24 Nov 2014 02:37:26 +0000 (21:37 -0500)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 24 Nov 2014 02:38:36 +0000 (21:38 -0500)
This patch brings .NET's implementation of the RegularExpressions
stack and brings some of the supporting infrastructure required to
build without resource files.

The build commands have been updated with two new defines to assist in
bringing .NET code: MONO (to indicate that the code is being compiled
as part of Mono) and a more granular DISABLE_CAS_USE that is used to
mark regions where Code Access Security is being used in the source
code, as Mono does not actually ship with a working CAS implementation.

18 files changed:
external/referencesource
mcs/build/common/SR.cs [new file with mode: 0644]
mcs/build/profiles/basic.make
mcs/build/profiles/build.make
mcs/build/profiles/mobile.make
mcs/build/profiles/mobile_static.make
mcs/build/profiles/monodroid.make
mcs/build/profiles/monotouch.make
mcs/build/profiles/monotouch_runtime.make
mcs/build/profiles/net_4_0.make
mcs/build/profiles/net_4_5.make
mcs/build/profiles/xammac.make
mcs/build/profiles/xbuild_12.make
mcs/build/profiles/xbuild_14.make
mcs/class/System/SR.cs [new file with mode: 0644]
mcs/class/System/System.dll.sources
mcs/class/System/Test/System.Text.RegularExpressions/RegexTest.cs
mcs/class/corlib/System.Threading/Timeout.cs

index 4e6dea7a9c7cbb4e6b000b05a099e7168d1b6960..d8ada9f754e9f2fd4ed8a4cd8450cf3aa80e2f31 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4e6dea7a9c7cbb4e6b000b05a099e7168d1b6960
+Subproject commit d8ada9f754e9f2fd4ed8a4cd8450cf3aa80e2f31
diff --git a/mcs/build/common/SR.cs b/mcs/build/common/SR.cs
new file mode 100644 (file)
index 0000000..15dbfe7
--- /dev/null
@@ -0,0 +1,38 @@
+using System.Globalization;
+
+internal sealed class AssemblyRef
+{
+       // FIXME
+       internal const string SystemConfiguration = "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, ProcessorArchitecture=MSIL";
+       internal const string System = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL";
+       internal const string SystemWeb = "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
+}
+
+internal sealed partial class SR
+{
+       internal static string GetString(string name, params object[] args)
+       {
+               return GetString (CultureInfo.InvariantCulture, name, args);
+       }
+
+       internal static string GetString(CultureInfo culture, string name, params object[] args)
+       {
+               return string.Format (name, args);
+       }
+
+       internal static string GetString(string name)
+       {
+               return name;
+       }
+
+       internal static string GetString(CultureInfo culture, string name)
+       {
+               return name;
+       }
+}
+
+namespace System.Runtime.CompilerServices
+{
+       class FriendAccessAllowed : Attribute
+       { }
+}
index 12f6c82cff2c8f05c225231d8d3769a19760335d..9fa24ccb47b6e4a74b0d0d1dc7d1f3e6d858adc4 100644 (file)
@@ -18,7 +18,7 @@ endif
 
 MCS = $(with_mono_path) $(INTERNAL_GMCS)
 
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:BOOTSTRAP_BASIC -nowarn:1699
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:BOOTSTRAP_BASIC -nowarn:1699 -d:MONO -d:DISABLE_CAS_USE
 NO_SIGN_ASSEMBLY = yes
 NO_TEST = yes
 NO_INSTALL = yes
index b09a441a03fffa49ed8548963e5e41500fbc6553..850d17e8a8fddedc816dedf4afe15c366c5528a9 100644 (file)
@@ -13,7 +13,7 @@ profile-check:
        @:
 
 DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
 
 NO_SIGN_ASSEMBLY = yes
 NO_TEST = yes
index 117ac6051512b75ac1cbf8b82af38c9185e86339..75611d8cda4d649e058bd4b1b7b45d0e42eb5931 100644 (file)
@@ -22,6 +22,8 @@ PROFILE_MCS_FLAGS = \
        -d:NET_3_5 \
        -d:NET_4_0 \
        -d:NET_4_5 \
+       -d:MONO \
+       -d:DISABLE_CAS_USE \
        -nowarn:1699 \
        -nostdlib \
        -lib:$(topdir)/class/lib/$(PROFILE) \
index b789823519463da50495b379d55a7837c5c7e188..2fef29aa96fa90d710635c67579bc0d2dff22e9d 100644 (file)
@@ -20,6 +20,8 @@ PROFILE_MCS_FLAGS = \
        -d:NET_3_5 \
        -d:NET_4_0 \
        -d:NET_4_5 \
+       -d:MONO \
+       -d:DISABLE_CAS_USE \
        -d:MOBILE \
        -d:FULL_AOT_RUNTIME \
        -d:DISABLE_REMOTING \
index c14f61c6087ffe40bcc4dc05ea6eec4846d16d99..28698ca63d60e12ef05cb049a0a42d237871acc1 100644 (file)
@@ -20,6 +20,8 @@ PROFILE_MCS_FLAGS = \
        -d:NET_3_5 \
        -d:NET_4_0 \
        -d:NET_4_5 \
+       -d:MONO \
+       -d:DISABLE_CAS_USE \
        -d:MOBILE \
        -d:MOBILE_DYNAMIC \
        -d:MONODROID \
index 706463d748cd4c1021e2dd5b4bca32c4c99f4ae3..c60d9398ffa190805439342211e43aae899fa056 100644 (file)
@@ -21,6 +21,8 @@ PROFILE_MCS_FLAGS = \
        -d:NET_4_0 \
        -d:NET_4_5 \
        -d:MOBILE \
+       -d:MONO \
+       -d:DISABLE_CAS_USE \
        -d:MONOTOUCH \
        -d:DISABLE_REMOTING \
        -d:DISABLE_COM \
index f438e805f0d054115e869b8e7042725b92c83b2b..59c7df4c31cd4366c9a4f6d65807c6056643938c 100644 (file)
@@ -14,7 +14,7 @@ profile-check:
        @:
 
 DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MOBILE -d:MONOTOUCH -D:DISABLE_REMOTING -d:DISABLE_COM -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MONO -d:DISABLE_CAS_USE  -d:MOBILE -d:MONOTOUCH -D:DISABLE_REMOTING -d:DISABLE_COM -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
 
 FRAMEWORK_VERSION = 2.1
 
index 99782bd526a783bd31c1e88598150f2fcc09a979..7081318194a3524ade3503704768016c3c2dae7d 100644 (file)
@@ -11,7 +11,7 @@ profile-check:
        @:
 
 DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -d:MONO -d:DISABLE_CAS_USE  -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES)
 
 FRAMEWORK_VERSION = 4.0
 XBUILD_VERSION = 4.0
index ad921e705ea23954807e40962b2e6cef80d3875b..7c37b2c89d644fb8b025c8db6b6a4d8ed47d03a7 100644 (file)
@@ -11,7 +11,7 @@ profile-check:
        @:
 
 DEFAULT_REFERENCES = -r:mscorlib.dll
-PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_3_0 -d:NET_3_5 -d:NET_4_0 -d:NET_4_5 -d:MONO -d:DISABLE_CAS_USE  -nowarn:1699 -nostdlib -lib:$(topdir)/class/lib/$(PROFILE) $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS)
 
 FRAMEWORK_VERSION = 4.5
 XBUILD_VERSION = 4.0
index d463a0fe943f580ecb05e81aaaf4d91ec6768853..3a91b7620e2960a986b6fd3eb54cf34335945190 100644 (file)
@@ -18,6 +18,8 @@ PROFILE_MCS_FLAGS = \
        -d:NET_3_5 \
        -d:NET_4_0 \
        -d:NET_4_5 \
+       -d:MONO \
+       -d:DISABLE_CAS_USE  \
        -d:MOBILE \
        -d:MOBILE_DYNAMIC \
        -d:XAMMAC \
index d3aff7e92e6645311ea9ba4b7d4b27ee8a8d98f0..4e0f9940dfeb23af2f1e773605a5e5abe7f804a7 100644 (file)
@@ -2,6 +2,6 @@
 
 include $(topdir)/build/profiles/net_4_5.make
 
-PROFILE_MCS_FLAGS := $(PROFILE_MCS_FLAGS) -d:XBUILD_12 -lib:$(topdir)/class/lib/net_4_5
+PROFILE_MCS_FLAGS := $(PROFILE_MCS_FLAGS) -d:XBUILD_12 -d:MONO -d:DISABLE_CAS_USE  -lib:$(topdir)/class/lib/net_4_5
 
 XBUILD_VERSION = 12.0
index cc55a1ded3b5907186e002bd6bc9bea9c132d1ff..eeff40826788f5c4bfac80a996cb07f5cb655e29 100644 (file)
@@ -2,6 +2,6 @@
 
 include $(topdir)/build/profiles/net_4_5.make
 
-PROFILE_MCS_FLAGS := $(PROFILE_MCS_FLAGS) -d:XBUILD_12 -d:XBUILD_14 -lib:$(topdir)/class/lib/net_4_5
+PROFILE_MCS_FLAGS := $(PROFILE_MCS_FLAGS) -d:XBUILD_12 -d:XBUILD_14 -d:MONO -d:DISABLE_CAS_USE  -lib:$(topdir)/class/lib/net_4_5
 
 XBUILD_VERSION = 14.0
diff --git a/mcs/class/System/SR.cs b/mcs/class/System/SR.cs
new file mode 100644 (file)
index 0000000..d910f5d
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Resource strings referenced by the code.
+//
+// Copyright 2014 Xamarin Inc
+//
+partial class SR
+{
+       public const string UnexpectedOpcode = "UnexpectedOpcode";
+       public const string BeginIndexNotNegative = "BeginIndexNotNegative";
+       public const string CountTooSmall = "CountTooSmall";
+       public const string ReplacementError = "ReplacementError";
+       public const string BadClassInCharRange = "BadClassInCharRange";
+       public const string TooManyAlternates = "TooManyAlternates";
+       public const string MakeException = "MakeException";
+       public const string IncompleteSlashP = "IncompleteSlashP";
+       public const string MalformedSlashP = "MalformedSlashP";
+       public const string CaptureGroupOutOfRange = "CaptureGroupOutOfRange";
+       public const string InvalidGroupName = "InvalidGroupName";
+       public const string UndefinedBackref = "UndefinedBackref";
+       public const string UndefinedNameref = "UndefinedNameref";
+       public const string UnrecognizedControl = "UnrecognizedControl";
+       
+       public const string AlternationCantCapture = "AlternationCantCapture";
+       public const string AlternationCantHaveComment = "AlternationCantHaveComment";
+       public const string Arg_InvalidArrayType = "Arg_InvalidArrayType";
+       public const string Arg_RankMultiDimNotSupported = "Arg_RankMultiDimNotSupported";
+       public const string ArgumentNull_ArrayWithNullElements = "ArgumentNull_ArrayWithNullElements";
+       public const string CapnumNotZero = "CapnumNotZero";
+       public const string EnumNotStarted = "EnumNotStarted";
+       public const string IllegalCondition = "IllegalCondition";
+       public const string IllegalDefaultRegexMatchTimeoutInAppDomain = "IllegalDefaultRegexMatchTimeoutInAppDomain";
+       public const string IllegalEndEscape = "IllegalEndEscape";
+       public const string IllegalRange = "IllegalRange";
+       public const string InvalidNullEmptyArgument = "Invalid empty argument {0}";
+       public const string InternalError = "InternalError";
+       public const string LengthNotNegative = "LengthNotNegative";
+       public const string MalformedNameRef = "MalformedNameRef";
+       public const string MalformedReference = "MalformedReference";
+       public const string MissingControl = "MissingControl";
+       public const string NestedQuantify = "NestedQuantify";
+       public const string NoResultOnFailed = "NoResultOnFailed";
+       public const string NotEnoughParens = "NotEnoughParens";
+       public const string OnlyAllowedOnce = "OnlyAllowedOnce";
+       public const string QuantifyAfterNothing = "QuantifyAfterNothing";
+       public const string RegexMatchTimeoutException_Occurred = "RegexMatchTimeoutException_Occurred";
+       public const string ReversedCharRange = "ReversedCharRange";
+       public const string SubtractionMustBeLast = "SubtractionMustBeLast";
+       public const string TooFewHex = "TooFewHex";
+       public const string TooManyParens = "TooManyParens";
+       public const string UndefinedNameRef = "UndefinedNameRef";
+       public const string UndefinedReference = "UndefinedReference";
+       public const string UnimplementedState = "UnimplementedState";
+       public const string UnknownProperty = "UnknownProperty";
+       public const string UnrecognizedEscape = "UnrecognizedEscape";
+       public const string UnrecognizedGrouping = "UnrecognizedGrouping";
+       public const string UnterminatedBracket = "UnterminatedBracket";
+       public const string UnterminatedComment = "UnterminatedComment";
+       
+}
index dffa27ef69059d084aebd7e76dc9359766bf1f26..286f991e5921de2ff6e455a92fb448ab3936d037 100644 (file)
@@ -1,3 +1,5 @@
+SR.cs
+../../build/common/SR.cs
 Assembly/AssemblyInfo.cs
 Microsoft.CSharp/CSharpCodeCompiler.cs
 Microsoft.CSharp/CSharpCodeGenerator.cs
@@ -967,35 +969,6 @@ System.Security.Permissions/StorePermissionAttribute.cs
 System.Security.Permissions/StorePermission.cs
 System.Security.Permissions/StorePermissionFlags.cs
 System/SRDescriptionAttribute.cs
-System.Text.RegularExpressions/arch.cs
-System.Text.RegularExpressions/BaseMachine.cs
-System.Text.RegularExpressions/cache.cs
-System.Text.RegularExpressions/CaptureCollection.cs
-System.Text.RegularExpressions/Capture.cs
-System.Text.RegularExpressions/CILCompiler.cs
-System.Text.RegularExpressions/category.cs
-System.Text.RegularExpressions/compiler.cs
-System.Text.RegularExpressions/debug.cs
-System.Text.RegularExpressions/GroupCollection.cs
-System.Text.RegularExpressions/Group.cs
-System.Text.RegularExpressions/interpreter.cs
-System.Text.RegularExpressions/interval.cs
-System.Text.RegularExpressions/MatchCollection.cs
-System.Text.RegularExpressions/Match.cs
-System.Text.RegularExpressions/MatchEvaluator.cs
-System.Text.RegularExpressions/parser.cs
-System.Text.RegularExpressions/quicksearch.cs
-System.Text.RegularExpressions/RegexCompilationInfo.cs
-System.Text.RegularExpressions/Regex.cs
-System.Text.RegularExpressions/RegexMatchTimeoutException.cs
-System.Text.RegularExpressions/RegexOptions.cs
-System.Text.RegularExpressions/RegexRunner.cs
-System.Text.RegularExpressions/RegexRunnerFactory.cs
-System.Text.RegularExpressions/RxInterpreter.cs
-System.Text.RegularExpressions/RxCompiler.cs
-System.Text.RegularExpressions/RxOp.cs
-System.Text.RegularExpressions/replace.cs
-System.Text.RegularExpressions/syntax.cs
 System.Threading/Semaphore.cs
 System.Threading/SemaphoreFullException.cs
 System.Threading/ThreadExceptionEventArgs.cs
@@ -1085,3 +1058,28 @@ Mono.Net.Dns/ResolverError.cs
 Mono.Net.Dns/SimpleResolverEventArgs.cs
 System.Net/DnsAsyncResult.cs
 System.Windows.Input/ICommand.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/Regex.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexBoyerMoore.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexCapture.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexCaptureCollection.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexCharClass.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexCode.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexCompilationInfo.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexCompiler.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexFCD.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexGroup.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexGroupCollection.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexInterpreter.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexMatch.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexMatchCollection.cs
+../../../external/referencesource/System/regex/System/Text/RegularExpressions/RegexMatchTimeoutException.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexNode.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexOptions.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexParser.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexReplacement.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexRunner.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexRunnerFactory.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexTree.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/RegexWriter.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/compiledregexrunner.cs
+../../../external/referencesource/System/regex/system/text/regularexpressions/compiledregexrunnerfactory.cs
\ No newline at end of file
index f5208ce99de0e39dfdea201a5222d945b471e435..5978a5d095f072b26dca560f5f4d305d4731f3c2 100644 (file)
@@ -189,7 +189,7 @@ namespace MonoTests.System.Text.RegularExpressions
                                   AddOptions( RegexOptions.None )).Match ("foobar", 5, -1);
                }
 
-               [Test, ExpectedException (typeof (ArgumentOutOfRangeException))]
+               [Test, ExpectedException (typeof (IndexOutOfRangeException))]
                public void Match_BadLength2 ()
                {
                        new Regex (@"foo",
index 66f661b2ee3752c2422358d26fe15fa697558ff9..8cca9840e5380b0bdc0a6ff599f54550039f1124 100644 (file)
@@ -38,8 +38,6 @@ namespace System.Threading {
        {
                public const int Infinite = -1;
 
-#if NET_4_5
                public static readonly TimeSpan InfiniteTimeSpan = new TimeSpan (0, 0, 0, 0, -1);
-#endif
        }
 }