Enable Regex compiler to be trimmed (dotnet/corefx#41075)
authorStephen Toub <stoub@microsoft.com>
Fri, 13 Sep 2019 00:21:41 +0000 (20:21 -0400)
committerGitHub <noreply@github.com>
Fri, 13 Sep 2019 00:21:41 +0000 (20:21 -0400)
commitc235d7252ca9df5122f1ea839fe555c03d961c4f
treef7cae31cb66783b543729f4f4a9f3945f48c057c
parent59d799a10bfa0d926a26ba99ead8f86147ab5747
Enable Regex compiler to be trimmed (dotnet/corefx#41075)

Today an app that just does:
```C#
Console.WriteLine(Regex.IsMatch("12345", "0*[1-9][0-9]*"));
```
and is trimmed will end up publishing a 105K System.Text.RegularExpression.dll, including the regex compiler for when the RegexOptions.Compiled is used.  We can refactor the constructors such that the compiler only ends up getting rooted when one of the ctors that takes options is used.  After this PR, if you don't pass RegexOptions, the 105K drops to 85K.

Commit migrated from https://github.com/dotnet/corefx/commit/31a5bba0e79a5ae875f691d70ec3b9789691136d
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Match.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Replace.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.Split.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs