Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@stephentoub
Copy link
Member

Today an app that just does:

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.

cc: @ViktorHofer, @jkotas (@danmosemsft, just an example of what we talked about today)

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.
Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'm not concerned about the changed behavior in the deserialization path.

@stephentoub stephentoub merged commit 31a5bba into dotnet:master Sep 13, 2019
@stephentoub stephentoub deleted the regextrimming branch September 13, 2019 00:21
@stephentoub stephentoub added the assembly-size Issues related to the size of assemblies, before or after trimming label Sep 19, 2019
@karelz karelz added this to the 5.0 milestone Dec 19, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
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 dotnet/corefx@31a5bba
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Text.RegularExpressions assembly-size Issues related to the size of assemblies, before or after trimming

5 participants