Warning using Bouncy Castle v.2.3.0
Hello,
using Bouncy Castle v.2.3.0, I have the following warning: 'Asn1TaggedObject.GetObject()' is obsolete: 'Will be removed'
Can you indicate me the new method to use instead it, please?
In this moment, I am trying "Asn1TaggedObject.GetBaseObject()". And in my first tests, I have not failures.
Is this the correct solution?
A direct drop-in for:
Asn1Object asn1Object = taggedObject.GetObject();
would be:
Asn1Utilities.CheckContextTagClass(taggedObject);
Asn1Object asn1Object = taggedObject.GetBaseObject().ToAsn1Object();
which is basically just inlining the current implementation. CheckContextTagClass can throw, so you might prefer to test taggedObject.HasContextTag() instead.
I would suggest though that you provide a little detail about the call, in particular what your code is expecting to find (i.e. is there a cast or GetInstance call for the return value?) and/or the ASN.1 datatype of which this tagged object is a member (e.g. is it a named type from some RFC?). Direct usage of GetObject() has historically been very error prone in user code.
A direct drop-in for:
Asn1Object asn1Object = taggedObject.GetObject();would be:
Asn1Utilities.CheckContextTagClass(taggedObject); Asn1Object asn1Object = taggedObject.GetBaseObject().ToAsn1Object();which is basically just inlining the current implementation.
CheckContextTagClasscan throw, so you might prefer to testtaggedObject.HasContextTag()instead.I would suggest though that you provide a little detail about the call, in particular what your code is expecting to find (i.e. is there a cast or GetInstance call for the return value?) and/or the ASN.1 datatype of which this tagged object is a member (e.g. is it a named type from some RFC?). Direct usage of GetObject() has historically been very error prone in user code.
Dear @peterdettman,
thanks for your reply. I use the cast (Asn1Sequence and Asn1OctectString for different scopes) into my source code.