ebceu4 / protobuf-csharp-port

Automatically exported from code.google.com/p/protobuf-csharp-port
0 stars 0 forks source link

Unable to compile DescriptorProtoFile.cs under Mono #59

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Generate the DescriptorProtoFile.cs , CSharpOptions.cs and Protocal.cs

I used
mono ProtoGen.exe -line_break=Unix 
-output_directory=../PDServer/PDServer/protocal --proto_path=./proto 
--include_imports ./proto/myproto.proto

2. Add all three files (DescriptorProtoFile.cs , CSharpOptions.cs and 
Protocal.cs) to the project, and the Google.ProtocolBuffers.dll hit build.

3. I'm using 

Monodevelop 2.8.8.1 

mono version 
Mono JIT compiler version 3.0.4 (tarball Thu Mar  7 10:40:07 UTC 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. 
www.mono-project.com

Running on OpenSuse openSUSE 12.3 (x86_64)

The .net 3.5 version of Google.ProtocolBuffers.dll

The cs files do compile under VS2012 and run and they are identical.

What is the expected output? What do you see instead?
I expect it to compile with out the following error.

/home/michael/test/test/DescriptorProtoFile.cs(37,37): Error CS0311: The type 
`Google.ProtocolBuffers.DescriptorProtos.FileOptions.Builder' cannot be used as 
type parameter `TBuilder' in the generic type or method 
`Google.ProtocolBuffers.FieldAccess.FieldAccessorTable<TMessage,TBuilder>'. 
There is no implicit reference conversion from 
`Google.ProtocolBuffers.DescriptorProtos.FileOptions.Builder' to 
`Google.ProtocolBuffers.IBuilder<Google.ProtocolBuffers.DescriptorProtos.FileOpt
ions,Google.ProtocolBuffers.DescriptorProtos.FileOptions.Builder>' (CS0311) 
(test)

/home/michael/test/test/DescriptorProtoFile.cs(37,37): Error CS0311: The type 
`Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Builder' cannot be used 
as type parameter `TBuilder' in the generic type or method 
`Google.ProtocolBuffers.FieldAccess.FieldAccessorTable<TMessage,TBuilder>'. 
There is no implicit reference conversion from 
`Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Builder' to 
`Google.ProtocolBuffers.IBuilder<Google.ProtocolBuffers.DescriptorProtos.Message
Options,Google.ProtocolBuffers.DescriptorProtos.MessageOptions.Builder>' 
(CS0311) (test)

NOTE: First error is on line 38 of the DescriptorProtoFile.cs none of the other 
declarations fail only all the 'Options ones'
global::Google.ProtocolBuffers.DescriptorProtos.FileOptions
..MessageOptions
..FieldOptions
..EnumOptions
..EnumValueOptions
..ServiceOptions
..MethodOptions

Hopefully I'm missing something obvious.

What version of the product are you using? On what operating system?
Version 2.4.1.521 release binaries only.

Linux protoc --version
libprotoc 2.4.1

I simlinked protoc.exe to /usr/bin/protoc

Please provide any additional information below.
My test proto file is attached. Its a trimmed down version of the real one.

The source does compile and run fine under Visual Studio.

If you do not include  DescriptorProtoFile.cs and CSharpOptions.cs in your 
project it compiles fine but crashes when you receive your first packet and try 
and decode it.

Original issue reported on code.google.com by micha...@posdroid.com on 21 Jun 2013 at 8:46

Attachments:

GoogleCodeExporter commented 9 years ago
Just to clarify, there are two steps here which can vary:

- Running ProtoGen
- Building the generated code

When you say that the source compiles under Visual Studio, do you mean the 
exact same source that fails to compile with Mono, i.e. the source generated by 
running "mono ProtoGen.exe ..."? Or source generated with a non-Mono ProtoGen 
invocation?

Original comment by jonsk...@google.com on 21 Jun 2013 at 8:50

GoogleCodeExporter commented 9 years ago
Ok the source that generated is checked into Git. It compiles on windows but 
not on Mono.

I ran some more tests and the .cs files generated by windows ProtoGen are 
identical to those generated by calling "mono ProtoGen.exe..." I checked them 
in beyond compare, and then to be really paranoid did md5sums and they are the 
same.

Dose that make this a mono issue?

Original comment by micha...@posdroid.com on 21 Jun 2013 at 9:58

GoogleCodeExporter commented 9 years ago
If the same source compiles with Microsoft's C# compiler but not Mono's, that 
definitely makes it sound like a problem *either* with the Mono compiler *or* 
with however you're building with it.

Original comment by jonathan.skeet on 21 Jun 2013 at 10:10

GoogleCodeExporter commented 9 years ago
I agree.

I have created a bran new 'blank' console project I add the three generated .cs 
files to it and the reference to the Google.ProtocolBuffers.dll and I still get 
the issue above.

However in Mono's defence It's does compile up the rest of our program without 
issue.
I'm checking out the latest monodevelop and will see if that helps ( onces it's 
all complied up).

If that dosn't work I'll see about compiling it from the command line <gulp> :).

Cheers

Michael.

Original comment by micha...@posdroid.com on 21 Jun 2013 at 10:35

GoogleCodeExporter commented 9 years ago
Well no luck by moving MonoDevelop to 4.1.4 and mono is
Mono JIT compiler version 3.0.4
I have tried changing the .Net version it's compiled against 2/3/3.5/4/4.5

You can see how it is being compiled here ( command line ) 

http://pastebin.com/94d8SXWD

If you can see any problems please let me know otherwise I'll have to see if I 
can dig a little deeper under the hood.

Michael

Original comment by micha...@posdroid.com on 21 Jun 2013 at 11:12

GoogleCodeExporter commented 9 years ago
Ok the generated DescriptorProtoFile.cs fails under Mono C# compiler version 
3.0.4.0
This is the version Running on OpenSuse openSUSE 12.3 (x86_64), at least on 
_my_ machine

However it works under 
Mono C# compiler version 2.10.2.0 (offical Mono stable)
and 2.10.8.1 (Ubuntu 12.10)

I hope this helps someone else.

Michael

Original comment by micha...@posdroid.com on 22 Jun 2013 at 8:53

GoogleCodeExporter commented 9 years ago
Thanks. I remember seeing some problems getting it to compile under Mono 
before, but I thought it was all fixed. I'll try to find some time to look into 
it.

Original comment by jonathan.skeet on 22 Jun 2013 at 9:17

GoogleCodeExporter commented 9 years ago
Hang on - you say you were compiling DescriptorProtoFile.cs? You don't need to 
do that - that contains types which are already present in 
Google.ProtocolBuffers.dll. I suspect that's the problem; the compiler is 
getting confused between the different types involved.

Both DescriptorProtoFile.cs and CSharpOptions.dll are already compiled into 
Google.ProtocolBuffers.dll, and should *not* be included into your project.

Can you confirm that there's no problem just compiling the *other* files? 
(Protocal.cs in the sample you've given.)

Original comment by jonathan.skeet on 13 Aug 2013 at 6:17