Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@@ -6,6 +6,8 @@
// ------------------------------------------------------------------------------
using System.Reflection;
namespace System.Text.RegularExpressions
{
public partial class Capture
@@ -16,7 +18,7 @@ namespace System.Text.RegularExpressions
public string Value { get { throw null; } }
public override string ToString() { throw null; }
}
public partial class CaptureCollection : System.Collections.ICollection, System.Collections.IEnumerable
public partial class CaptureCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Capture>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
internal CaptureCollection() { }
public int Count { get { throw null; } }
@@ -25,16 +27,36 @@ namespace System.Text.RegularExpressions
public System.Text.RegularExpressions.Capture this[int i] { get { throw null; } }
public object SyncRoot { get { throw null; } }
public void CopyTo(System.Array array, int arrayIndex) { }
public void CopyTo(System.Text.RegularExpressions.Capture[] array, int arrayIndex) { }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Capture> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Capture>.GetEnumerator() { throw null; }
int System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.IndexOf(System.Text.RegularExpressions.Capture item) { throw null; }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.Insert(int index, System.Text.RegularExpressions.Capture item) { }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.RemoveAt(int index) { }
System.Text.RegularExpressions.Capture System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.this[int index] { get { throw null; } set { } }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Add(System.Text.RegularExpressions.Capture item) { }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Clear() { }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Contains(System.Text.RegularExpressions.Capture item) { throw null; }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Remove(System.Text.RegularExpressions.Capture item) { throw null; }
int System.Collections.IList.Add(object value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object value) { throw null; }
int System.Collections.IList.IndexOf(object value) { throw null; }
void System.Collections.IList.Insert(int index, object value) { }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
void System.Collections.IList.Remove(object value) { }
void System.Collections.IList.RemoveAt(int index) { }
object System.Collections.IList.this[int index] { get { throw null; } set { } }
}
public partial class Group : System.Text.RegularExpressions.Capture
{
internal Group() { }
public System.Text.RegularExpressions.CaptureCollection Captures { get { throw null; } }
public string Name { get { throw null; } }
public bool Success { get { throw null; } }
public static System.Text.RegularExpressions.Group Synchronized(System.Text.RegularExpressions.Group inner) { throw null; }
}
public partial class GroupCollection : System.Collections.ICollection, System.Collections.IEnumerable
public partial class GroupCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group>, System.Collections.Generic.IList<System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Group>, System.Collections.IList
{
internal GroupCollection() { }
public int Count { get { throw null; } }
@@ -44,7 +66,26 @@ namespace System.Text.RegularExpressions
public System.Text.RegularExpressions.Group this[string groupname] { get { throw null; } }
public object SyncRoot { get { throw null; } }
public void CopyTo(System.Array array, int arrayIndex) { }
public void CopyTo(System.Text.RegularExpressions.Group[] array, int arrayIndex) { }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Group> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group>.GetEnumerator() { throw null; }
int System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.IndexOf(System.Text.RegularExpressions.Group item) { throw null; }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.Insert(int index, System.Text.RegularExpressions.Group item) { }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.RemoveAt(int index) { }
System.Text.RegularExpressions.Group System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.this[int index] { get { throw null; } set { } }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Add(System.Text.RegularExpressions.Group item) { }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Clear() { }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Contains(System.Text.RegularExpressions.Group item) { throw null; }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Remove(System.Text.RegularExpressions.Group item) { throw null; }
int System.Collections.IList.Add(object value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object value) { throw null; }
int System.Collections.IList.IndexOf(object value) { throw null; }
void System.Collections.IList.Insert(int index, object value) { }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
void System.Collections.IList.Remove(object value) { }
void System.Collections.IList.RemoveAt(int index) { }
object System.Collections.IList.this[int index] { get { throw null; } set { } }
}
public partial class Match : System.Text.RegularExpressions.Group
{
@@ -55,7 +96,7 @@ namespace System.Text.RegularExpressions
public virtual string Result(string replacement) { throw null; }
public static System.Text.RegularExpressions.Match Synchronized(System.Text.RegularExpressions.Match inner) { throw null; }
}
public partial class MatchCollection : System.Collections.ICollection, System.Collections.IEnumerable
public partial class MatchCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>, System.Collections.Generic.IList<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Match>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
internal MatchCollection() { }
public int Count { get { throw null; } }
@@ -64,7 +105,26 @@ namespace System.Text.RegularExpressions
public virtual System.Text.RegularExpressions.Match this[int i] { get { throw null; } }
public object SyncRoot { get { throw null; } }
public void CopyTo(System.Array array, int arrayIndex) { }
public void CopyTo(System.Text.RegularExpressions.Match[] array, int arrayIndex) { }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Match> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>.GetEnumerator() { throw null; }
int System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.IndexOf(System.Text.RegularExpressions.Match item) { throw null; }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.Insert(int index, System.Text.RegularExpressions.Match item) { }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.RemoveAt(int index) { }
System.Text.RegularExpressions.Match System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.this[int index] { get { throw null; } set { } }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Add(System.Text.RegularExpressions.Match item) { }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Clear() { }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Contains(System.Text.RegularExpressions.Match item) { throw null; }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Remove(System.Text.RegularExpressions.Match item) { throw null; }
int System.Collections.IList.Add(object value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object value) { throw null; }
int System.Collections.IList.IndexOf(object value) { throw null; }
void System.Collections.IList.Insert(int index, object value) { }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
void System.Collections.IList.Remove(object value) { }
void System.Collections.IList.RemoveAt(int index) { }
object System.Collections.IList.this[int index] { get { throw null; } set { } }
}
public delegate string MatchEvaluator(System.Text.RegularExpressions.Match match);
public partial class Regex : System.Runtime.Serialization.ISerializable
@@ -84,6 +144,10 @@ namespace System.Text.RegularExpressions
public Regex(string pattern, System.Text.RegularExpressions.RegexOptions options) { }
public Regex(string pattern, System.Text.RegularExpressions.RegexOptions options, System.TimeSpan matchTimeout) { }
public static int CacheSize { get { throw null; } set { } }
[System.CLSCompliant(false)]
protected System.Collections.IDictionary Caps { get { throw null; } set { } }
[System.CLSCompliant(false)]
protected System.Collections.IDictionary CapNames { get { throw null; } set { } }
public System.TimeSpan MatchTimeout { get { throw null; } }
public System.Text.RegularExpressions.RegexOptions Options { get { throw null; } }
public bool RightToLeft { get { throw null; } }
@@ -134,6 +198,17 @@ namespace System.Text.RegularExpressions
protected bool UseOptionR() { throw null; }
protected internal static void ValidateMatchTimeout(System.TimeSpan matchTimeout) { }
}
public partial class RegexCompilationInfo
{
public RegexCompilationInfo(string pattern, RegexOptions options, string name, string fullnamespace, bool ispublic) { }
public RegexCompilationInfo(string pattern, RegexOptions options, string name, string fullnamespace, bool ispublic, TimeSpan matchTimeout) { }
public bool IsPublic { get; set; }
public TimeSpan MatchTimeout { get; set; }
public string Name { get; set; }
public string Namespace { get; set; }
public RegexOptions Options { get; set; }
public string Pattern { get; set; }
}
public partial class RegexMatchTimeoutException : System.TimeoutException, System.Runtime.Serialization.ISerializable
{
public RegexMatchTimeoutException() { }

View File

@@ -10,6 +10,9 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'uap-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.Text.RegularExpressions.cs" />
</ItemGroup>
<!-- Files required to enable compiled feature -->
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Compile Include="System.Text.RegularExpressions.netcoreapp.cs" />
</ItemGroup>
<ItemGroup>
@@ -17,5 +20,9 @@
<ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" />
<ProjectReference Include="..\..\System.Collections.NonGeneric\ref\System.Collections.NonGeneric.csproj" />
</ItemGroup>
<!-- Required for CompileToAssembly API -->
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<ProjectReference Include="..\..\System.Reflection.Emit.ILGeneration\ref\System.Reflection.Emit.ILGeneration.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>

View File

@@ -8,81 +8,10 @@
namespace System.Text.RegularExpressions
{
public partial class Group
{
public string Name { get { throw null; } }
}
public partial class Regex
{
[System.CLSCompliant(false)]
protected System.Collections.IDictionary Caps { get { throw null; } set { } }
[System.CLSCompliant(false)]
protected System.Collections.IDictionary CapNames { get { throw null; } set { } }
}
public partial class CaptureCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Capture>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Capture>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
public void CopyTo(System.Text.RegularExpressions.Capture[] array, int arrayIndex) { }
System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Capture> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Capture>.GetEnumerator() { throw null; }
int System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.IndexOf(System.Text.RegularExpressions.Capture item) { throw null; }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.Insert(int index, System.Text.RegularExpressions.Capture item) { }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.RemoveAt(int index) { }
System.Text.RegularExpressions.Capture System.Collections.Generic.IList<System.Text.RegularExpressions.Capture>.this[int index] { get { throw null; } set { } }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Add(System.Text.RegularExpressions.Capture item) { }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Clear() { }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Contains(System.Text.RegularExpressions.Capture item) { throw null; }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Capture>.Remove(System.Text.RegularExpressions.Capture item) { throw null; }
int System.Collections.IList.Add(object value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object value) { throw null; }
int System.Collections.IList.IndexOf(object value) { throw null; }
void System.Collections.IList.Insert(int index, object value) { }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
void System.Collections.IList.Remove(object value) { }
void System.Collections.IList.RemoveAt(int index) { }
object System.Collections.IList.this[int index] { get { throw null; } set { } }
}
public partial class GroupCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group>, System.Collections.Generic.IList<System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Group>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Group>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
public void CopyTo(System.Text.RegularExpressions.Group[] array, int arrayIndex) { }
System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Group> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Group>.GetEnumerator() { throw null; }
int System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.IndexOf(System.Text.RegularExpressions.Group item) { throw null; }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.Insert(int index, System.Text.RegularExpressions.Group item) { }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.RemoveAt(int index) { }
System.Text.RegularExpressions.Group System.Collections.Generic.IList<System.Text.RegularExpressions.Group>.this[int index] { get { throw null; } set { } }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Add(System.Text.RegularExpressions.Group item) { }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Clear() { }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Contains(System.Text.RegularExpressions.Group item) { throw null; }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Group>.Remove(System.Text.RegularExpressions.Group item) { throw null; }
int System.Collections.IList.Add(object value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object value) { throw null; }
int System.Collections.IList.IndexOf(object value) { throw null; }
void System.Collections.IList.Insert(int index, object value) { }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
void System.Collections.IList.Remove(object value) { }
void System.Collections.IList.RemoveAt(int index) { }
object System.Collections.IList.this[int index] { get { throw null; } set { } }
}
public partial class MatchCollection : System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>, System.Collections.Generic.IList<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyCollection<System.Text.RegularExpressions.Match>, System.Collections.Generic.IReadOnlyList<System.Text.RegularExpressions.Match>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
public void CopyTo(System.Text.RegularExpressions.Match[] array, int arrayIndex) { }
System.Collections.Generic.IEnumerator<System.Text.RegularExpressions.Match> System.Collections.Generic.IEnumerable<System.Text.RegularExpressions.Match>.GetEnumerator() { throw null; }
int System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.IndexOf(System.Text.RegularExpressions.Match item) { throw null; }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.Insert(int index, System.Text.RegularExpressions.Match item) { }
void System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.RemoveAt(int index) { }
System.Text.RegularExpressions.Match System.Collections.Generic.IList<System.Text.RegularExpressions.Match>.this[int index] { get { throw null; } set { } }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Add(System.Text.RegularExpressions.Match item) { }
void System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Clear() { }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Contains(System.Text.RegularExpressions.Match item) { throw null; }
bool System.Collections.Generic.ICollection<System.Text.RegularExpressions.Match>.Remove(System.Text.RegularExpressions.Match item) { throw null; }
int System.Collections.IList.Add(object value) { throw null; }
void System.Collections.IList.Clear() { }
bool System.Collections.IList.Contains(object value) { throw null; }
int System.Collections.IList.IndexOf(object value) { throw null; }
void System.Collections.IList.Insert(int index, object value) { }
bool System.Collections.IList.IsFixedSize { get { throw null; } }
void System.Collections.IList.Remove(object value) { }
void System.Collections.IList.RemoveAt(int index) { }
object System.Collections.IList.this[int index] { get { throw null; } set { } }
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname) { }
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname, System.Reflection.Emit.CustomAttributeBuilder[] attributes) { }
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname, System.Reflection.Emit.CustomAttributeBuilder[] attributes, string resourceFile) { }
}
}

View File

@@ -67,6 +67,9 @@
<data name="Arg_ArrayPlusOffTooSmall" xml:space="preserve">
<value>Destination array is not long enough to copy all the items in the collection. Check array index and length.</value>
</data>
<data name="ArgumentNull_ArrayWithNullElements" xml:space="preserve">
<value>The array cannot contain null elements.</value>
</data>
<data name="BadClassInCharRange" xml:space="preserve">
<value>Cannot include class \\{0} in character range.</value>
</data>
@@ -88,6 +91,9 @@
<data name="IllegalCondition" xml:space="preserve">
<value>Illegal conditional (?(...)) expression.</value>
</data>
<data name="IllegalDefaultRegexMatchTimeoutInAppDomain" xml:space="preserve">
<value>AppDomain data '{0}' contains the invalid value or object '{1}' for specifying a default matching timeout for System.Text.RegularExpressions.Regex.</value>
</data>
<data name="IllegalEndEscape" xml:space="preserve">
<value>Illegal \\ at end of pattern.</value>
</data>
@@ -103,6 +109,9 @@
<data name="InvalidGroupName" xml:space="preserve">
<value>Invalid group name: Group names must begin with a word character.</value>
</data>
<data name="InvalidEmptyArgument" xml:space="preserve">
<value>Argument {0} cannot be zero-length.</value>
</data>
<data name="LengthNotNegative" xml:space="preserve">
<value>Length cannot be less than 0 or exceed input length.</value>
</data>
@@ -136,6 +145,9 @@
<data name="OnlyAllowedOnce" xml:space="preserve">
<value>This operation is only allowed once per object.</value>
</data>
<data name="PlatformNotSupported_CompileToAssembly" xml:space="preserve">
<value>This platform does not support writing compiled regular expressions to an assembly.</value>
</data>
<data name="QuantifyAfterNothing" xml:space="preserve">
<value>Quantifier {x,y} following nothing.</value>
</data>
@@ -193,4 +205,4 @@
<data name="UnterminatedComment" xml:space="preserve">
<value>Unterminated (?#...) comment.</value>
</data>
</root>
</root>

View File

@@ -4,6 +4,7 @@
<PropertyGroup>
<ProjectGuid>{2C58640B-5BED-4E83-9554-CD2B9762643F}</ProjectGuid>
<AssemblyName>System.Text.RegularExpressions</AssemblyName>
<DefineConstants Condition="'$(TargetGroup)' == 'netcoreapp'">$(DefineConstants);FEATURE_COMPILED</DefineConstants>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netcoreapp-Debug|AnyCPU'" />
@@ -19,6 +20,7 @@
<Compile Include="System\Text\RegularExpressions\RegexCharClass.cs" />
<Compile Include="System\Text\RegularExpressions\RegexCode.cs" />
<Compile Include="System\Text\RegularExpressions\RegexCollectionDebuggerProxy.cs" />
<Compile Include="System\Text\RegularExpressions\RegexCompilationInfo.cs" />
<Compile Include="System\Text\RegularExpressions\RegexFCD.cs" />
<Compile Include="System\Text\RegularExpressions\RegexGroup.cs" />
<Compile Include="System\Text\RegularExpressions\RegexGroupCollection.cs" />
@@ -42,6 +44,13 @@
<Link>Common\System\IO\StringBuilderCache.cs</Link>
</Compile>
</ItemGroup>
<!-- Files that enable compiled feature -->
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Compile Include="System\Text\RegularExpressions\CompiledRegexRunnerFactory.cs" />
<Compile Include="System\Text\RegularExpressions\CompiledRegexRunner.cs" />
<Compile Include="System\Text\RegularExpressions\RegexCompiler.cs" />
<Compile Include="System\Text\RegularExpressions\RegexLWCGCompiler.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Debug" />
@@ -51,5 +60,11 @@
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Threading" />
</ItemGroup>
<!-- References required for compiled feature -->
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Reference Include="System.Reflection.Emit.ILGeneration" />
<Reference Include="System.Reflection.Emit.Lightweight" />
<Reference Include="System.Reflection.Primitives" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project>

View File

@@ -0,0 +1,37 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Text.RegularExpressions
{
internal sealed class CompiledRegexRunner : RegexRunner
{
private Action<RegexRunner> _goMethod;
private Func<RegexRunner, bool> _findFirstCharMethod;
private Action<RegexRunner> _initTrackCountMethod;
internal CompiledRegexRunner() { }
internal void SetDelegates(Action<RegexRunner> go, Func<RegexRunner,bool> firstChar, Action<RegexRunner> trackCount)
{
_goMethod = go;
_findFirstCharMethod = firstChar;
_initTrackCountMethod = trackCount;
}
protected override void Go()
{
_goMethod(this);
}
protected override bool FindFirstChar()
{
return _findFirstCharMethod(this);
}
protected override void InitTrackCount()
{
_initTrackCountMethod(this);
}
}
}

View File

@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Reflection.Emit;
namespace System.Text.RegularExpressions
{
internal sealed class CompiledRegexRunnerFactory : RegexRunnerFactory
{
private readonly DynamicMethod _goMethod;
private readonly DynamicMethod _findFirstCharMethod;
private readonly DynamicMethod _initTrackCountMethod;
internal CompiledRegexRunnerFactory(DynamicMethod go, DynamicMethod firstChar, DynamicMethod trackCount)
{
_goMethod = go;
_findFirstCharMethod = firstChar;
_initTrackCountMethod = trackCount;
}
protected internal override RegexRunner CreateInstance()
{
CompiledRegexRunner runner = new CompiledRegexRunner();
runner.SetDelegates((Action<RegexRunner>)_goMethod.CreateDelegate(typeof(Action<RegexRunner>)),
(Func<RegexRunner, bool>)_findFirstCharMethod.CreateDelegate(typeof(Func<RegexRunner, bool>)),
(Action<RegexRunner>)_initTrackCountMethod.CreateDelegate(typeof(Action<RegexRunner>)));
return runner;
}
}
}

View File

@@ -9,6 +9,11 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
#if FEATURE_COMPILED
using System.Runtime.CompilerServices;
#endif
using System.Runtime.Serialization;
using System.Threading;
@@ -43,9 +48,12 @@ namespace System.Text.RegularExpressions
protected internal TimeSpan internalMatchTimeout; // timeout for the execution of this regex
// During static initialisation of Regex we check
private const string DefaultMatchTimeout_ConfigKeyName = "REGEX_DEFAULT_MATCH_TIMEOUT";
// DefaultMatchTimeout specifies the match timeout to use if no other timeout was specified
// by one means or another. Typically, it is set to InfiniteMatchTimeout.
internal static readonly TimeSpan DefaultMatchTimeout = InfiniteMatchTimeout;
internal static readonly TimeSpan DefaultMatchTimeout = InitDefaultMatchTimeout();
// *********** } match timeout fields ***********
@@ -147,16 +155,18 @@ namespace System.Text.RegularExpressions
throw new PlatformNotSupportedException();
}
private Regex(string pattern, RegexOptions options, TimeSpan matchTimeout, bool useCache)
private Regex(string pattern, RegexOptions options, TimeSpan matchTimeout, bool addToCache)
{
RegexTree tree;
CachedCodeEntry cached = null;
string cultureKey = null;
if (pattern == null)
{
throw new ArgumentNullException(nameof(pattern));
}
if (options < RegexOptions.None || (((int)options) >> MaxOptionShift) != 0)
{
throw new ArgumentOutOfRangeException(nameof(options));
}
if ((options & RegexOptions.ECMAScript) != 0
&& (options & ~(RegexOptions.ECMAScript |
RegexOptions.IgnoreCase |
@@ -167,29 +177,30 @@ namespace System.Text.RegularExpressions
| RegexOptions.Debug
#endif
)) != 0)
{
throw new ArgumentOutOfRangeException(nameof(options));
}
ValidateMatchTimeout(matchTimeout);
// Try to look up this regex in the cache. We do this regardless of whether useCache is true since there's
// really no reason not to.
string cultureKey;
if ((options & RegexOptions.CultureInvariant) != 0)
cultureKey = CultureInfo.InvariantCulture.ToString(); // "English (United States)"
cultureKey = CultureInfo.InvariantCulture.ToString();
else
cultureKey = CultureInfo.CurrentCulture.ToString();
// Try to look up this regex in the cache.
var key = new CachedCodeEntryKey(options, cultureKey, pattern);
cached = LookupCachedAndUpdate(key);
CachedCodeEntry cached = LookupCachedAndUpdate(key);
this.pattern = pattern;
roptions = options;
internalMatchTimeout = matchTimeout;
if (cached == null)
{
// Parse the input
tree = RegexParser.Parse(pattern, roptions);
RegexTree tree = RegexParser.Parse(pattern, roptions);
// Extract the relevant information
capnames = tree._capnames;
@@ -201,7 +212,7 @@ namespace System.Text.RegularExpressions
InitializeReferences();
tree = null;
if (useCache)
if (addToCache)
cached = CacheCode(key);
}
else
@@ -211,10 +222,28 @@ namespace System.Text.RegularExpressions
capslist = cached._capslist;
capsize = cached._capsize;
_code = cached._code;
#if FEATURE_COMPILED
factory = cached._factory;
#endif
_runnerref = cached._runnerref;
_replref = cached._replref;
_refsInitialized = true;
}
#if FEATURE_COMPILED
// if the compile option is set, then compile the code if it's not already
if (UseOptionC() && factory == null)
{
factory = Compile(_code, roptions);
if (addToCache && cached != null)
{
cached.AddCompiled(factory);
}
_code = null;
}
#endif
}
// Note: "&lt;" is the XML entity for smaller ("<").
@@ -237,6 +266,58 @@ namespace System.Text.RegularExpressions
throw new ArgumentOutOfRangeException(nameof(matchTimeout));
}
/// <summary>
/// Specifies the default RegEx matching timeout value (i.e. the timeout that will be used if no
/// explicit timeout is specified).
/// The default is queried from the current <code>AppDomain</code>.
/// If the AddDomain's data value for that key is not a <code>TimeSpan</code> value or if it is outside the
/// valid range, an exception is thrown.
/// If the AddDomain's data value for that key is <code>null</code>, a fallback value is returned.
/// </summary>
/// <returns>The default RegEx matching timeout for this AppDomain</returns>
private static TimeSpan InitDefaultMatchTimeout()
{
// Query AppDomain
AppDomain ad = AppDomain.CurrentDomain;
object defaultMatchTimeoutObj = ad.GetData(DefaultMatchTimeout_ConfigKeyName);
// If no default is specified, use fallback
if (defaultMatchTimeoutObj == null)
{
return InfiniteMatchTimeout;
}
if (defaultMatchTimeoutObj is TimeSpan defaultMatchTimeOut)
{
// If default timeout is outside the valid range, throw. It will result in a TypeInitializationException:
try
{
ValidateMatchTimeout(defaultMatchTimeOut);
}
catch (ArgumentOutOfRangeException)
{
throw new ArgumentOutOfRangeException(SR.Format(SR.IllegalDefaultRegexMatchTimeoutInAppDomain, DefaultMatchTimeout_ConfigKeyName, defaultMatchTimeOut));
}
return defaultMatchTimeOut;
}
throw new InvalidCastException(SR.Format(SR.IllegalDefaultRegexMatchTimeoutInAppDomain, DefaultMatchTimeout_ConfigKeyName, defaultMatchTimeoutObj));
}
#if FEATURE_COMPILED
/// <summary>
/// This method is here for perf reasons: if the call to RegexCompiler is NOT in the
/// Regex constructor, we don't load RegexCompiler and its reflection classes when
/// instantiating a non-compiled regex.
/// </summary>
[MethodImplAttribute(MethodImplOptions.NoInlining)]
private RegexRunnerFactory Compile(RegexCode code, RegexOptions roptions)
{
return RegexCompiler.Compile(code, roptions);
}
#endif
/// <summary>
/// Escapes a minimal set of metacharacters (\, *, +, ?, |, {, [, (, ), ^, $, ., #, and
/// whitespace) by replacing them with their \ codes. This converts a string so that
@@ -854,8 +935,7 @@ namespace System.Text.RegularExpressions
}
/// <summary>
/// Splits the <paramref name="input"/> string at the position defined by a
/// previous pattern.
/// Splits the <paramref name="input"/> string at the position defined by a previous pattern.
/// </summary>
public string[] Split(string input, int count, int startat)
{
@@ -865,6 +945,26 @@ namespace System.Text.RegularExpressions
return RegexReplacement.Split(this, input, count, startat);
}
#if FEATURE_COMPILED
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "assemblyname", Justification = "Microsoft: already shipped since v1 - can't fix without causing a breaking change")]
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_CompileToAssembly);
}
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "assemblyname", Justification = "Microsoft: already shipped since v1 - can't fix without causing a breaking change")]
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[] attributes)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_CompileToAssembly);
}
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "assemblyname", Justification = "Microsoft: already shipped since v1 - can't fix without causing a breaking change")]
public static void CompileToAssembly(RegexCompilationInfo[] regexinfos, AssemblyName assemblyname, CustomAttributeBuilder[] attributes, string resourceFile)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_CompileToAssembly);
}
#endif
protected void InitializeReferences()
{
if (_refsInitialized)
@@ -898,6 +998,8 @@ namespace System.Text.RegularExpressions
if (runner == null)
{
// Use the compiled RegexRunner factory if the code was compiled to MSIL
if (factory != null)
runner = factory.CreateInstance();
else
@@ -1067,6 +1169,9 @@ namespace System.Text.RegularExpressions
internal Hashtable _caps;
internal Hashtable _capnames;
internal string[] _capslist;
#if FEATURE_COMPILED
internal RegexRunnerFactory _factory;
#endif
internal int _capsize;
internal ExclusiveReference _runnerref;
internal SharedReference _replref;
@@ -1084,6 +1189,14 @@ namespace System.Text.RegularExpressions
_runnerref = runner;
_replref = repl;
}
#if FEATURE_COMPILED
internal void AddCompiled(RegexRunnerFactory factory)
{
_factory = factory;
_code = null;
}
#endif
}
/*

View File

@@ -19,14 +19,14 @@ namespace System.Text.RegularExpressions
{
internal sealed class RegexBoyerMoore
{
private readonly int[] _positive;
private readonly int[] _negativeASCII;
private readonly int[][] _negativeUnicode;
private readonly string _pattern;
private readonly int _lowASCII;
private readonly int _highASCII;
internal readonly int[] _positive;
internal readonly int[] _negativeASCII;
internal readonly int[][] _negativeUnicode;
internal readonly string _pattern;
internal readonly int _lowASCII;
internal readonly int _highASCII;
private readonly bool _rightToLeft;
private readonly bool _caseInsensitive;
internal readonly bool _caseInsensitive;
private readonly CultureInfo _culture;
/// <summary>

View File

@@ -151,7 +151,6 @@ namespace System.Text.RegularExpressions
}
}
#if DEBUG
internal static int OpcodeSize(int opcode)
{
opcode &= Mask;
@@ -212,6 +211,7 @@ namespace System.Text.RegularExpressions
}
}
#if DEBUG
private static readonly string[] CodeStr = new string[]
{
"Onerep", "Notonerep", "Setrep",

View File

@@ -0,0 +1,77 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Text.RegularExpressions
{
public class RegexCompilationInfo
{
private string _pattern;
private string _name;
private string _nspace;
private TimeSpan _matchTimeout;
public RegexCompilationInfo(string pattern, RegexOptions options, string name, string fullnamespace, bool ispublic)
: this(pattern, options, name, fullnamespace, ispublic, Regex.DefaultMatchTimeout)
{
}
public RegexCompilationInfo(string pattern, RegexOptions options, string name, string fullnamespace, bool ispublic, TimeSpan matchTimeout)
{
Pattern = pattern;
Name = name;
Namespace = fullnamespace;
Options = options;
IsPublic = ispublic;
MatchTimeout = matchTimeout;
}
public bool IsPublic { get; set; }
public TimeSpan MatchTimeout
{
get => _matchTimeout;
set
{
Regex.ValidateMatchTimeout(value);
_matchTimeout = value;
}
}
public string Name
{
get => _name;
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(Name));
}
if (value.Length == 0)
{
throw new ArgumentException(SR.Format(SR.InvalidEmptyArgument, nameof(Name)), nameof(Name));
}
_name = value;
}
}
public string Namespace
{
get => _nspace;
set
{
_nspace = value ?? throw new ArgumentNullException(nameof(Namespace));
}
}
public RegexOptions Options { get; set; }
public string Pattern
{
get => _pattern;
set => _pattern = value ?? throw new ArgumentNullException(nameof(Pattern));
}
}
}

View File

@@ -0,0 +1 @@
fac86269ec4ab0f16a400c531f4934efa4435b11

View File

@@ -0,0 +1,68 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
using System.Globalization;
namespace System.Text.RegularExpressions
{
internal class RegexLWCGCompiler : RegexCompiler
{
private static int s_regexCount = 0;
private static Type[] s_paramTypes = new Type[] { typeof(RegexRunner) };
internal RegexLWCGCompiler()
{
}
/*
* The top-level driver. Initializes everything then calls the Generate* methods.
*/
internal RegexRunnerFactory FactoryInstanceFromCode(RegexCode code, RegexOptions options)
{
_code = code;
_codes = code._codes;
_strings = code._strings;
_fcPrefix = code._fcPrefix;
_bmPrefix = code._bmPrefix;
_anchors = code._anchors;
_trackcount = code._trackcount;
_options = options;
// pick a unique number for the methods we generate
int regexnum = Interlocked.Increment(ref s_regexCount);
string regexnumString = regexnum.ToString(CultureInfo.InvariantCulture);
DynamicMethod goMethod = DefineDynamicMethod("Go" + regexnumString, null, typeof(CompiledRegexRunner));
GenerateGo();
DynamicMethod firstCharMethod = DefineDynamicMethod("FindFirstChar" + regexnumString, typeof(bool), typeof(CompiledRegexRunner));
GenerateFindFirstChar();
DynamicMethod trackCountMethod = DefineDynamicMethod("InitTrackCount" + regexnumString, null, typeof(CompiledRegexRunner));
GenerateInitTrackCount();
return new CompiledRegexRunnerFactory(goMethod, firstCharMethod, trackCountMethod);
}
/*
* Begins the definition of a new method (no args) with a specified return value
*/
internal DynamicMethod DefineDynamicMethod(string methname, Type returntype, Type hostType)
{
// We're claiming that these are static methods, but really they are instance methods.
// By giving them a parameter which represents "this", we're tricking them into
// being instance methods.
MethodAttributes attribs = MethodAttributes.Public | MethodAttributes.Static;
CallingConventions conventions = CallingConventions.Standard;
DynamicMethod dm = new DynamicMethod(methname, attribs, conventions, returntype, s_paramTypes, hostType, false /*skipVisibility*/);
_ilg = dm.GetILGenerator();
return dm;
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Xunit;
namespace System.Text.RegularExpressions.Tests
@@ -163,10 +164,23 @@ namespace System.Text.RegularExpressions.Tests
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot)]
public static void DebuggerAttributeTests()
{
DebuggerAttributes.ValidateDebuggerDisplayReferences(CreateCollection());
DebuggerAttributes.ValidateDebuggerTypeProxyProperties(CreateCollection());
CaptureCollection col = CreateCollection();
DebuggerAttributes.ValidateDebuggerDisplayReferences(col);
DebuggerAttributeInfo info = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(col);
PropertyInfo itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute<DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
Capture[] items = itemProperty.GetValue(info.Instance) as Capture[];
Assert.Equal(col, items);
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot)]
public static void DebuggerAttributeTests_Null()
{
TargetInvocationException ex = Assert.Throws<TargetInvocationException>(() => DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(CaptureCollection), null));
Assert.IsType<ArgumentNullException>(ex.InnerException);
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Xunit;
namespace System.Text.RegularExpressions.Tests
@@ -160,10 +161,23 @@ namespace System.Text.RegularExpressions.Tests
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot)]
public static void DebuggerAttributeTests()
{
DebuggerAttributes.ValidateDebuggerDisplayReferences(CreateCollection());
DebuggerAttributes.ValidateDebuggerTypeProxyProperties(CreateCollection());
GroupCollection col = CreateCollection();
DebuggerAttributes.ValidateDebuggerDisplayReferences(col);
DebuggerAttributeInfo info = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(col);
PropertyInfo itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute<DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
Group[] items = itemProperty.GetValue(info.Instance) as Group[];
Assert.Equal(col, items);
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot)]
public static void DebuggerAttributeTests_Null()
{
TargetInvocationException ex = Assert.Throws<TargetInvocationException>(() => DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(GroupCollection), null));
Assert.IsType<ArgumentNullException>(ex.InnerException);
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Xunit;
namespace System.Text.RegularExpressions.Tests
@@ -157,10 +158,23 @@ namespace System.Text.RegularExpressions.Tests
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot)]
public static void DebuggerAttributeTests()
{
DebuggerAttributes.ValidateDebuggerDisplayReferences(CreateCollection());
DebuggerAttributes.ValidateDebuggerTypeProxyProperties(CreateCollection());
MatchCollection col = CreateCollection();
DebuggerAttributes.ValidateDebuggerDisplayReferences(col);
DebuggerAttributeInfo info = DebuggerAttributes.ValidateDebuggerTypeProxyProperties(col);
PropertyInfo itemProperty = info.Properties.Single(pr => pr.GetCustomAttribute<DebuggerBrowsableAttribute>().State == DebuggerBrowsableState.RootHidden);
Match[] items = itemProperty.GetValue(info.Instance) as Match[];
Assert.Equal(col, items);
}
[Fact]
[SkipOnTargetFramework(TargetFrameworkMonikers.UapAot)]
public static void DebuggerAttributeTests_Null()
{
TargetInvocationException ex = Assert.Throws<TargetInvocationException>(() => DebuggerAttributes.ValidateDebuggerTypeProxyProperties(typeof(MatchCollection), null));
Assert.IsType<ArgumentNullException>(ex.InnerException);
}
}
}

View File

@@ -3,13 +3,14 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using Xunit;
namespace System.Text.RegularExpressions.Tests
{
public class RegexConstructorTests
public class RegexConstructorTests : RemoteExecutorTestBase
{
public static IEnumerable<object[]> Ctor_TestData()
{
@@ -75,6 +76,30 @@ namespace System.Text.RegularExpressions.Tests
AssertExtensions.Throws<ArgumentOutOfRangeException>("matchTimeout", () => new Regex("foo", RegexOptions.None, TimeSpan.FromMilliseconds(int.MaxValue)));
}
[Fact]
public static void StaticCtor_InvalidTimeoutObject_ExceptionThrown()
{
RemoteInvoke(() =>
{
AppDomain.CurrentDomain.SetData(RegexHelpers.DefaultMatchTimeout_ConfigKeyName, true);
Assert.Throws<TypeInitializationException>(() => Regex.InfiniteMatchTimeout);
return SuccessExitCode;
});
}
[Fact]
public static void StaticCtor_InvalidTimeoutRange_ExceptionThrown()
{
RemoteInvoke(() =>
{
AppDomain.CurrentDomain.SetData(RegexHelpers.DefaultMatchTimeout_ConfigKeyName, TimeSpan.Zero);
Assert.Throws<TypeInitializationException>(() => Regex.InfiniteMatchTimeout);
return SuccessExitCode;
});
}
[Fact]
public void CacheSize_Get()
{

View File

@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using Xunit;
namespace System.Text.RegularExpressions.Tests
@@ -266,6 +267,7 @@ namespace System.Text.RegularExpressions.Tests
[Theory]
[MemberData(nameof(Match_Basic_TestData))]
[MemberData(nameof(RegexCompilationHelper.TransformRegexOptions), nameof(Match_Basic_TestData), 2, MemberType = typeof(RegexCompilationHelper))]
public void Match(string pattern, string input, RegexOptions options, int beginning, int length, bool expectedSuccess, string expectedValue)
{
bool isDefaultStart = RegexHelpers.IsDefaultStart(input, options, beginning);
@@ -328,6 +330,21 @@ namespace System.Text.RegularExpressions.Tests
Assert.Equal("a", match.Value);
}
[Fact]
public void Match_Timeout_Throws()
{
RemoteInvoke(() =>
{
const string Pattern = @"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$";
string input = new string('a', 50) + "@a.a";
AppDomain.CurrentDomain.SetData(RegexHelpers.DefaultMatchTimeout_ConfigKeyName, TimeSpan.FromMilliseconds(100));
Assert.Throws<RegexMatchTimeoutException>(() => new Regex(Pattern).Match(input));
return SuccessExitCode;
});
}
public static IEnumerable<object[]> Match_Advanced_TestData()
{
// \B special character escape: ".*\\B(SUCCESS)\\B.*"
@@ -596,7 +613,7 @@ namespace System.Text.RegularExpressions.Tests
bool isDefaultCount = RegexHelpers.IsDefaultStart(input, options, length);
if (options == RegexOptions.None)
{
if (isDefaultStart && isDefaultCount)
if (isDefaultStart && isDefaultCount)
{
// Use Match(string) or Match(string, string)
VerifyMatch(new Regex(pattern).Match(input), true, expected);

View File

@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace System.Text.RegularExpressions.Tests
@@ -109,6 +110,7 @@ namespace System.Text.RegularExpressions.Tests
[Theory]
[MemberData(nameof(Replace_String_TestData))]
[MemberData(nameof(RegexCompilationHelper.TransformRegexOptions), nameof(Replace_String_TestData), 3, MemberType = typeof(RegexCompilationHelper))]
public void Replace(string pattern, string input, string replacement, RegexOptions options, int count, int start, string expected)
{
bool isDefaultStart = RegexHelpers.IsDefaultStart(input, options, start);
@@ -178,6 +180,7 @@ namespace System.Text.RegularExpressions.Tests
[Theory]
[MemberData(nameof(Replace_MatchEvaluator_TestData))]
[MemberData(nameof(RegexCompilationHelper.TransformRegexOptions), nameof(Replace_MatchEvaluator_TestData), 3, MemberType = typeof(RegexCompilationHelper))]
public void Replace(string pattern, string input, MatchEvaluator evaluator, RegexOptions options, int count, int start, string expected)
{
bool isDefaultStart = RegexHelpers.IsDefaultStart(input, options, start);

View File

@@ -9,7 +9,7 @@ namespace System.Text.RegularExpressions.Tests
{
public class RegexSplitTests
{
public static IEnumerable<object[]> Split_TestData()
public static IEnumerable<object[]> Split_NonCompiled_TestData()
{
yield return new object[] { " ", "word0 word1 word2 word3", RegexOptions.None, 32, 0, new string[] { "word0", "word1", "word2", "word3" } };
@@ -50,7 +50,8 @@ namespace System.Text.RegularExpressions.Tests
}
[Theory]
[MemberData(nameof(Split_TestData))]
[MemberData(nameof(Split_NonCompiled_TestData))]
[MemberData(nameof(RegexCompilationHelper.TransformRegexOptions), nameof(Split_NonCompiled_TestData), 2, MemberType = typeof(RegexCompilationHelper))]
public void Split(string pattern, string input, RegexOptions options, int count, int start, string[] expected)
{
bool isDefaultStart = RegexHelpers.IsDefaultStart(input, options, start);

Some files were not shown because too many files have changed in this diff Show More