当我尝试使用两个string[]或两个List打印模式时,会出现错误。string[]和List都可以
在目标类中有这个
public string[] ovoList;
public string[] procList;
在模式转换为字符串的行而不是在生成模式的行中导致错误。
static void Main(){
JSchemaGenerator generator = new JSchemaGenerator();
JSchema schema = generator.Generate(typeof(UNIKK.UIEngine.UIFrame));
//Error is thrown on two lines below
Console.WriteLine(schema);
File.WriteAllText(@"OVOSchema.json", schema.ToString());
我用Newtonsoft都试过了。JSON 6.0.8和最新的7。使用Newtonsoft.JSON.Schema 1.0.11和Newtonsoft.JSON.Schema 1.0.11,我使用nuget抓取它们并运行Xamarin的工作室5.9.5版本(build 10)Mono 4.0.3 ((detached/d6946b4)OS X
错误跟踪是
System.Uri。/private/tmp/source-mono-mac-4.0.0-branch-c5sr3/blockbuild -mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs:2062System.Uri.GetComponents(组件= System.UriComponents.Host | System.UriComponents.Port | System.UriComponents.Scheme | System.UriComponents。UserInfo, format=System. uriformat . unescaped) in/private/tmp/source-mono-mac-4.0.0-branch-c5sr3/blockbuild -mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs:1731System.Uri.Compare (uri1={#}, uri2={#/properties/ovoList}, partsToCompare=System.UriComponents. host |System.UriComponents. port |System.UriComponents. scheme |System.UriComponents. scheme)用户信息,compareFormat = System.UriFormat。在/private/tmp/source-mono-mac-4.0.0-branch-c5sr3/blockbuild -mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs中,未转写的comparisonType=System. stringcomparon . invariantcultureignorecase):1768System. uriparser . isbaseof (baseUri={#}, relativeUri={#/properties/ovoList}) in/private/tmp/source-mono-mac-4.0.0-branch-c5sr3/blockbuild -mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/UriParser.cs:208
System.Uri。IsBaseOf (uri={#/properties/ovoList})在/private/tmp/source-mono-mac-4.0.0-branch/blockbuild -mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/uri .cs:1740
问题是没有Id。这一计划。ToString函数希望procList属性引用ovoList属性,但由于没有模式的基本URI,它无法创建ref。
添加schema.Id = new Uri ("http://www.example.com/");
解决这个问题。