Skip to content

Instantly share code, notes, and snippets.

@mmodrow
Last active January 31, 2018 19:29
Show Gist options
  • Save mmodrow/cba84f0637c0f3bd92803b1c7cd82ed5 to your computer and use it in GitHub Desktop.
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
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; }
}
@mmodrow
Copy link
Author

mmodrow commented Jan 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment