Skip to content

Commit a24a980

Browse files
committed
[修改]1. 修改服务器协议的代码格式
1 parent 53f741a commit a24a980

File tree

1 file changed

+42
-33
lines changed

1 file changed

+42
-33
lines changed

ProtoExport/ProtoBuffServerHelper.cs

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,74 +27,83 @@ public void Run(MessageInfoList messageInfoList, string outputPath, string names
2727
{
2828
if (operationCodeInfo.IsEnum)
2929
{
30-
sb.AppendLine($"\t/// <summary>");
31-
sb.AppendLine($"\t/// {operationCodeInfo.Description}");
32-
sb.AppendLine($"\t/// </summary>");
33-
sb.AppendLine($"\t[System.ComponentModel.Description(\"{operationCodeInfo.Description}\")]");
34-
sb.AppendLine($"\tpublic enum {operationCodeInfo.Name}");
35-
sb.AppendLine("\t{");
36-
foreach (var operationField in operationCodeInfo.Fields)
30+
sb.AppendLine($" /// <summary>");
31+
sb.AppendLine($" /// {operationCodeInfo.Description}");
32+
sb.AppendLine($" /// </summary>");
33+
sb.AppendLine($" [System.ComponentModel.Description(\"{operationCodeInfo.Description}\")]");
34+
sb.AppendLine($" public enum {operationCodeInfo.Name}");
35+
sb.AppendLine(" {");
36+
for (var index = 0; index < operationCodeInfo.Fields.Count; index++)
3737
{
38-
sb.AppendLine($"\t\t/// <summary>");
39-
sb.AppendLine($"\t\t/// {operationField.Description}");
40-
sb.AppendLine($"\t\t/// </summary>");
41-
sb.AppendLine($"\t\t[System.ComponentModel.Description(\"{operationField.Description}\")]");
42-
sb.AppendLine($"\t\t{operationField.Type} = {operationField.Members},");
38+
var operationField = operationCodeInfo.Fields[index];
39+
sb.AppendLine($" /// <summary>");
40+
sb.AppendLine($" /// {operationField.Description}");
41+
sb.AppendLine($" /// </summary>");
42+
sb.AppendLine($" [System.ComponentModel.Description(\"{operationField.Description}\")]");
43+
sb.AppendLine($" {operationField.Type} = {operationField.Members},");
44+
if (index < operationCodeInfo.Fields.Count - 1)
45+
{
46+
sb.AppendLine();
47+
}
4348
}
4449

45-
sb.AppendLine("\t}");
50+
sb.AppendLine(" }");
4651
sb.AppendLine();
4752
}
4853
else
4954
{
50-
sb.AppendLine($"\t/// <summary>");
51-
sb.AppendLine($"\t/// {operationCodeInfo.Description}");
52-
sb.AppendLine($"\t/// </summary>");
53-
sb.AppendLine($"\t[ProtoContract]");
54-
sb.AppendLine($"\t[System.ComponentModel.Description(\"{operationCodeInfo.Description}\")]");
55+
sb.AppendLine($" /// <summary>");
56+
sb.AppendLine($" /// {operationCodeInfo.Description}");
57+
sb.AppendLine($" /// </summary>");
58+
sb.AppendLine($" [ProtoContract]");
59+
sb.AppendLine($" [System.ComponentModel.Description(\"{operationCodeInfo.Description}\")]");
5560
if (string.IsNullOrEmpty(operationCodeInfo.ParentClass))
5661
{
57-
sb.AppendLine($"\tpublic sealed class {operationCodeInfo.Name}");
62+
sb.AppendLine($" public sealed class {operationCodeInfo.Name}");
5863
}
5964
else
6065
{
61-
sb.AppendLine($"\t[MessageTypeHandler({(messageInfoList.Module << 16) + operationCodeInfo.Opcode})]");
62-
sb.AppendLine($"\tpublic sealed class {operationCodeInfo.Name} : MessageObject, {operationCodeInfo.ParentClass}");
66+
sb.AppendLine($" [MessageTypeHandler({(messageInfoList.Module << 16) + operationCodeInfo.Opcode})]");
67+
sb.AppendLine($" public sealed class {operationCodeInfo.Name} : MessageObject, {operationCodeInfo.ParentClass}");
6368
}
6469

65-
sb.AppendLine("\t{");
66-
foreach (var operationField in operationCodeInfo.Fields)
70+
sb.AppendLine(" {");
71+
for (var index = 0; index < operationCodeInfo.Fields.Count; index++)
6772
{
73+
var operationField = operationCodeInfo.Fields[index];
6874
if (!operationField.IsValid)
6975
{
7076
continue;
7177
}
7278

73-
sb.AppendLine($"\t\t/// <summary>");
74-
sb.AppendLine($"\t\t/// {operationField.Description}");
75-
sb.AppendLine($"\t\t/// </summary>");
76-
sb.AppendLine($"\t\t[ProtoMember({operationField.Members})]");
77-
sb.AppendLine($"\t\t[System.ComponentModel.Description(\"{operationField.Description}\")]");
79+
sb.AppendLine($" /// <summary>");
80+
sb.AppendLine($" /// {operationField.Description}");
81+
sb.AppendLine($" /// </summary>");
82+
sb.AppendLine($" [ProtoMember({operationField.Members})]");
83+
sb.AppendLine($" [System.ComponentModel.Description(\"{operationField.Description}\")]");
7884
if (operationField.IsRepeated)
7985
{
80-
sb.AppendLine($"\t\tpublic List<{operationField.Type}> {operationField.Name} {{ get; set; }} = new List<{operationField.Type}>();");
86+
sb.AppendLine($" public List<{operationField.Type}> {operationField.Name} {{ get; set; }} = new List<{operationField.Type}>();");
8187
}
8288
else
8389
{
8490
string defaultValue = string.Empty;
8591
if (operationField.IsKv)
8692
{
8793
defaultValue = $" = new {operationField.Type}();";
88-
sb.AppendLine($"\t\t[ProtoMap(DisableMap = true)]");
94+
sb.AppendLine($" [ProtoMap(DisableMap = true)]");
8995
}
9096

91-
sb.AppendLine($"\t\tpublic {operationField.Type} {operationField.Name} {{ get; set; }}{defaultValue}");
97+
sb.AppendLine($" public {operationField.Type} {operationField.Name} {{ get; set; }}{defaultValue}");
9298
}
9399

94-
sb.AppendLine();
100+
if (index < operationCodeInfo.Fields.Count - 1)
101+
{
102+
sb.AppendLine();
103+
}
95104
}
96105

97-
sb.AppendLine("\t}");
106+
sb.AppendLine(" }");
98107
sb.AppendLine();
99108
}
100109
}

0 commit comments

Comments
 (0)