From a5ee312d22b65c8902f91e6700e3ab0120a7e5d7 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Tue, 26 Mar 2024 20:49:11 +0700 Subject: Refactoring in Asn1 --- crypto/src/asn1/Asn1RelativeOid.cs | 5 ++--- crypto/src/asn1/DerObjectIdentifier.cs | 2 +- crypto/src/asn1/util/Asn1Dump.cs | 6 +++--- crypto/test/src/asn1/test/RelativeOidTest.cs | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crypto/src/asn1/Asn1RelativeOid.cs b/crypto/src/asn1/Asn1RelativeOid.cs index f1b9bc274..587d41d2c 100644 --- a/crypto/src/asn1/Asn1RelativeOid.cs +++ b/crypto/src/asn1/Asn1RelativeOid.cs @@ -134,8 +134,7 @@ namespace Org.BouncyCastle.Asn1 return Objects.EnsureSingletonInitialized(ref m_identifier, m_contents, ParseContents); } - // TODO[api] - //[Obsolete("Use 'GetID' instead")] + [Obsolete("Use 'GetID' instead")] public string Id => GetID(); public override string ToString() => GetID(); @@ -180,7 +179,7 @@ namespace Org.BouncyCastle.Asn1 internal static void CheckIdentifier(string identifier) { if (identifier == null) - throw new ArgumentNullException("identifier"); + throw new ArgumentNullException(nameof(identifier)); if (identifier.Length > MaxIdentifierLength) throw new ArgumentException("exceeded relative OID contents length limit"); if (!IsValidIdentifier(identifier, from: 0)) diff --git a/crypto/src/asn1/DerObjectIdentifier.cs b/crypto/src/asn1/DerObjectIdentifier.cs index 4a68d541c..7e1d5c2ff 100644 --- a/crypto/src/asn1/DerObjectIdentifier.cs +++ b/crypto/src/asn1/DerObjectIdentifier.cs @@ -211,7 +211,7 @@ namespace Org.BouncyCastle.Asn1 internal static void CheckIdentifier(string identifier) { if (identifier == null) - throw new ArgumentNullException("identifier"); + throw new ArgumentNullException(nameof(identifier)); if (identifier.Length > MaxIdentifierLength) throw new ArgumentException("exceeded OID contents length limit"); if (!IsValidIdentifier(identifier)) diff --git a/crypto/src/asn1/util/Asn1Dump.cs b/crypto/src/asn1/util/Asn1Dump.cs index 67fbba979..d4576000a 100644 --- a/crypto/src/asn1/util/Asn1Dump.cs +++ b/crypto/src/asn1/util/Asn1Dump.cs @@ -104,12 +104,12 @@ namespace Org.BouncyCastle.Asn1.Utilities else if (obj is DerObjectIdentifier oid) { buf.Append(indent); - buf.AppendLine("ObjectIdentifier(" + oid.Id + ")"); + buf.AppendLine("ObjectIdentifier(" + oid.GetID() + ")"); } else if (obj is Asn1RelativeOid relativeOid) { buf.Append(indent); - buf.AppendLine("RelativeOID(" + relativeOid.Id + ")"); + buf.AppendLine("RelativeOID(" + relativeOid.GetID() + ")"); } else if (obj is DerBoolean derBoolean) { @@ -230,7 +230,7 @@ namespace Org.BouncyCastle.Asn1.Utilities if (ext.DirectReference != null) { buf.Append(tab); - buf.AppendLine("Direct Reference: " + ext.DirectReference.Id); + buf.AppendLine("Direct Reference: " + ext.DirectReference.GetID()); } if (ext.IndirectReference != null) { diff --git a/crypto/test/src/asn1/test/RelativeOidTest.cs b/crypto/test/src/asn1/test/RelativeOidTest.cs index c7d13af68..bbf83064a 100644 --- a/crypto/test/src/asn1/test/RelativeOidTest.cs +++ b/crypto/test/src/asn1/test/RelativeOidTest.cs @@ -45,7 +45,7 @@ namespace Org.BouncyCastle.Asn1.Tests Asn1RelativeOid o = new Asn1RelativeOid(oid); o = (Asn1RelativeOid)Asn1Object.FromByteArray(o.GetEncoded()); - if (!o.Id.Equals(oid)) + if (!o.GetID().Equals(oid)) { Fail("failed relative oid check for " + oid); } @@ -69,7 +69,7 @@ namespace Org.BouncyCastle.Asn1.Tests private void BranchCheck(string stem, string branch) { string expected = stem + "." + branch; - string actual = new Asn1RelativeOid(stem).Branch(branch).Id; + string actual = new Asn1RelativeOid(stem).Branch(branch).GetID(); if (expected != actual) { -- cgit 1.4.1