Note that there are some explanatory texts on larger screens.

plurals
  1. POprotobuf-net Inheritance & Field Numbers
    text
    copied!<p>I am trying to construct a serialisation system for our application that must be able to handle inheritance. To further complicate matters the application is extensible so types might are very unlikely to be known at compile time.</p> <p>I have read through a <a href="https://stackoverflow.com/questions/6247513/protobuf-net-inheritance">previous stackoverflow question</a> that was answered and that helped me get a long way to my goal but I have hit a stumbling block that is probably more of a lack of understanding than any real issue!</p> <p>So this is the code that I have currently...</p> <pre><code>public interface IBaseFrame { } public class BasicDataFrame : IBaseFrame { } public class AnotherFrame : BasicDataFrame { } </code></pre> <p>. . . .</p> <pre><code>RuntimeTypeModel model = TypeModel.Create(); MetaType baseType = model.Add(typeof(IBaseFrame), true); MetaType basicFrameType = model.Add(typeof(BasicDataFrame),true); baseType.AddSubType(7, typeof(BasicDataFrame)); model.Add(typeof(AnotherFrame), true); basicFrameType.AddSubType(8, typeof(AnotherFrame)); </code></pre> <p>Now this code works correctly (as far as I can tell!) and all is good in the world... My concern is where the values 7 and 8 are used in the code above for the <em>fieldNumber</em> argument of the AddSubType method.</p> <p>As the plugins are enumerated I am registering their frame types with the SerialisationManager and I add them to the model with an incrementing counter for the <em>fieldNumber</em> (I start it at an arbitrarily large number so I don't have to worry about extending the base classes in the future). </p> <p>I am worried that if the plugins are enumerated in a different order or new ones are added (or removed) then the auto generated <em>fieldNumber</em> is going to be different for the different sub types that will then cause issues with sharing log files between users (who may have different plugins and therefore subtypes) or even files on the same system when a plugin may have been removed.</p> <p>Is there any cunning way of dealing with this kind of inheritance automatically and without introducing compatibility issues in the future or when plugins change or do I need to come up with a mechanism where these <em>fieldNumbers</em> can be guaranteed to remain contant across all installations?</p> <p>Any help or advice that can be given would be greatly appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload