Full rutime working, Lite generator and runtime building but untested
diff --git a/src/ProtoGen/FieldGeneratorBase.cs b/src/ProtoGen/FieldGeneratorBase.cs
index 1c273b1..3520dc9 100644
--- a/src/ProtoGen/FieldGeneratorBase.cs
+++ b/src/ProtoGen/FieldGeneratorBase.cs
@@ -51,6 +51,7 @@
return true;
}
+ /// <remarks>Copy exists in ExtensionGenerator.cs</remarks>
protected string DefaultValue {
get {
string suffix = "";
@@ -84,6 +85,10 @@
if (!Descriptor.HasDefaultValue) {
return "pb::ByteString.Empty";
}
+ if (UseLiteRuntime && Descriptor.DefaultValue is ByteString) {
+ string temp = Convert.ToBase64String(((ByteString)Descriptor.DefaultValue).ToByteArray());
+ return String.Format("ByteString.FromBase64(\"{0}\")", temp);
+ }
return string.Format("(pb::ByteString) {0}.Descriptor.Fields[{1}].DefaultValue", GetClassName(Descriptor.ContainingType), Descriptor.Index);
case FieldType.String:
if (AllPrintableAscii(Descriptor.Proto.DefaultValue)) {
@@ -95,6 +100,10 @@
.Replace("\"", "\\\"")
+ "\"";
}
+ if (UseLiteRuntime && Descriptor.DefaultValue is String) {
+ string temp = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes((String)Descriptor.DefaultValue));
+ return String.Format("ByteString.FromBase64(\"{0}\").ToStringUtf8()", temp);
+ }
return string.Format("(string) {0}.Descriptor.Fields[{1}].DefaultValue", GetClassName(Descriptor.ContainingType), Descriptor.Index);
case FieldType.Enum:
return TypeName + "." + ((EnumValueDescriptor) Descriptor.DefaultValue).Name;