Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8861133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:25:27+00:00 2026-06-14T15:25:27+00:00

I have data in a Protocol Buffers format which can be described as follows

  • 0

I have data in a Protocol Buffers format which can be described as follows

message Sections {
    repeated Section sections = 1;
}

message Section {
    required uint32 type = 1;
    required bytes payload = 2;
}

message SectionType1 {
    required int32 fieldType1 = 1;
    // ...
}

message SectionType2 {
    required int32 fieldType2 = 1;
    // ...
}

message SectionType3 {
    required int32 fieldType3 = 1;
    // ...
}

I’m using the protobuf-net library (+ protogen + precompile).
How do I deserialize such data into DTOs similar to

public class Sections
{
    public List<Section> Sections { get; }
}

public abstract class Section
{
}

public class SectionType1 : Section
{
    public int FieldType1 { get; }
}

public class SectionType2 : Section
{
    public int FieldType2 { get; }
}

public class SectionType3 : Section
{
    public int FieldType3 { get; }
}

Is it possible to work with such data from .NET (using precompilation since I’m on a light framework)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:25:28+00:00Added an answer on June 14, 2026 at 3:25 pm

    To do that, you would have to do it manually – i.e. have

    [ProtoContract]
    public abstract class Section
    {
        [ProtoMember(1)] public int Type {get;set;}
        [ProtoMember(2)] public byte[] Payload {get;set;}
    }
    

    and handle the rest manually. protobuf-net inheritance maps top the following .proto schema:

    message Section {
        optional SectionType1 Type1 = 1;
        optional SectionType2 Type2 = 2;
        optional SectionType3 Type3 = 3;
    }
    

    where we have, say:

    [ProtoInclude(1, typeof(SectionType1)]
    [ProtoInclude(2, typeof(SectionType2)]
    [ProtoInclude(3, typeof(SectionType3)]
    public abstract class Section
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Protocol Buffer for logging data. message Message { required double val1 =
I have a graph data structure that I'd like to encode with protocol buffers
I'm trying to write an application which uses Google's protocol buffers to deserialize data
I have data from travel diaries which has been read in from a csv
I have an existing internal data model for a Picture , as follows: package
I have 4 files message.proto udp.h udp.cpp main.cpp message.proto is a google protocol buffer
I'm currently building a P2P-system which uses Protocol Buffers for all communication between the
We are using a application protocol which specifies the length indicator of the message
I am working on a parser for a serial data protocol. I have an
We have a Scala server that is getting a node tree using Protocol Buffers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.