Open
Description
Hi, Thanks for the nice plugin!! I found the differences in my generated files.
Version of protoc (protoc --version
)
libprotoc 2.6.1
Version of ProtocolBuffers.framework
2.4.1
.proto
file to reproduce
syntax = "proto2";
message SessionCommand {
required string name = 1;
};
message Request {
optional string name = 1;
}
message Input {
required SessionCommand command = 1;
optional Request request = 2;
};
Description
In (official) Java, request field is set the default value. It is not null.
public static final class Request extends
com.google.protobuf.GeneratedMessage implements
// @@protoc_insertion_point(message_implements:Request)
RequestOrBuilder {
private static final Request defaultInstance;
public static Request getDefaultInstance() {
return defaultInstance;
}
private void initFields() {
name_ = "";
}
static {
defaultInstance = new Request(true);
defaultInstance.initFields();
}
}
public static final class Input extends
com.google.protobuf.GeneratedMessage implements
// @@protoc_insertion_point(message_implements:Input)
InputOrBuilder {
private Commands.SessionCommand command_ = Commands.SessionCommand.getDefaultInstance();
private Commands.Request request_ = Commands.Request.getDefaultInstance();
private void initFields() {
command_ = Commands.SessionCommand.getDefaultInstance();
request_ = Commands.Request.getDefaultInstance();
}
static {
defaultInstance = new Input(true);
defaultInstance.initFields();
}
}
On the other hand, it is not set in protobuf-swift.
final public class Input : GeneratedMessage, GeneratedMessageProtocol {
public private(set) var command:SessionCommand!
public private(set) var hasCommand:Bool = false
public private(set) var request:Request!
public private(set) var hasRequest:Bool = false
In this case, optional string field is set empty string value.
final public class Request : GeneratedMessage, GeneratedMessageProtocol {
public private(set) var name:String = ""
This is incomprehensible for me. This is a spec or bug?
Metadata
Metadata
Assignees
Labels
No labels