Skip to content

Commit a45deef

Browse files
committed
[增加]1. 增加字典的格式异常标识
1 parent aa752de commit a45deef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ProtoExport/MessageHelper.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static MessageInfoList Parse(string proto, string fileName, string filePa
2525
throw new Exception("Package not found==>example: package {" + fileName + "};");
2626
}
2727

28-
MessageInfoList messageInfo = new MessageInfoList
28+
var messageInfo = new MessageInfoList
2929
{
3030
OutputPath = Path.Combine(filePath, fileName),
3131
ModuleName = packageMatch.Groups[1].Value,
@@ -214,9 +214,14 @@ private static void ParseMessage(string proto, string packageName, List<MessageI
214214
if (fieldSplit.Length > 0)
215215
{
216216
var fieldSplitStrings = fieldSplit[0].Split(Utility.splitChars, StringSplitOptions.RemoveEmptyEntries);
217+
var key = fieldSplitStrings[0].Trim();
218+
if (key.Trim().StartsWith("map") && fieldSplitStrings.Length < 3)
219+
{
220+
throw new Exception($"[{packageName}] 包的 [{messageName}] 消息的 [{key}] 字段名称字典类型中间的[逗号]后面必须跟随空格\n");
221+
}
222+
217223
if (fieldSplitStrings.Length > 2)
218224
{
219-
var key = fieldSplitStrings[0].Trim();
220225
if (key.Trim().StartsWith("repeated"))
221226
{
222227
field.IsRepeated = true;

0 commit comments

Comments
 (0)