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 7078543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:33:39+00:00 2026-05-28T06:33:39+00:00

I assume it looks at your model and somehow gets things ready, so that

  • 0

I assume it looks at your model and somehow gets things ready, so that your first few serializations aren’t slowed. What if my messaging model has a message class with child classes? Does putting my parent class in the type argument prepare all the children too?

  • 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-05-28T06:33:40+00:00Added an answer on May 28, 2026 at 6:33 am

    (this answer assumes protobuf-net v2)

    If you mean Serializer.PrepareSerializer<T>(), then it will certainly inspect all the child-types, so the type-model will be prepared for them (meaning: it will figure out what fields/properties etc need serializing). It will pre-compile (i.e. IL-emit) the code for the parent class, but (looking at the code) not specifically for the derived types. If unattended, the derived types will compile themselves when first needed. I think! I can do a thorough check if you really want.

    However, if you use RuntimeTypeModel.Default.CompileInPlace(), it builds the entire model – everything known is prepared. Of course, that then leaves the dilemma of having to tell the model about them first ;p

    I’ll double check to see at what point the sub-type serializers are prepared, just to be sure. It might indeed make sense to cascade them.


    Update:

    it looks like it does indeed cascade to derived types, but not to the parent type (if any):

        [Test]
        public void CheckTypeSpecificCompileInPlaceCascadesToBaseAndChildTypes()
        {
            var model = TypeModel.Create();
            model[typeof(B)].CompileInPlace();
    
            Assert.IsTrue(model.IsPrepared(typeof(D)), "D"); // sub-sub-type
            Assert.IsTrue(model.IsPrepared(typeof(C)), "C"); // sub-type
            Assert.IsTrue(model.IsPrepared(typeof(B)), "B"); // self
            Assert.IsTrue(model.IsPrepared(typeof(A)), "A"); // base-type
        }
    
        [Test]
        public void CheckGlobalCompileInPlaceCascadesToBaseAndChildTypes()
        {
            var model = TypeModel.Create();
            model.Add(typeof (B), true); // give the model a clue!
            model.CompileInPlace();
    
            Assert.IsTrue(model.IsPrepared(typeof(D)), "D"); // sub-sub-type
            Assert.IsTrue(model.IsPrepared(typeof(C)), "C"); // sub-type
            Assert.IsTrue(model.IsPrepared(typeof(B)), "B"); // self
            Assert.IsTrue(model.IsPrepared(typeof(A)), "A"); // base-type
        }
    

    Here, the second test passes; the first test fails citing “A” – so the sub-types (“C” and “D”) were fully compiled. Since the base type will still get compiled on demand, this is probably fine as-is, but I could probably make it tract to ancestor types if that would be useful.

    (the IsPrepared method only exists in my local copy)

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

Sidebar

Related Questions

Assume I have a class that looks like this: class Sample { public string
I currently use SVN for a number of things that aren't exactly code, for
Here is the senario. I have a model called Permission. Lets assume it looks
Assume that we have N erlang nodes, running same application. I want to share
I am just wondering how some things work in gamedev: I know, that the
What would your own (I assume perfect) programming language look like? Give a small
I'm currently designing a Django based site. For simplicity lets assume that it is
Assume you have built (coded) your MVC Sencha Touch App with a bunch of
Assume you are working with a large working environment and you aren't great about
I assume that the basic setup for ASP.net web development today is: Windows Vista

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.