Skip to content

Commit

Permalink
增加处理string为null bytes为null的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
AtheosCode committed Apr 20, 2020
1 parent d336e81 commit eb90860
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/HiProtobuf.Lib/DataHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ private void ProcessData(string path)
var tempCharUper = charArray[index + 1].ToString().ToUpper();
charArray[index + 1] = tempCharUper.ToCharArray()[0];
fieldName = new string(charArray);
fieldName = fieldName.Remove(index,1);
fieldName = fieldName.Remove(index, 1);
insField = insType.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
value = GetVariableValue(variableType, variableValue);
if (insField == null)
{
Log.Info($"文件: {name} 属性: {variableName} 没有反射获取到对应的数据");
}
Log.Info($"文件: {name} 属性: {variableName} 命名规则不正常,注意修复");
Log.Info($"文件: {name} 属性: {variableName} 命名规则不正常,注意修复");
}
insField?.SetValue(ins, value);
}
Expand Down Expand Up @@ -138,9 +138,9 @@ object GetVariableValue(string type, string value)
if (type == Common.bool_)
return isEmpty ? false : (value == "1");
if (type == Common.string_)
return value.ToString();
return isEmpty ? string.Empty : value.ToString();
if (type == Common.bytes_)
return ByteString.CopyFromUtf8(value.ToString());
return isEmpty ? ByteString.CopyFromUtf8(string.Empty) : ByteString.CopyFromUtf8(value.ToString());
if (type == Common.double_s)
{
RepeatedField<double> newValue = new RepeatedField<double>();
Expand Down
Binary file modified src/HiProtobuf.Test/bin/Debug/HiProtobuf.Lib.dll
Binary file not shown.
Binary file modified src/HiProtobuf.Test/bin/Debug/HiProtobuf.Lib.pdb
Binary file not shown.
Binary file modified src/HiProtobuf.Test/bin/Debug/HiProtobuf.Test.dll
Binary file not shown.
Binary file modified src/HiProtobuf.Test/bin/Debug/HiProtobuf.Test.pdb
Binary file not shown.

0 comments on commit eb90860

Please sign in to comment.