Visual Studio having problems referencing the internal class Converter
I was trying to use the QuickType converter to create C# JSON objects to add to my Visual Studio 2017 project and I'm not sure if the generated code should be fully "drop in" or if I need to hook it together. This is what I'm getting.
After using QuickType to convert some JSON objects, the resultant C# code uses the internal class Converter, but Visual Studio 2017 complains that the generated Converter method cannot be resolved in the generated classes.
The Converter class is defined as an internal class to the namespace.
internal class Converter : JsonConverter {
the partial class "Disclosure" defines a static FromJson method that returns the object where the bold method marks the unresolved code.
public partial class Disclosure {
public static Disclosure FromJson(string json) => JsonConvert.DeserializeObject<Disclosure>(json, Disclosure.**Converter**.Settings);
}
the static Serialize class defines a ToJson method that references the undefined Converter method.
public static class Serialize {
public static string ToJson(this Disclosure self) => JsonConvert.SerializeObject(self, Disclosure.**Converter**.Settings);
}
I'll add the generated file so you can have at least a picture of the generated code.
It seems that you manually changed the name of the namespace, but you didn't change it where Settings is referenced. You can tell quicktype to use a specific namespace name. Please use that option and you shouldn't get the error.
You can also use refactoring tools (or find and replace) to do an exhaustive manual rename within VS.
Sorry about that. That was a big "oh, duh" moment on my part. I even have resharper installed.