Skip to content

Commit

Permalink
Fixes the Regex serialization problem causing SortaKinda issue #26 (C…
Browse files Browse the repository at this point in the history
…redit: @doubleyewdee)
  • Loading branch information
R4d1o4ct1v3 committed Jul 19, 2024
1 parent a549d26 commit 8eb988d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Classes/UserRegex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ public struct UserRegex {
/// <summary> Default options optimized for efficiency. Compiled is always set. </summary>
public const RegexOptions DefaultOptions = RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Multiline | RegexOptions.NonBacktracking;

[JsonIgnore] private string text = string.Empty;
/// <summary> The user-supplied text. </summary>
public string Text { get; set; } = string.Empty;
public string Text {
get { return this.text; }
set { this.UpdateText(value); }
}

/// <summary> The compiled regex, if text is valid regex. </summary>
[JsonIgnore] public Regex? Regex { get; set; }
Expand All @@ -33,13 +37,13 @@ public UserRegex(Regex? regex)

/// <summary> Update the filter via text. </summary>
public void UpdateText(string text, RegexOptions options = DefaultOptions) {
Text = text;
this.text = text;
Regex = BuildRegex(text, options);
}

/// <summary> Update the filter via regex. </summary>
public void UpdateText(Regex? regex) {
Text = regex?.ToString() ?? string.Empty;
this.text = regex?.ToString() ?? string.Empty;
Regex = regex;
}

Expand Down

0 comments on commit 8eb988d

Please sign in to comment.