diff --git a/src/TeleSharp.Generator/Models/TlSchema.cs b/src/TeleSharp.Generator/Models/TlSchema.cs deleted file mode 100644 index ca1d82e..0000000 --- a/src/TeleSharp.Generator/Models/TlSchema.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; - -namespace TeleSharp.Generator.Models -{ - internal class TlSchema - { - [JsonProperty("constructors")] - public List Constructors { get; set; } - - [JsonProperty("methods")] - public List Methods { get; set; } - } -} \ No newline at end of file diff --git a/src/TeleSharp.Generator/App.config b/src/TgSharp.Generator/App.config similarity index 100% rename from src/TeleSharp.Generator/App.config rename to src/TgSharp.Generator/App.config diff --git a/src/TeleSharp.Generator/Constructor.tmp b/src/TgSharp.Generator/Constructor.tmp similarity index 100% rename from src/TeleSharp.Generator/Constructor.tmp rename to src/TgSharp.Generator/Constructor.tmp diff --git a/src/TeleSharp.Generator/ConstructorAbs.tmp b/src/TgSharp.Generator/ConstructorAbs.tmp similarity index 100% rename from src/TeleSharp.Generator/ConstructorAbs.tmp rename to src/TgSharp.Generator/ConstructorAbs.tmp diff --git a/src/TeleSharp.Generator/Method.tmp b/src/TgSharp.Generator/Method.tmp similarity index 100% rename from src/TeleSharp.Generator/Method.tmp rename to src/TgSharp.Generator/Method.tmp diff --git a/src/TeleSharp.Generator/Models/TlConstructor.cs b/src/TgSharp.Generator/Models/Constructor.cs similarity index 73% rename from src/TeleSharp.Generator/Models/TlConstructor.cs rename to src/TgSharp.Generator/Models/Constructor.cs index 9c0ee4e..f1b8058 100644 --- a/src/TeleSharp.Generator/Models/TlConstructor.cs +++ b/src/TgSharp.Generator/Models/Constructor.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; + using Newtonsoft.Json; -namespace TeleSharp.Generator.Models +namespace TgSharp.Generator.Models { - internal class TlConstructor + internal class Constructor { [JsonProperty("id")] public int Id { get; set; } @@ -12,7 +13,7 @@ namespace TeleSharp.Generator.Models public string Predicate { get; set; } [JsonProperty("params")] - public List Params { get; set; } + public List Params { get; set; } [JsonProperty("type")] public string Type { get; set; } diff --git a/src/TeleSharp.Generator/Models/TlMethod.cs b/src/TgSharp.Generator/Models/Function.cs similarity index 63% rename from src/TeleSharp.Generator/Models/TlMethod.cs rename to src/TgSharp.Generator/Models/Function.cs index a1e4b66..64588a4 100644 --- a/src/TeleSharp.Generator/Models/TlMethod.cs +++ b/src/TgSharp.Generator/Models/Function.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; + using Newtonsoft.Json; -namespace TeleSharp.Generator.Models +namespace TgSharp.Generator.Models { - internal class TlMethod + //called 'Function' because C# compiler doesn't let a property name == class + internal class Function { [JsonProperty("id")] public int Id { get; set; } @@ -12,7 +14,7 @@ namespace TeleSharp.Generator.Models public string Method { get; set; } [JsonProperty("params")] - public List Params { get; set; } + public List Params { get; set; } [JsonProperty("type")] public string Type { get; set; } diff --git a/src/TeleSharp.Generator/Models/TlParam.cs b/src/TgSharp.Generator/Models/Param.cs similarity index 74% rename from src/TeleSharp.Generator/Models/TlParam.cs rename to src/TgSharp.Generator/Models/Param.cs index 8cae783..a919935 100644 --- a/src/TeleSharp.Generator/Models/TlParam.cs +++ b/src/TgSharp.Generator/Models/Param.cs @@ -1,8 +1,8 @@ using Newtonsoft.Json; -namespace TeleSharp.Generator.Models +namespace TgSharp.Generator.Models { - internal class TlParam + internal class Param { [JsonProperty("name")] public string Name { get; set; } diff --git a/src/TgSharp.Generator/Models/Schema.cs b/src/TgSharp.Generator/Models/Schema.cs new file mode 100644 index 0000000..f21431c --- /dev/null +++ b/src/TgSharp.Generator/Models/Schema.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace TgSharp.Generator.Models +{ + internal class Schema + { + [JsonProperty("constructors")] + public List Constructors { get; set; } + + [JsonProperty("methods")] + public List Methods { get; set; } + } +} \ No newline at end of file diff --git a/src/TeleSharp.Generator/Program.cs b/src/TgSharp.Generator/Program.cs similarity index 98% rename from src/TeleSharp.Generator/Program.cs rename to src/TgSharp.Generator/Program.cs index 71ffc02..2afa9df 100644 --- a/src/TeleSharp.Generator/Program.cs +++ b/src/TgSharp.Generator/Program.cs @@ -3,9 +3,10 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using TeleSharp.Generator.Models; -namespace TeleSharp.Generator +using TgSharp.Generator.Models; + +namespace TgSharp.Generator { class Program { @@ -88,7 +89,7 @@ namespace TeleSharp.Generator } FileStream file = File.OpenWrite("Result.cs"); StreamWriter sw = new StreamWriter(file); - TlSchema schema = JsonConvert.DeserializeObject(Json); + Schema schema = JsonConvert.DeserializeObject(Json); foreach (var c in schema.Constructors) { interfacesList.Add(c.Type); @@ -343,7 +344,7 @@ namespace TeleSharp.Generator #endregion #region DeSerializeRespFunc var deserializeResp = ""; - TlParam p2 = new TlParam() { Name = "Response", Type = c.Type }; + var p2 = new Param() { Name = "Response", Type = c.Type }; deserializeResp += WriteReadCode(p2); temp = temp.Replace("/* DESERIALIZEResp */", deserializeResp); #endregion @@ -506,7 +507,7 @@ namespace TeleSharp.Generator return src; } - public static string WriteWriteCode(TlParam p, bool flag = false) + public static string WriteWriteCode(Param p, bool flag = false) { switch (p.Type.ToLower()) { @@ -534,7 +535,7 @@ namespace TeleSharp.Generator return $""; else { - TlParam p2 = new TlParam() { Name = p.Name, Type = p.Type.Split('?')[1] }; + Param p2 = new Param() { Name = p.Name, Type = p.Type.Split('?')[1] }; return $"if ((Flags & {GetBitMask(p.Type).ToString()}) != 0)" + Environment.NewLine + " " + WriteWriteCode(p2, true); @@ -542,7 +543,7 @@ namespace TeleSharp.Generator } } } - public static string WriteReadCode(TlParam p) + public static string WriteReadCode(Param p) { switch (p.Type.ToLower()) { @@ -575,7 +576,7 @@ namespace TeleSharp.Generator return $"{CheckForKeywordAndPascalCase(p.Name)} = (Flags & {GetBitMask(p.Type).ToString()}) != 0;"; else { - TlParam p2 = new TlParam() { Name = p.Name, Type = p.Type.Split('?')[1] }; + Param p2 = new Param() { Name = p.Name, Type = p.Type.Split('?')[1] }; return $"if ((Flags & {GetBitMask(p.Type).ToString()}) != 0)" + Environment.NewLine + " " + WriteReadCode(p2) + Environment.NewLine + " " + diff --git a/src/TeleSharp.Generator/Properties/AssemblyInfo.cs b/src/TgSharp.Generator/Properties/AssemblyInfo.cs similarity index 92% rename from src/TeleSharp.Generator/Properties/AssemblyInfo.cs rename to src/TgSharp.Generator/Properties/AssemblyInfo.cs index 7c4146a..57c37c7 100644 --- a/src/TeleSharp.Generator/Properties/AssemblyInfo.cs +++ b/src/TgSharp.Generator/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("TeleSharp.Generator")] +[assembly: AssemblyTitle("TgSharp.Generator")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TeleSharp.Generator")] +[assembly: AssemblyProduct("TgSharp.Generator")] [assembly: AssemblyCopyright("Copyright © 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/TeleSharp.Generator/TeleSharp.Generator.csproj b/src/TgSharp.Generator/TgSharp.Generator.csproj similarity index 91% rename from src/TeleSharp.Generator/TeleSharp.Generator.csproj rename to src/TgSharp.Generator/TgSharp.Generator.csproj index ec8fd85..1d651a5 100644 --- a/src/TeleSharp.Generator/TeleSharp.Generator.csproj +++ b/src/TgSharp.Generator/TgSharp.Generator.csproj @@ -7,8 +7,8 @@ {9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129} Exe Properties - TeleSharp.Generator - TeleSharp.Generator + TgSharp.Generator + TgSharp.Generator v4.6 512 true @@ -48,12 +48,12 @@ - + - - - + + + diff --git a/src/TeleSharp.Generator/packages.config b/src/TgSharp.Generator/packages.config similarity index 100% rename from src/TeleSharp.Generator/packages.config rename to src/TgSharp.Generator/packages.config diff --git a/src/TgSharp.sln b/src/TgSharp.sln index 7b36be7..1b09fc7 100644 --- a/src/TgSharp.sln +++ b/src/TgSharp.sln @@ -7,7 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TgSharp.Core", "TgSharp.Cor EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeleSharp.TL", "TeleSharp.TL\TeleSharp.TL.csproj", "{D6144517-91D2-4880-86DF-E9FF5D7F383A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeleSharp.Generator", "TeleSharp.Generator\TeleSharp.Generator.csproj", "{9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TgSharp.Generator", "TgSharp.Generator\TgSharp.Generator.csproj", "{9BE3B9D4-9FF6-4DC8-B9CC-EB2E3F390129}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TgSharp.Tests", "TgSharp.Tests\TgSharp.Tests.csproj", "{DE5C0467-EE99-4734-95F2-EFF7A0B99924}" EndProject