@@ -153,14 +153,21 @@ static string GenerateProtocolMessageField(FieldInfo field, ref int count)
153153 string content = "repeated " ;
154154 Type type = field . FieldType . GetGenericArguments ( ) [ 0 ] ;
155155
156- content += GetTypeName ( type ) + " " + GenerateProtocolFieldName ( field ) + " = " + count ++ + ";\n " ;
156+ content += GetTypeName ( type ) . ToLower ( ) + " " + GenerateProtocolFieldName ( field ) + " = " + count ++ + ";\n " ;
157157
158158 return content ;
159159 }
160+ else if ( field . FieldType == typeof ( string ) )
161+ {
162+ return "required string " + GenerateProtocolFieldName ( field ) + " = " + count ++ + ";\n " ;
163+ }
160164
161165 else
162166 {
163- return "required string " + GenerateProtocolFieldName ( field ) + " = " + count ++ + ";\n " ;
167+ string content = "required " ;
168+ content += GetTypeName ( field . FieldType ) . ToLower ( ) + " " + GenerateProtocolFieldName ( field ) + " = " + count ++ + ";\n " ;
169+
170+ return content ;
164171 }
165172 }
166173
@@ -367,9 +374,9 @@ static void GenerateProtocolToCsharp()
367374 {
368375 output += GenerateProtocolClass ( 2 , SendMode . Both , null , s_SubStruct [ i ] , protocolInfo [ s_SubStruct [ i ] ] , true ) ;
369376 }
370- catch
377+ catch ( Exception e )
371378 {
372- throw new Exception ( "s_SubStruct[i] ->" + s_SubStruct [ i ] ) ;
379+ throw new Exception ( "s_SubStruct[i] ->" + s_SubStruct [ i ] + " \n " + e . ToString ( ) ) ;
373380 }
374381 }
375382 output += GetTab ( 1 ) + "#endregion \n " ;
@@ -637,7 +644,8 @@ static void GenerateList()
637644
638645 for ( int i = 0 ; i < types . Length ; i ++ )
639646 {
640- if ( typeof ( IProtocolStructInterface ) . IsAssignableFrom ( types [ i ] ) )
647+ if ( typeof ( IProtocolStructInterface ) . IsAssignableFrom ( types [ i ] )
648+ && types [ i ] != typeof ( IProtocolStructInterface ) )
641649 {
642650 StructList . Add ( types [ i ] ) ;
643651 }
@@ -800,8 +808,7 @@ static string GeneratePrototalList()
800808
801809 for ( int j = 0 ; j < msgList . Count ; j ++ )
802810 {
803- if ( msgList [ j ] . IsSubclassOf ( ModuleList [ i ] ) ||
804- ModuleList [ i ] . IsAssignableFrom ( msgList [ i ] ) )
811+ if ( msgList [ j ] . IsSubclassOf ( ModuleList [ i ] ) )
805812 {
806813 string nameTmp = GenerateProtocolName ( msgList [ j ] ) ;
807814 if ( ! nameList . Contains ( nameTmp ) )
@@ -990,7 +997,7 @@ static string GenerateSerializeFieldContent(int tab, FieldInfo field, string aim
990997 {
991998 content += GetTab ( tab ) + "{\n " ;
992999
993- content += GetTab ( tab + 1 ) + "List<" + typeTmp + " > list = new List<" + typeTmp + " >();\n ";
1000+ content += GetTab ( tab + 1 ) + "List<object > list = new List<object >();\n " ;
9941001 content += GetTab ( tab + 1 ) + "for(int i = 0;i <" + sourceName + "." + field . Name + ".Count ; i++)\n " ;
9951002
9961003 content += GetTab ( tab + 1 ) + "{\n " ;
@@ -1004,7 +1011,7 @@ static string GenerateSerializeFieldContent(int tab, FieldInfo field, string aim
10041011 {
10051012 content += GetTab ( tab ) + "{\n " ;
10061013
1007- content += GetTab ( tab + 1 ) + "List<Dictionary<string, object>> list" + tab + " = new List<Dictionary<string, object> >();\n " ;
1014+ content += GetTab ( tab + 1 ) + "List<object> list" + tab + " = new List<object>();\n " ;
10081015 content += GetTab ( tab + 1 ) + "for(int i" + tab + " = 0;i" + tab + " <" + sourceName + "." + field . Name + ".Count ; i" + tab + "++)\n " ;
10091016
10101017 content += GetTab ( tab + 1 ) + "{\n " ;
@@ -1117,8 +1124,9 @@ static string GenerateAnalysisContent(int tab, FieldInfo field, string aimName,s
11171124 else
11181125 {
11191126 content += GetTab ( tab ) + "{\n " ;
1120- content += GenerateAnalysisClassContent ( tab + 1 , field . FieldType , "tmp" + tab + "" , sourceName ) ;
1121-
1127+ content += GetTab ( tab + 1 ) + "Dictionary<string, object> data" + tab + " = (Dictionary<string, object>)" + sourceName + "[\" " + GenerateProtocolFieldName ( field ) + "\" ];\n " ;
1128+ content += GenerateAnalysisClassContent ( tab + 1 , field . FieldType , "tmp" + tab + "" , "data" + tab ) ;
1129+
11221130 content += GetTab ( tab + 1 ) + aimName + "." + field . Name + " = " + "tmp" + tab + ";\n " ;
11231131
11241132 content += GetTab ( tab ) + "}\n " ;
0 commit comments