【修复】修复proto typescript代码,当namespace为空时生成的代码编译错误
parent
6e091c7640
commit
252ed19b61
|
|
@ -39,11 +39,19 @@ namespace Luban.Common.Utils
|
||||||
|
|
||||||
public static string MakeCppNamespaceBegin(string module)
|
public static string MakeCppNamespaceBegin(string module)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(module))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return string.Join("", module.Split('.').Select(n => $"namespace {n} {{"));
|
return string.Join("", module.Split('.').Select(n => $"namespace {n} {{"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string MakeCppNamespaceEnd(string module)
|
public static string MakeCppNamespaceEnd(string module)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(module))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return string.Join("", module.Split('.').Select(n => $"}}"));
|
return string.Join("", module.Split('.').Select(n => $"}}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,9 +67,22 @@ namespace Luban.Common.Utils
|
||||||
|
|
||||||
public static string MakeTypescriptNamespaceBegin(string module)
|
public static string MakeTypescriptNamespaceBegin(string module)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(module))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return string.Join("", module.Split('.').Select(n => $"export namespace {n} {{"));
|
return string.Join("", module.Split('.').Select(n => $"export namespace {n} {{"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string MakeTypescriptNamespaceEnd(string module)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(module))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return MakeCppNamespaceEnd(module);
|
||||||
|
}
|
||||||
|
|
||||||
public static string MakeFullName(string module, string name)
|
public static string MakeFullName(string module, string name)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(module))
|
if (string.IsNullOrEmpty(module))
|
||||||
|
|
@ -83,6 +104,10 @@ namespace Luban.Common.Utils
|
||||||
|
|
||||||
public static string MakeGoNamespace(string module)
|
public static string MakeGoNamespace(string module)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(module))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return string.Join("", module.Split('.').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => UpperCaseFirstChar(s)));
|
return string.Join("", module.Split('.').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => UpperCaseFirstChar(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,6 +171,7 @@ namespace Luban.Common.Utils
|
||||||
"const",
|
"const",
|
||||||
"is",
|
"is",
|
||||||
"as",
|
"as",
|
||||||
|
"of",
|
||||||
"typeid",
|
"typeid",
|
||||||
"typeof",
|
"typeof",
|
||||||
"object",
|
"object",
|
||||||
|
|
@ -154,6 +180,7 @@ namespace Luban.Common.Utils
|
||||||
"in",
|
"in",
|
||||||
"os",
|
"os",
|
||||||
"sb",
|
"sb",
|
||||||
|
"if",
|
||||||
"ele",
|
"ele",
|
||||||
"new",
|
"new",
|
||||||
"friend",
|
"friend",
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ namespace Luban.Job.Common.Defs
|
||||||
|
|
||||||
public string TypescriptNamespaceBegin => TypeUtil.MakeTypescriptNamespaceBegin(Namespace);
|
public string TypescriptNamespaceBegin => TypeUtil.MakeTypescriptNamespaceBegin(Namespace);
|
||||||
|
|
||||||
public string TypescriptNamespaceEnd => TypeUtil.MakeCppNamespaceEnd(Namespace);
|
public string TypescriptNamespaceEnd => TypeUtil.MakeTypescriptNamespaceEnd(Namespace);
|
||||||
|
|
||||||
public string CppFullName => TypeUtil.MakeCppFullName(Namespace, Name);
|
public string CppFullName => TypeUtil.MakeCppFullName(Namespace, Name);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue