Re: [protobuf] Issue with extends

2021-08-03 Thread 'Adam Cozzette' via Protocol Buffers
Extensions are not quite like inheritance. The way I think of an extension
is that it is like an ordinary field except with the dependency inverted,
so that the field depends on the message rather than the message depending
on the field.

I haven't worked with the C# implementation, but as I understand the
generated code should include a static pb::Extension variable called Plot
(or similar), which you can use to get or set the extension on a GroupPlot
message. Here are some examples from the unit tests:
https://github.com/protocolbuffers/protobuf/blob/d13afed5639727c3c52d302ddfb3a0a04e21eb74/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs#L116

On Mon, Aug 2, 2021 at 9:58 PM Geervani BS  wrote:

> Hello All,
>
> I have a message as below:
>
> message DynamicGroupPlot
> {
>   extend GroupPlot {
> optional DynamicGroupPlot plot = 100;
>   }
>
>   repeated int32 line = 1
>   optional bool overlay = 5;
>   optional bool tdc_shift = 6;
>   optional bool smoothing = 7;
>   optional bool valve_events = 8;
>   optional bool theoretical = 9;
> }
>
>
> I am using c# compiler. With extends what I understood is, it will create
> a mapping between DynamicGroupPlot and GroupPlot  i.e some kind of
> inheritance. But the generated .cs files doesn't show any relationship
> between  DynamicGroupPlot  and GroupPlot .
>
> Here is the snippet from generated .cs file
>
>  public sealed partial class DynamicGroupPlot :
> pb::IMessage
>
>   {
>  .
> .
> .
> [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
> public DynamicGroupPlot() {
>   OnConstruction();
> }
>
> partial void OnConstruction();
>
> [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
> public DynamicGroupPlot(DynamicGroupPlot other) : this() {
>   _hasBits0 = other._hasBits0;
>   line_ = other.line_.Clone();
>   dynamicType_ = other.dynamicType_;
>   phasing_ = other.phasing_;
>   autoscale_ = other.autoscale_;
>   overlay_ = other.overlay_;
>   tdcShift_ = other.tdcShift_;
>   smoothing_ = other.smoothing_;
>   valveEvents_ = other.valveEvents_;
>   theoretical_ = other.theoretical_;
>   _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
> }
>
>
> I am new to protobuf. Any help is much appreciated.
>
>
> Regards
> Geervani
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/77c427d5-624e-4de5-a32d-031e5e97e7c2n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr7qT01RjNkrrJ0Vb6dvou9g5H4MQ269hcmQp6JG%3Dy59FQ%40mail.gmail.com.


[protobuf] Issue with extends

2021-08-02 Thread Geervani BS
Hello All,

I have a message as below:

message DynamicGroupPlot
{
  extend GroupPlot {
optional DynamicGroupPlot plot = 100; 
  }

  repeated int32 line = 1 
  optional bool overlay = 5;
  optional bool tdc_shift = 6;
  optional bool smoothing = 7;
  optional bool valve_events = 8;
  optional bool theoretical = 9;
}


I am using c# compiler. With extends what I understood is, it will create a 
mapping between DynamicGroupPlot and GroupPlot  i.e some kind of 
inheritance. But the generated .cs files doesn't show any relationship 
between  DynamicGroupPlot  and GroupPlot .

Here is the snippet from generated .cs file

 public sealed partial class DynamicGroupPlot : 
pb::IMessage
  
  {
 .
.
.
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public DynamicGroupPlot() {
  OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public DynamicGroupPlot(DynamicGroupPlot other) : this() {
  _hasBits0 = other._hasBits0;
  line_ = other.line_.Clone();
  dynamicType_ = other.dynamicType_;
  phasing_ = other.phasing_;
  autoscale_ = other.autoscale_;
  overlay_ = other.overlay_;
  tdcShift_ = other.tdcShift_;
  smoothing_ = other.smoothing_;
  valveEvents_ = other.valveEvents_;
  theoretical_ = other.theoretical_;
  _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}


I am new to protobuf. Any help is much appreciated.


Regards
Geervani

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/77c427d5-624e-4de5-a32d-031e5e97e7c2n%40googlegroups.com.