Coder Social home page Coder Social logo

silentorbit / protobuf Goto Github PK

View Code? Open in Web Editor NEW
298.0 298.0 104.0 1.1 MB

C# code generator for reading and writing the protocol buffers format

Home Page: https://silentorbit.com/protobuf/

License: MIT License

C# 100.00%
c-sharp protocol-buffer protocol-buffers protocolbuffers serialization

protobuf's People

Contributors

codeaid avatar deitry avatar hultqvist avatar meir017 avatar sauliusvl avatar wislon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protobuf's Issues

use compression

Example: CodeGenerator.exe test.proto --compress

it will be generate the normal thingw but an overload to serialize into gzipstream

It's impossible to import messages from arbitrary namespaces

I have the following structure of proto schemas:

/foo/Bar.proto
/baz/Qux.proto

Now I want to define a separate schema that utilizes both:

/norf/BarAndQux.proto

inside which I have smth like

package norf;

import "../foo/Bar.proto";
import "../baz/Qux.proto";

message BarAndQux {
   optional Bar bar = 1;
   optional Qux qux = 2;
}

While this compiles ok with Java and Scala generators, this code generator is complaining:
error CS001: Field type "Bar" not found for field bar in message norf.BarAndQux

It looks like in https://github.com/hultqvist/ProtoBuf/blob/master/CodeGenerator/Proto/Search.cs the search space is only limited to the enclosing and global namespaces.

Namespace are not turn into camel-case

My proto file is used in other environment which use lower-case names for packages.
When I build the C# file from the proto file the resulting namespace is Com.mycomp.myprod and I think it should be Com.Mycomp.Myprod.

Mono for Android: System.NotSupportedException

Stream.position is not supported for android asset streams

stacktrace:
at Android.Runtime.InputStreamInvoker.get_Position ()
at ActionLib.Proto.T_Sprite.DeserializeLengthDelimited (System.IO.Stream stream, ActionLib.Proto.T_Sprite instance)

line:
stream.Position

binary:
ProtoBuf-2014-08-23-bin.zip

Cannot open assembly '/bin/CodeGenerator/Debug/CodeGenerator.exe': No such file or directory.

Hello

Started using ProtoBuf on a mac.
I'm using ProtoBuf with unity3D and usually would generate the c# script with "generate_state.command" file.
Got this issue when trying to do it on mac:
Cannot open assembly '/bin/CodeGenerator/Debug/CodeGenerator.exe': No such file or directory.
The only solution was to type the following in a terminal:
export PROTO_BUF_PATH="/Users//Documents/ProtoBuf
echo $PROTO_BUF_PATH
source ~/.bash_profile
cd mono $PROTO_BUF_PATH/bin/CodeGenerator/Debug/CodeGenerator.exe Assets/Scripts/ProtoBuf/.proto

What is the issue here? Why do I need to tell the path each time? How can it be solved?
Thank you.

Add grouped message serialization

Implement the, by google, deprecated group wire format.

Compatible to the ProtobufNet implementation
[ProtoMember(1, DataFormat = DataFormat.Group)]

The goal is to get a less memory intensive serialization.

No RPC support

Is there a reason that RPC/services aren't supported?

Error parsing messages named using '_'

Hello,

I have the following .proto file:

package Test;

message __FileCheckSum {
    required string path = 2;
    required string sha = 3;
}

Parsing this file results in the following error:

[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: startIndex + length > this.length
Parameter name: length
  at System.String.Substring (Int32 startIndex, Int32 length) [0x00085] in /media/storage/extgit/mono/mcs/class/corlib/System/String.cs:342 
  at ProtocolBuffers.ProtoPrepare.GetCamelCase (System.String name) [0x00000] in <filename unknown>:0 
  at ProtocolBuffers.ProtoPrepare.PrepareMessage (ProtocolBuffers.ProtoMessage m) [0x00000] in <filename unknown>:0 
  at ProtocolBuffers.ProtoPrepare.Prepare (ProtocolBuffers.ProtoCollection file) [0x00000] in <filename unknown>:0 
  at ProtocolBuffers.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 
The application was terminated by a signal: SIGHUP

It seems that the problem is caused by the leading '_' in the message name.

proto3 schema not supported?

I've cloned master and built the CodeGenerator.

First thing is that it can't handle Java specific options:
option java_outer_classname = "foobar";
But it seems it just gives a warning and proceeds with the compiling:
Warning: Unknown option: java_outer_classname

And after that it expects proto2 field descriptors such as optional / required.
Does the compiler take the syntax field into account?? syntax = "proto3";

.proto(6,12): error CS001: unknown rule: string

Is there a special flag that needs to be set in order to get it to compile proto3 definitions?

Message type not found for field in nested message

The following .proto definition reproduces the issue:

message Data {
 optional double somefield = 1;
}

message Container {
  message Nested {
    optional Data nestedData = 1;
  }

  optional Nested myNestedMessage = 1;
}

The code at '//Second Search local namespace' can be replaced with the following to fix it:

ProtoMessage currentParent = this;
while (!(currentParent is ProtoCollection))
{
    pt = SearchMessage(topParent, currentParent.Package + "." + path);
    if (pt != null)
        return pt;

    currentParent = currentParent.Parent;
}

Default values for string field generate invalid C# code

I've created a message with default value like so:

message ProtocolVersion {
  required string current = 1 [default = "2.0.0"];
}

and it generate the following code which did not compile:

        /// <summary>Takes the remaining content of the stream and deserialze it into the instance.</summary>
        public static Test.Protocol.ProtocolVersion Deserialize(Stream stream, Test.Protocol.ProtocolVersion instance)
        {
            instance.Current = 2.0.0;   <------- This should have been a string
            instance.ServerSupported = 2.x;
            while (true)
            {
            ....

The default value was not wrapped with quotes, it was emitted bare.

Another problem is that the message class does not have the default value in it:

    public partial class ProtocolVersion
    {
        /// <summary> The current version of this protocol</summary>
        public string Current { get; set; }
    }

In other languages when creating new instance of ProtocolVersion message and getting the value of Current it will return the default value.

I use it as a way of adding "constant" to the protocol buffer.

Unexpected/not implemented: enum while parsing .proto file

Hello,

I am trying to generate code for the following .proto file:

package Test;

enum ValueType {
    INT                     = 1;
    STRING                  = 2;
    BOOL                    = 3;
    DOUBLE                  = 4;
    INT64                   = 5;
    BYTES                   = 6;

    INTLIST                 = 7;
    STRINGLIST              = 8;
    BOOLLIST                = 9;
    DOUBLELIST              = 10;
    INT64LIST               = 11;
    BYTESLIST               = 12;

    INTLISTLIST             = 13;
    STRINGLISTLIST          = 14;
    BOOLLISTLIST            = 15;
    DOUBLELISTLIST          = 16;
    INT64LISTLIST           = 17;
    BYTESLISTLIST           = 18;

//    STATECOUNT              = 19;
//    STATECHANGE             = 20;
//    OUTCOME                 = 21;
//    ACTION                  = 22;
//    GAMESTATE               = 23;
//    ENGINEEVENT             = 24;
    GAMEID                  = 25;
    GAMEIDLIST              = 26;
    OSUPGRADE               = 27;
    IPV4CONFIG              = 28;
    COMMAND                 = 29;
    COMMANDLIST             = 30;
    OSSTATUS                = 32;
    GMBLOGMSG               = 33;
    GMBLOGMSGLIST           = 34;
    QUEUEENCODEDELEMENT     = 35;
    QUEUEENCODEDELEMENTLIST = 36;
    PROCESSSTATUS           = 37;
    GAMEENGINECOUNTERS      = 38;
    INTSET          = 39;
    USBDEVICEID             = 41;
    USBDEVICEIDSET          = 42;
    GAMEENGINETRANSACTION   = 43;
    FILECHECKSUM            = 44;
    APPMANIFEST             = 45;
    APPMANIFESTSET          = 46;
    FIRMWAREPACKAGE         = 47;
    STRINGSET               = 48;
    INSPECTION              = 49;
    SEALING                 = 50;
    IDENTITY                = 51;
    IDENTITYSET             = 52;
    CALLHOMECONFIGURATION   = 53;
    CALLARGUMENTLIST        = 54;

    ENGINEWINNING           = 55;
    ENGINEOUTCOME           = 56;
    ENGINEOUTCOMEGROUP      = 57;
    ENGINEACTION            = 58;
    ENGINEUSERSTATE         = 59;
    ENGINEEVENT             = 60;
    TOUCHSCREENCALLIBRATION = 70;
}

message TypeOnly {
    optional ValueType type = 1;
}

Unfortunetly I get the following error:

Parsing /media/storage/gamblify/git/machinelibs/libsubject_mono/LibSubject/SubjectLibrary/GeneratedProtoBuf/system_configuration/system_configuration.proto
Format error in /media/storage/gamblify/git/machinelibs/libsubject_mono/LibSubject/SubjectLibrary/GeneratedProtoBuf/system_configuration/system_configuration.proto
Unexpected/not implemented: enum
The application exited with code: 255

It only seems to happen when enum's are placed outside any messages.

Best regards,
Christian

unhandled exception of type 'System.NotImplementedException' Unknown wire type: 7

I am trying to deserialise a kura mqtt package and get 'System.NotImplementedException' Unknown wire type: 7.
The kura proto file I used to generate the .cs files is here: https://github.com/eclipse/kura/blob/develop/kura/org.eclipse.kura.core.cloud/src/main/protobuf/kurapayload.proto
the message to be decode is this one, string of bytes value: "31,139,8,0,0,0,0,0,0,0,227,248,186,233,237,179,77,154,135,118,48,201,112,9,151,164,230,22,164,22,37,150,148,22,165,186,86,148,164,22,229,37,230,8,48,170,50,48,44,112,192,144,247,204,67,150,119,4,202,75,115,9,161,232,207,72,44,45,46,1,75,127,0,73,243,115,113,166,22,21,229,23,57,231,167,164,10,48,27,48,0,0,49,79,132,184,121,0,0,0"
Can you advise what the fix for this is?

Thanks,
Dan

at SilentOrbit.ProtocolBuffers.ProtocolParser.SkipKey(Stream stream, Key key) in c:\Development\GIT\MZP\MZP-NET\MultiZonePlayer\ThirdParty\ProtocolParser.cs:line 446
at Kuradatatypes.KuraPayload.Deserialize(Stream stream, KuraPayload instance) in c:\Development\GIT\MZP\MZP-NET\MultiZonePlayer\ThirdParty\kurapayload.Serializer.cs:line 105
at Kuradatatypes.KuraPayload.Deserialize(Byte[] buffer) in c:\Development\GIT\MZP\MZP-NET\MultiZonePlayer\ThirdParty\kurapayload.Serializer.cs:line 48
at MultiZonePlayer.Test.client_MqttMsgPublishReceived(Object sender, MqttMsgPublishEventArgs e) in c:\Development\GIT\MZP\MZP-NET\MultiZonePlayer\Test.cs:line 196
at uPLibrary.Networking.M2Mqtt.MqttClient.OnMqttMsgPublishReceived(MqttMsgPublish publish) in c:\Development\GIT\MZP\MZP-NET\M2Mqtt\MqttClient.cs:line 875
at uPLibrary.Networking.M2Mqtt.MqttClient.DispatchEventThread() in c:\Development\GIT\MZP\MZP-NET\M2Mqtt\MqttClient.cs:line 1704
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Non-unique XML names

XmlSerializer cannot always be created with the generated System.Serializable attributes.

An InvalidOperationException is raised when creating an XmlSerializer with an inner exception with message:

{"Types 'Example.MessageTwo.SubType' and 'Example.MessageOne.SubType' both use the XML type name, 'SubType', from namespace ''. Use XML attributes to specify a unique XML name and/or namespace for the type."}

The following .proto definition and C# code reproduce the exception:

.proto definition:

message MessageOne {  
  enum SubType {
    typeOneA = 1;
    typeOneB = 2;
  }

  optional SubType subType = 1;
}

message MessageTwo {
  enum SubType {
    typeTwoA = 1;
    typeTwoB = 2;
  }

  optional SubType subType = 1;
}

C# code:

using System;
using System.Xml;
using Example; // This is where my generated code went

namespace SerializeTest
{
    public class SerializeTest
    {
        [STAThread]
        static void Main(string[] args)
        {
            Type[] types = new Type[] { typeof(MessageOne), typeof(MessageTwo) };
            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(string), types);
        }
    }
}

Support disabling/overriding ConvertToCamelCase

I upgraded to the new source generator version of this and it is no longer valid to write a protobuf message for Unity engine types like Vector3.

//:namespace = UnityEngine
//:type = struct
//:external
message Vector3 {
	optional float x = 1 [default = 0];
	optional float y = 2 [default = 0];
	optional float z = 3 [default = 0];
}

Unity does not use camel case for Vector3 fields so, after upgrading, there is no way to make this work because the source generator doesn't allow ConvertToCamelCase to be disabled and I can't go and change Unity builtin types.

Include common .proto specs

Include googles .proto

Will require their copyright reproduced in binary releases - up to this implementation or the end user?

Map Duration to TimeSpan and Timestamp to DateTime.

Not support: Import proto files which defines enum

TestEnum.proto file:

package Personal;

enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;

}

and AddressBook.proto file:

import "TestEnum.proto";

package Personal;

message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;

message PhoneNumber {
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}

repeated PhoneNumber phone = 4;
}

message AddressBook {
repeated Person List = 1;
}


when generate code, error occurs:
AddressBook.proto(12,14): error CS001: Field type "PhoneType" not found for field type in message Personal.Person.PhoneNumber

Nameclash between fields and nested messages/classes

ProtocolBuffer definitions allow fields and nested messages with the same name:

message Container {
  message Nested {
    optional double somevalue = 1;
  }

  optional Nested Nested = 1;
}

This generates C# code that contains a nested class and a property with the same name. In C# this is not allowed however, which means the generated code will not compile.

I'm using a local change that 'fixes' it for my case. Although there are downsides...

static void PrepareProtoType(ProtoMessage m, Field f)
{

    f.ProtoType = GetBuiltinProtoType(f.ProtoTypeName);
    if (f.ProtoType == null)
        f.ProtoType = m.GetProtoType(f.ProtoTypeName);
    if (f.ProtoType == null)
    {
#if DEBUG
        //this will still return null but we keep it here for debugging purposes
        f.ProtoType = m.GetProtoType(f.ProtoTypeName);
#endif
        throw new ProtoFormatException("Field type \"" + f.ProtoTypeName + "\" not found for field " + f.ProtoName + " in message " + m.FullProtoName, f.Source);
    }

    //Change property name to C# style, CamelCase.
    //Avoid name clashes between nested classes and fields by appending "_field" to potential clashes
    string propertyName = GetCSPropertyName(m, f.ProtoName);

    bool nameclash = false;
    var container = f.ProtoType.Parent;
    if (container != null && !(container is ProtoCollection))
        nameclash = container.Messages.ContainsKey(propertyName);
    if (nameclash)
        propertyName += "_field";

    f.CsName = propertyName;

    if (f.OptionPacked)
    {
        if (f.ProtoType.WireType == Wire.LengthDelimited)
            throw new InvalidOperationException("Length delimited types cannot be packed");
    }
}

Support for serializing into arrays

Currently only List<> are supported.

It would at least be easily doable using repeated packed basic values.
For other repeated occurrences, perhaps load into a List<> and make it into an array when serialization finishes.

Immutable classes and Builders

The original ProtoBuf implementation generates immutable classes, as well as Builders that are mutable version of those classes. It would be nice to have this behavior reflected here too.

Flag for NOT generating the ProtocolParser.cs

A flag should be added to not have it write ProtocolParser.cs to the output directory.
This comes in handy when splitting your proto files over multiple directories, as it will put a ProtocolParser.cs in every directory atm (since i have to run it once per directory)

Compatibility with Visual Studio 2015 tech preview

Hello,

I'm excited about this tool. Great work so far! When I try to use it in Windows 10 tech preview, there are some problems. I'd like to help you resolve those before this stuff gets released in late July.

Using this .proto file
https://github.com/WhisperSystems/libaxolotl-java/blob/master/protobuf/WhisperTextProtocol.proto

I discovered 4 errors that seem to be related to compatibility with what namespaces are availalbe from Windows Universal C# class libraries in Windows 10.

There were four distinct bugs found in VS 2015 tech preview when generating. We need to help this community fix their tool.

  1. Streams apparently no longer have a close method. This is news to me, so maybe some deeper digging is needed.

Severity Code Description Project File Line
Error CS0117 'Stream' does not contain a definition for 'Close' libaxolotl-classlib C:\Users\Jeff\Source\Repos\libaxolotl-windows\libaxolotl-classlib\Protobuf\ProtocolParser.cs 185

  1. Encoding.GetString changed in VS 2015

Severity Code Description Project File Line
Error CS7036 There is no argument given that corresponds to the required formal parameter 'index' of 'Encoding.GetString(byte[], int, int)' libaxolotl-classlib C:\Users\Jeff\Source\Repos\libaxolotl-windows\libaxolotl-classlib\Protobuf\ProtocolParser.cs 16

  1. No Serializable type. I researched this one some. This may be the solution: http://stackoverflow.com/questions/26269025/xml-serialization-error-on-universal-store-app

Severity Code Description Project File Line
Error CS0234 The type or namespace name 'Serializable' does not exist in the namespace 'System' (are you missing an assembly reference?) libaxolotl-classlib C:\Users\Jeff\Source\Repos\libaxolotl-windows\libaxolotl-classlib\Protobuf\WhisperTextProtocol.Serializer.cs 787

  1. No ApplicationException in Universal C# class libraries. For now, I will just generate my own.

Severity Code Description Project File Line
Error CS0246 The type or namespace name 'ApplicationException' could not be found (are you missing a using directive or an assembly reference?) libaxolotl-classlib C:\Users\Jeff\Source\Repos\libaxolotl-windows\libaxolotl-classlib\Protobuf\ProtocolParser.cs 653

Problem reading protobuf data: InvalidDataException: Invalid field id: 0...

Hallo,

I get the following error while reading a protobuf message:
InvalidDataException: Invalid field id: 0, something went wrong in the stream

The schema looks like this:

package Test;

option java_package = "test";

message GameModeType {
    optional uint32 gamemode = 100;
}

The hex code of the protobuf message is:

30-01-3A-28-12-06-10-01-18-01-20-01-1A-06-10-01-18-01-20-01-22-06-10-01-18-01-20-01-2A-06-10-01-18-01-20-01-32-06-10-01-18-01-20-01-60-00-A0-06-01

And a file containing the message can be downloaded here:
https://dl.dropbox.com/u/1373661/gamemode.pb

The message contains a lot of fields which are to be ignored. The goal is only to read the gamemode (id 100) field.

I have no problem reading the protobuf message using the standard c++ parser.

Any ideas?

Best regards,
Christian

New C# Source Generation

The latest commit has major changes that is are compatible with previous workflow.
Previous code is now available on the console branch.

  • Using C# Source Generator instead of external console application to generate source files
  • Removed all command line options
  • Removed experimental MemoryStream allocations, turned out the default one was the fastest one

Another VS 2015 Compatibility bug

I was using the proto found here:
https://github.com/WhisperSystems/libaxolotl-java/blob/master/protobuf/LocalStorageProtocol.proto

And this generated code is causing an error because there is no GetBuffer() method on the Stream.

Severity Code Description Project File Line
Error CS1061 'MemoryStream' does not contain a definition for 'GetBuffer' and no extension method 'GetBuffer' accepting a first argument of type 'MemoryStream' could be found (are you missing a using directive or an assembly reference?) libaxolotl-csharp C:\Users\Jeff\Source\Repos\libaxolotl-windows\libaxolotl-csharp\Protobuf\LocalStorageProtocol.Serializer.cs 393

if (instance.SenderChain != null)
{
// Key for field: 6, LengthDelimited
stream.WriteByte(50);
msField.SetLength(0);
Textsecure.SessionStructure.Chain.Serialize(msField, instance.SenderChain);
// Length delimited byte array
uint length6 = (uint)msField.Length;
global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, length6);
stream.Write(msField.GetBuffer(), 0, (int)length6);

        }

On the surface, the fix seems to be the use of CopyTo() instead of GetBuffer(), although I am still testing this change to be sure.
Example:
msField.CopyTo(stream, (int)length6);

Remove dependency on CommandLine

The CommandLine project is being used to parse command line arguments.

Some time ago the development of that project has changed so much that it broke our integration and thus the git submodule points to an older commit.

The git submodule is in itself a problem, not to blame CommandLine for us including it as such.

The idea is to write something simple to parse arguments just enough to fit our need.

Hopefully without breaking existing functionality.

It does support Field options

It shows in ProtoFeatures.proto:

extend google.protobuf.FieldOptions {
optional float my_field_option = 50002;
}

message MyMessage {
optional int32 foo = 1 [(my_field_option) = 4.5];
}

Excute:

CodeGenerator.exe --fix-nameclash ProtoFeatures.proto -o ./output

Warning: Unknown field option: (my_field_option)

It does support Field options as you say:
Field options:

access - default: public, can be any, even private if generating a local class(default)
codetype - set an int64 field type to "DateTime" or "TimeSpan", the serializer will do the conversion for you.
generate - if set to false(default: true), the field/property is expected to be defined elsewhere in the project rather than the generated code.
readonly - make the message field a c# readonly field rather than a property.

Thank you.

Details:
E:\PBNET\protobuf-master\TestProgram\ProtoSpec>CodeGenerator.exe --fix-nameclash ProtoFeatures.proto -o ./output
Parsing E:\PBNET\protobuf-master\TestProgram\ProtoSpec\ProtoFeatures.proto
Warning: Unknown option: (my_file_option) = Hello world!
Warning: Unknown option: (my_message_option) = 1234
Warning: Unknown field option: (my_field_option)
Parsing E:\PBNET\protobuf-master\TestProgram\ProtoSpec\google\protobuf\descriptor.proto
Warning: Unknown option: java_package = com.google.protobuf
Warning: Unknown option: java_outer_classname = DescriptorProtos
Warning: Unknown option: optimize_for = SPEED
ProtoCollection:
message proto.test.my_message_v1
message proto.test.my_message_v1_no_preserve
message proto.test.my_message_v2
message proto.test.their_message
message proto.test.longMessage
message proto.test.Data
message proto.test.Container
message proto.test.MyMessage
message google.protobuf.FileDescriptorSet
message google.protobuf.FileDescriptorProto
message google.protobuf.DescriptorProto
message google.protobuf.FieldDescriptorProto
message google.protobuf.EnumDescriptorProto
message google.protobuf.EnumValueDescriptorProto
message google.protobuf.ServiceDescriptorProto
message google.protobuf.MethodDescriptorProto
message google.protobuf.FileOptions
message google.protobuf.MessageOptions
message google.protobuf.FieldOptions
message google.protobuf.EnumOptions
message google.protobuf.EnumValueOptions
message google.protobuf.ServiceOptions
message google.protobuf.MethodOptions
message google.protobuf.UninterpretedOption
message google.protobuf.SourceCodeInfo
Warning: renamed field: Google.Protobuf.DescriptorProto.ExtensionRangeField
Warning: renamed field: Google.Protobuf.UninterpretedOption.NamePart.NamePartField
Warning: renamed field: Google.Protobuf.SourceCodeInfo.LocationField
Saved: E:\PBNET\protobuf-master\TestProgram\ProtoSpec\output\ProtoFeatures.cs

Cannot open in Xamarin

I cloned the source. Tried to open in Xamarin.
I get the error message:

unknown file format: blah/blah/Protobuf/commandline/src/CommandLine/CommandLine.csproj

This might have something to do with the fact that the entire command line folder is empty...

Unused variable in DeserializeLengthDelimited method

I notice the compiler complain that there is unused variable name br in every DeserializeLengthDelimited method of every message class.
The first line of every such method has this line:
BinaryReader br = new BinaryReader(stream);

but this variable is really not every used.
There is BinaryReader br1 = new BinaryReader(ms1); line deep inside the method - I'm not sure if it is related.

Import/Include path

Im having an issue where i import a file using import "somefile.proto";
In protoc i can provide the -I someincludedir to tell it where it can look for imports, but CodeGenerator does not have this.

Fail to compile on Mono due to System.Collections.Concurrent

Hi,
I manage to compile the source code of the ProtoBuf generator on Mono on Mac OS but after I build the message source code I get a compilation error due to this line:
using System.Collections.Concurrent

Is it possible to add switch to not use this feature because AFAIK .NET 4 is not available on Mono at this point.

Have message classes use common Interface?

Atm all messages use partial classes to get functions such as Serialize, but this makes it impossible to use something like a generic type constraint. Wouldn't it be preferable to have all Message classes implement a common Interface?

An example of why this would be usefull:

void SendMessage<T>(UInt32 messageType, T message) where T: IProtoMessage {
  using (MemoryStream stream = new MemoryStream()) {
      // Prefix header to actual message
      using (BinaryWriter writer = new BinaryWriter(stream)) {
        writer.Write(messageType);

        // Actual message
        T.Serialize(stream, message);
        websocket.Send(stream.ToArray());
      }
    }
}

As far as I know this isnt currently possible.

Issue with a proto file

Hi

I have a proto file like this:

syntax = "proto3";

package _abbbd3832ad747a0a1b0cd1b3c6d6579;

enum Allocator {
// This needs to be here as a zero value.
DO_NOT_REMOVE = 0;
VALUE = 1;
};

enum StandardEventCodes {
// Signal: N/A
POWER_UP = 0;

// Signal: N/A
WAKE_UP = 1;

// Signal: N/A
POWER_OR_WAKE_UP = 2;
};

enum StandardFilterCodes {
// Signal: The current profile.
IS_CURRENT_PROFILE = 0;

// Signal: The restricted mode
// 0 - unrestricted
// 1 - restricted
// 2 - transport
// 3 - invalid
IS_RESTRICTED_MODE = 1;
};

enum StandardActionCodes {
// Signal: The profile to apply.
APPLY_PROFILE = 0;
};

message Config {
message Profile {
enum State {
ACTIVE = 0;
SLEEP = 1;
HIBERNATE = 2;
};

// The profile's state.
State state = 1;

// What will wake the device up (input, adc_threshold, cell, etc).
uint32 wakeup_mask = 2;

// How long to wait before applying this profile in seconds.
uint32 delay_s = 3;

};

repeated Profile profiles = 1;
};

If I add required or optional in front of uint32 it generates a cs file else it doesnot. Is there any way to fix this?

Nullable value types

The protocol buffer specification allow for fields to be optional. For the primitive types it is not possible to know whether they had a value of the default value or no value at all.

The idea is to add an option to the code generator "--nullable" that would use the c# nullable value types for optional fields.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.