From bca8bc5631ee7242ad4ad86c3df9564e694a7e0b Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 12 Apr 2020 17:58:12 +0800 Subject: [PATCH] Generator: default to a schema filename in line to online resource The schema is in https://core.telegram.org/schema/json so it's more logical to expect the file to be named `json`, which is what would happen if you download it with wget, for example. --- TeleSharp.Generator/Program.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/TeleSharp.Generator/Program.cs b/TeleSharp.Generator/Program.cs index 3598628..675352f 100644 --- a/TeleSharp.Generator/Program.cs +++ b/TeleSharp.Generator/Program.cs @@ -20,10 +20,21 @@ namespace TeleSharp.Generator string MethodStyle = File.ReadAllText("Method.tmp"); //string method = File.ReadAllText("constructor.tt"); string Json = ""; - string url; - if (args.Count() == 0) url = "tl-schema.json"; else url = args[0]; - Json = File.ReadAllText(url); + string url; + if (!args.Any()) + url = "json"; + else + url = args[0]; + + try + { + Json = File.ReadAllText(url); + } + catch (FileNotFoundException ex) + { + throw new Exception ("Couldn't find schema JSON file, did you download it first e.g. with `wget https://core.telegram.org/schema/json`?", ex); + } FileStream file = File.OpenWrite("Result.cs"); StreamWriter sw = new StreamWriter(file); TlSchema schema = JsonConvert.DeserializeObject(Json);