From a395a34a769d3c7e6616129f4832b7014dbbfe98 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 29 Jun 2022 14:47:32 +0700 Subject: Cleanup NewLine handling --- crypto/src/asn1/x509/AuthorityInformationAccess.cs | 13 +++------ crypto/src/asn1/x509/CRLDistPoint.cs | 14 ++++------ crypto/src/asn1/x509/DistributionPoint.cs | 25 ++++++----------- crypto/src/asn1/x509/DistributionPointName.cs | 27 ++++++------------ crypto/src/asn1/x509/GeneralNames.cs | 13 +++------ crypto/src/asn1/x509/IssuingDistributionPoint.cs | 32 ++++++++-------------- 6 files changed, 41 insertions(+), 83 deletions(-) (limited to 'crypto/src/asn1/x509') diff --git a/crypto/src/asn1/x509/AuthorityInformationAccess.cs b/crypto/src/asn1/x509/AuthorityInformationAccess.cs index 57868baea..382513674 100644 --- a/crypto/src/asn1/x509/AuthorityInformationAccess.cs +++ b/crypto/src/asn1/x509/AuthorityInformationAccess.cs @@ -94,18 +94,13 @@ namespace Org.BouncyCastle.Asn1.X509 //return "AuthorityInformationAccess: Oid(" + this.descriptions[0].AccessMethod.Id + ")"; StringBuilder buf = new StringBuilder(); - string sep = Platform.NewLine; - - buf.Append("AuthorityInformationAccess:"); - buf.Append(sep); - + buf.AppendLine("AuthorityInformationAccess:"); foreach (AccessDescription description in descriptions) { - buf.Append(" "); - buf.Append(description); - buf.Append(sep); + buf.Append(" ") + .Append(description) + .AppendLine(); } - return buf.ToString(); } } diff --git a/crypto/src/asn1/x509/CRLDistPoint.cs b/crypto/src/asn1/x509/CRLDistPoint.cs index 446bb19db..518bf3f00 100644 --- a/crypto/src/asn1/x509/CRLDistPoint.cs +++ b/crypto/src/asn1/x509/CRLDistPoint.cs @@ -72,16 +72,12 @@ namespace Org.BouncyCastle.Asn1.X509 public override string ToString() { StringBuilder buf = new StringBuilder(); - string sep = Platform.NewLine; - - buf.Append("CRLDistPoint:"); - buf.Append(sep); - DistributionPoint[] dp = GetDistributionPoints(); - for (int i = 0; i != dp.Length; i++) + buf.AppendLine("CRLDistPoint:"); + foreach (DistributionPoint dp in GetDistributionPoints()) { - buf.Append(" "); - buf.Append(dp[i]); - buf.Append(sep); + buf.Append(" ") + .Append(dp) + .AppendLine(); } return buf.ToString(); } diff --git a/crypto/src/asn1/x509/DistributionPoint.cs b/crypto/src/asn1/x509/DistributionPoint.cs index 54ab930a5..f35586016 100644 --- a/crypto/src/asn1/x509/DistributionPoint.cs +++ b/crypto/src/asn1/x509/DistributionPoint.cs @@ -106,43 +106,34 @@ namespace Org.BouncyCastle.Asn1.X509 public override string ToString() { - string sep = Platform.NewLine; StringBuilder buf = new StringBuilder(); - buf.Append("DistributionPoint: ["); - buf.Append(sep); + buf.AppendLine("DistributionPoint: ["); if (distributionPoint != null) { - appendObject(buf, sep, "distributionPoint", distributionPoint.ToString()); + AppendObject(buf, "distributionPoint", distributionPoint.ToString()); } if (reasons != null) { - appendObject(buf, sep, "reasons", reasons.ToString()); + AppendObject(buf, "reasons", reasons.ToString()); } if (cRLIssuer != null) { - appendObject(buf, sep, "cRLIssuer", cRLIssuer.ToString()); + AppendObject(buf, "cRLIssuer", cRLIssuer.ToString()); } - buf.Append("]"); - buf.Append(sep); + buf.AppendLine("]"); return buf.ToString(); } - private void appendObject( - StringBuilder buf, - string sep, - string name, - string val) + private void AppendObject(StringBuilder buf, string name, string val) { string indent = " "; - buf.Append(indent); buf.Append(name); - buf.Append(":"); - buf.Append(sep); + buf.AppendLine(":"); buf.Append(indent); buf.Append(indent); buf.Append(val); - buf.Append(sep); + buf.AppendLine(); } } } diff --git a/crypto/src/asn1/x509/DistributionPointName.cs b/crypto/src/asn1/x509/DistributionPointName.cs index 43fdaf533..bca54fa06 100644 --- a/crypto/src/asn1/x509/DistributionPointName.cs +++ b/crypto/src/asn1/x509/DistributionPointName.cs @@ -92,39 +92,30 @@ namespace Org.BouncyCastle.Asn1.X509 public override string ToString() { - string sep = Platform.NewLine; StringBuilder buf = new StringBuilder(); - buf.Append("DistributionPointName: ["); - buf.Append(sep); + buf.AppendLine("DistributionPointName: ["); if (type == FullName) { - appendObject(buf, sep, "fullName", name.ToString()); + AppendObject(buf, "fullName", name.ToString()); } else { - appendObject(buf, sep, "nameRelativeToCRLIssuer", name.ToString()); + AppendObject(buf, "nameRelativeToCRLIssuer", name.ToString()); } - buf.Append("]"); - buf.Append(sep); + buf.AppendLine("]"); return buf.ToString(); } - private void appendObject( - StringBuilder buf, - string sep, - string name, - string val) + private void AppendObject(StringBuilder buf, string name, string val) { string indent = " "; - buf.Append(indent); buf.Append(name); - buf.Append(":"); - buf.Append(sep); + buf.AppendLine(":"); buf.Append(indent); buf.Append(indent); buf.Append(val); - buf.Append(sep); - } - } + buf.AppendLine(); + } + } } diff --git a/crypto/src/asn1/x509/GeneralNames.cs b/crypto/src/asn1/x509/GeneralNames.cs index c105f3b6e..acf263f84 100644 --- a/crypto/src/asn1/x509/GeneralNames.cs +++ b/crypto/src/asn1/x509/GeneralNames.cs @@ -78,18 +78,13 @@ namespace Org.BouncyCastle.Asn1.X509 public override string ToString() { StringBuilder buf = new StringBuilder(); - string sep = Platform.NewLine; - - buf.Append("GeneralNames:"); - buf.Append(sep); - + buf.AppendLine("GeneralNames:"); foreach (GeneralName name in names) { - buf.Append(" "); - buf.Append(name); - buf.Append(sep); + buf.Append(" ") + .Append(name) + .AppendLine(); } - return buf.ToString(); } } diff --git a/crypto/src/asn1/x509/IssuingDistributionPoint.cs b/crypto/src/asn1/x509/IssuingDistributionPoint.cs index 8e9362b90..a05efffa4 100644 --- a/crypto/src/asn1/x509/IssuingDistributionPoint.cs +++ b/crypto/src/asn1/x509/IssuingDistributionPoint.cs @@ -192,56 +192,46 @@ namespace Org.BouncyCastle.Asn1.X509 public override string ToString() { - string sep = Platform.NewLine; StringBuilder buf = new StringBuilder(); - - buf.Append("IssuingDistributionPoint: ["); - buf.Append(sep); + buf.AppendLine("IssuingDistributionPoint: ["); if (_distributionPoint != null) { - appendObject(buf, sep, "distributionPoint", _distributionPoint.ToString()); + AppendObject(buf, "distributionPoint", _distributionPoint.ToString()); } if (_onlyContainsUserCerts) { - appendObject(buf, sep, "onlyContainsUserCerts", _onlyContainsUserCerts.ToString()); + AppendObject(buf, "onlyContainsUserCerts", _onlyContainsUserCerts.ToString()); } if (_onlyContainsCACerts) { - appendObject(buf, sep, "onlyContainsCACerts", _onlyContainsCACerts.ToString()); + AppendObject(buf, "onlyContainsCACerts", _onlyContainsCACerts.ToString()); } if (_onlySomeReasons != null) { - appendObject(buf, sep, "onlySomeReasons", _onlySomeReasons.ToString()); + AppendObject(buf, "onlySomeReasons", _onlySomeReasons.ToString()); } if (_onlyContainsAttributeCerts) { - appendObject(buf, sep, "onlyContainsAttributeCerts", _onlyContainsAttributeCerts.ToString()); + AppendObject(buf, "onlyContainsAttributeCerts", _onlyContainsAttributeCerts.ToString()); } if (_indirectCRL) { - appendObject(buf, sep, "indirectCRL", _indirectCRL.ToString()); + AppendObject(buf, "indirectCRL", _indirectCRL.ToString()); } - buf.Append("]"); - buf.Append(sep); + buf.AppendLine("]"); return buf.ToString(); } - private void appendObject( - StringBuilder buf, - string sep, - string name, - string val) + private void AppendObject(StringBuilder buf, string name, string val) { string indent = " "; - buf.Append(indent); buf.Append(name); - buf.Append(":"); - buf.Append(sep); + buf.AppendLine(":"); buf.Append(indent); buf.Append(indent); buf.Append(val); - buf.Append(sep); + buf.AppendLine(); } } } -- cgit 1.4.1