Last active
January 31, 2018 19:29
-
-
Save mmodrow/cba84f0637c0f3bd92803b1c7cd82ed5 to your computer and use it in GitHub Desktop.
Demonstrates a misleading ArgumentOutOfRangeException when Parsing a RegexString without '/'-enclosure with Newtonsoft.Json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.RegularExpressions; | |
using Newtonsoft.Json; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
ClassWithRegexAttribute objectWithRegexAttribute = | |
JsonConvert.DeserializeObject<ClassWithRegexAttribute>( | |
"{\"RegexAttribute\": \"committing-some-shitty-code-on-my-colleagues\"}"); | |
} | |
} | |
public class ClassWithRegexAttribute | |
{ | |
public Regex RegexAttribute { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Relates to JamesNK/Newtonsoft.Json#1601