Skip to content

Commit

Permalink
RegEx performance fix in TEHelpers (#1990)
Browse files Browse the repository at this point in the history
  • Loading branch information
gw79 authored May 14, 2020
1 parent c8110e6 commit 2946edc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion TechTalk.SpecFlow/Assist/TEHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace TechTalk.SpecFlow.Assist
{
internal static class TEHelpers
{
private static readonly Regex invalidPropertyNameRegex = new Regex(InvalidPropertyNamePattern, RegexOptions.Compiled);
private const string InvalidPropertyNamePattern = @"[^\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}\p{Nd}_]";

internal static T CreateTheInstanceWithTheDefaultConstructor<T>(Table table, InstanceCreationOptions creationOptions)
{
var instance = (T)Activator.CreateInstance(typeof(T));
Expand Down Expand Up @@ -84,7 +87,7 @@ internal static bool MatchesThisColumnName(this string propertyName, string colu
internal static string RemoveAllCharactersThatAreNotValidInAPropertyName(string name)
{
//Unicode groups allowed: Lu, Ll, Lt, Lm, Lo, Nl or Nd see https://msdn.microsoft.com/en-us/library/aa664670%28v=vs.71%29.aspx
return new Regex(@"[^\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Lo}\p{Nl}\p{Nd}_]").Replace(name, string.Empty);
return invalidPropertyNameRegex.Replace(name, string.Empty);
}

internal static string NormalizePropertyNameToMatchAgainstAColumnName(string name)
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Changes:

Fixes:
+ Empty value for nullable enum should not throw an exception
+ RegEx performance fix in TEHelpers (Table column name validation)


Fixes:
Expand Down

0 comments on commit 2946edc

Please sign in to comment.