Reputation: 5575
I created a sample application in VS2010 with .Net 4 setting. I am trying out the ProtoBuf-Net Extention methods. However, Whenever, I try to call GetValue extention, It throws an exception saying
Method or operation is not implemented
StackTrace:
at ProtoBuf.ExtensibleUtil.GetExtendedValues[TValue](IExtensible instance, Int32 tag, DataFormat format, Boolean singleton, Boolean allowDefinedTag)
at ProtoBuf.Extensible.TryGetValue[TValue](IExtensible instance, Int32 tag, DataFormat format, Boolean allowDefinedTag, TValue& value)
at ProtoBuf.Extensible.TryGetValue[TValue](IExtensible instance, Int32 tag, DataFormat format, TValue& value)
at ProtoBuf.Extensible.GetValue[TValue](IExtensible instance, Int32 tag, DataFormat format)
at ProtoBuf.Extensible.GetValue[TValue](IExtensible instance, Int32 tag)
at PhoneBookData.PhoneBookSerializer.Serialize(PhoneBookProto phData) in E:\project\PhoneBook\Source\PhoneBookData\PhoneBookSerializer.cs:line 14
at ConsoleApplication1.Program.Main(String[] args) in E:\project\PhoneBook\Source\ConsoleApplication1\Program.cs:line 23
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Below is my Proto class with Extention support.
[ProtoContract]
public class PhoneBookProto : Extensible
{
[ProtoMember(1, IsRequired=true)]
public string Name { get; set; }
[ProtoMember(2)]
public string Email { get; set; }
[ProtoMember(3)]
public AddressProto Address { get; set; }
[ProtoMember(4,IsRequired=true)]
public string PhoneNumber { get; set; }
}
[ProtoContract]
public class AddressProto
{
[ProtoMember(1)]
public string Line1 { get; set; }
[ProtoMember(2)]
public string Line2 { get; set; }
}
What am i doing wrong. I have reference the latest protobuf version (561) available for download. Below is my code which keeps crashing.
Extensible.AppendValue<int>(phData, 5, 10);
Extensible.GetValue<int>(phData, 5);
Edit the other older versions of protobuf also gives me the same exception
Upvotes: 1
Views: 466
Reputation: 1062780
Indeed. Extension data is one of the last pieces missing since the v2 re-write. As you can see it is next on the roadmap, but pragmatically (time availability etc) I've had to prioritise the most common .NET scenarios first. And extension data simply isn't the most common usage. V1 has a fully working extension data API, and r280 (IIRC) is still available.
Once I get into this, I do not anticipate (having written it once before) it being a huge piece of work, so I hope it will be in the build pretty soon.
Edit: this should be available from r565 onwards
Upvotes: 1