Skip to content

Commit cfb2f68

Browse files
committed
fix(ProtoBufMessageHandler): 修复Unity和TypeScript模式下未过滤服务端文件的问题
在Unity和TypeScript模式下添加对以"-s"或"_s"结尾的文件名过滤,避免生成不必要的客户端代码
1 parent dbfa3e3 commit cfb2f68

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

ProtoExport/ProtoBufMessageHandler.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,35 @@ public static void Start(LauncherOptions launcherOptions, ModeType modeType)
3232
var messageInfoLists = new List<MessageInfoList>(files.Length);
3333
foreach (var file in files)
3434
{
35-
var operationCodeInfo = MessageHelper.Parse(File.ReadAllText(file), Path.GetFileNameWithoutExtension(file), launcherOptions.OutputPath, launcherOptions.IsGenerateErrorCode);
35+
var fileName = Path.GetFileNameWithoutExtension(file);
36+
var operationCodeInfo = MessageHelper.Parse(File.ReadAllText(file), fileName, launcherOptions.OutputPath, launcherOptions.IsGenerateErrorCode);
3637
messageInfoLists.Add(operationCodeInfo);
3738
switch (modeType)
3839
{
3940
case ModeType.Server:
41+
{
42+
_protoGenerateHelper?.Run(operationCodeInfo, launcherOptions.OutputPath, launcherOptions.NamespaceName);
43+
}
44+
break;
4045
case ModeType.Unity:
46+
{
47+
if (fileName.EndsWith("-s") || fileName.EndsWith("_s"))
48+
{
49+
continue;
50+
}
51+
4152
_protoGenerateHelper?.Run(operationCodeInfo, launcherOptions.OutputPath, launcherOptions.NamespaceName);
53+
}
4254
break;
4355
case ModeType.TypeScript:
56+
{
57+
if (fileName.EndsWith("-s") || fileName.EndsWith("_s"))
58+
{
59+
continue;
60+
}
61+
4462
_protoGenerateHelper?.Run(operationCodeInfo, launcherOptions.OutputPath, Path.GetFileNameWithoutExtension(file));
63+
}
4564
break;
4665
default:
4766
throw new ArgumentOutOfRangeException();

0 commit comments

Comments
 (0)