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

  • Home
  • SEARCH
  • 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 8997955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:57:34+00:00 2026-06-15T23:57:34+00:00

Having a class type (for example D that was inherited from C, that inherited

  • 0

Having a class type (for example D that was inherited from C, that inherited from B) how to list all class members (including inherited) that are marked with protobuf .net ProtoMember attribute in order from top parent to bottom descendant ( B members, C members, D members)?

  • 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-15T23:57:35+00:00Added an answer on June 15, 2026 at 11:57 pm

    Usually the answer would be just to check with reflection, using GetFields(), GetProperties(), and Attribute.IsDefined. However, in this case it may be more advisable to ask the protobuf-net model what it thinks exists:

    using ProtoBuf;
    using ProtoBuf.Meta;
    using System;
    [ProtoContract, ProtoInclude(5, typeof(Bar))]
    public class Foo
    {
        [ProtoMember(1)]
        public int X { get; set; }
    }
    [ProtoContract]
    public class Bar : Foo
    {
        [ProtoMember(1)]
        public string Y { get; set; }
    }
    static class Program {
        static void Main() {
            var metaType = RuntimeTypeModel.Default[typeof(Bar)];
            do {
                Console.WriteLine(metaType.Type.FullName);
                foreach(var member in metaType.GetFields())
                {
                    Console.WriteLine("> {0}, {1}, field {2}",
                        member.Member.Name, member.MemberType.Name,
                        member.FieldNumber);
                }
            } while ((metaType = metaType.BaseType) != null);
        }
    }
    

    The advantage of this is that it will work even for custom configurations (attributes are not the only mechanism for configuring protobuf-net)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with C++ calling elements of an array of type class .
Im having a problem with python.. I have a binary tree node type: class
In UML, if there's a class A having an object of type B as
I'm having a class with a list of constants. I want something like get_object_vars
Is it possible to get the class type from inside the static initialization block?
Imagine having a main class -- Simulator -- that uses two other classes --
Example: namespace MyApp.NET { class Class1 { public enum Types : byte = {t1,
I have a parent class that is also a factory. For example: Public Class
I'm having trouble creating a sub that can create objects of a variable type
I am having problems creating a new instance of a class by type with

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.