plutoo / protobuf-csharp-port

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

Implicit conversions of protos with one member #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I sometimes create protos with only one member, to get better type-safety.
For instance it's somewhat safer when a method getNode has signature
getNode(NodeID id) than getNode(int id), because in the later case your
risk passing some completely arbitary int to the method.

The problem with this approach however is that the type conversions are a
bit cumbersome. It would therefore be really cool if protos which only have
one member could implement implicit type conversion to the type of it's
member. 

Original issue reported on code.google.com by carl%cal...@gtempaccount.com on 1 Nov 2009 at 8:14

GoogleCodeExporter commented 9 years ago
I apologies for entering my feature-requests as defects but I haven't found a 
way to
enter them as feature-requests.

Original comment by carl%cal...@gtempaccount.com on 1 Nov 2009 at 8:15

GoogleCodeExporter commented 9 years ago
No problem - it should just be a case of changing the labels as you add the 
issue. 
Anyway, I'm not sure I really want to add implicit conversions by default. If 
you want 
to add an implicit conversion to a message you can always do so using the fact 
that 
they're partial classes - just create your own source file contributing to the 
same 
partial class.

I *could* add an option for implicit conversions, but I suspect this is a 
relatively 
rare requirement...

Original comment by jonathan.skeet on 19 May 2010 at 8:25

GoogleCodeExporter commented 9 years ago
Closing as will not implement, recommended workaround is noted above via 
partial class. 

Original comment by Grig...@gmail.com on 27 May 2011 at 12:55