code-cracker/code-cracker — pull request #180 by andrecarlucci (2014-12-29 22:50:15+00:00)
Title: Validate Json when used with Json.NET #2

I created 3 analysers, one for each of the json.net parsers:
- Newtonsoft.Json.JsonConvert.DeserializeObject(string)
- Newtonsoft.Json.Linq.JObject.Parse(string)
- Newtonsoft.Json.Linq.JArray.Parse(string)

The side effect is that we have to add json.net assembly to our tests and add it to the created project, otherwise it's impossible to get any info from the semantic model. It was easy to do, though (what a great job TestHelper is, I'm impressed).

Since json.net is already loaded by the time we call the semantic model, we can call the original method via reflection and it workes like a charm. This opens the opportunity to call any method we want during design time and check it in a generic way (I can do the refectory that enables that if we find more use cases).

If you don't care about adding json.net reference to the test assembly, I'll be very glad to learn from your feedback of my code. If that's not a good idea, I'm happy to have learned a lot doing this :)