Skip to content

Commit a9fe3da

Browse files
committed
[修改]1. 修改消息码的头部范围
1 parent 38a6018 commit a9fe3da

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

ProtoExport/MessageHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static partial class MessageHelper
1111
private const string MessagePattern = @"message\s+(\w+)\s*\{\s*([^}]+)\s*\}";
1212
private const string CommentPattern = @"//([^\n]*)\n\s*(enum|message)\s+(\w+)\s*{";
1313
private const string StartPattern = @"option start = (\d+);";
14-
private const string ModulePattern = @"option module = (\d+);";
14+
private const string ModulePattern = @"option module = (-?\d+);";
1515
private const string PackagePattern = @"package (\w+);";
1616

1717

@@ -36,14 +36,14 @@ public static MessageInfoList Parse(string proto, string fileName, string filePa
3636
Match moduleMatch = Regex.Match(proto, ModulePattern, RegexOptions.Singleline);
3737
if (moduleMatch.Success)
3838
{
39-
if (ushort.TryParse(moduleMatch.Groups[1].Value, out var value))
39+
if (short.TryParse(moduleMatch.Groups[1].Value, out var value))
4040
{
4141
messageInfo.Module = value;
4242
}
4343
else
4444
{
4545
Console.WriteLine("Module range error");
46-
throw new ArgumentOutOfRangeException("module", "Module range error==>module >= 0 and module <= 65535");
46+
throw new ArgumentOutOfRangeException("module", $"Module range error==>module > {short.MinValue} and module < {short.MaxValue}");
4747
}
4848
}
4949
else

ProtoExport/MessageInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class MessageInfoList
55
/// <summary>
66
/// 消息模块ID
77
/// </summary>
8-
public ushort Module { get; set; }
8+
public short Module { get; set; }
99

1010
/// <summary>
1111
/// 文件名

0 commit comments

Comments
 (0)