From 68020854cafc0169a4ae1fccb313d1d68c7cb1a7 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 23 Sep 2019 22:22:44 -0700 Subject: [PATCH] Remove some unnecessary string concatenation from CertificatePal.AppendPrivateKeyInfo (dotnet/corefx#41274) Commit migrated from https://github.com/dotnet/corefx/commit/f2292af3a1794378339d6f5c8adcc0f2019a2cf9 --- .../Pal.Windows/CertificatePal.cs | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs index c707190692655..87803da1af051 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs @@ -423,48 +423,38 @@ public void AppendPrivateKeyInfo(StringBuilder sb) if (cspKeyContainerInfo == null) return; - sb.Append(Environment.NewLine + " Key Store: "); - sb.Append(cspKeyContainerInfo.MachineKeyStore ? "Machine" : "User"); - sb.Append(Environment.NewLine + " Provider Name: "); - sb.Append(cspKeyContainerInfo.ProviderName); - sb.Append(Environment.NewLine + " Provider type: "); - sb.Append(cspKeyContainerInfo.ProviderType); - sb.Append(Environment.NewLine + " Key Spec: "); - sb.Append(cspKeyContainerInfo.KeyNumber); - sb.Append(Environment.NewLine + " Key Container Name: "); - sb.Append(cspKeyContainerInfo.KeyContainerName); + sb.AppendLine().Append(" Key Store: ").Append(cspKeyContainerInfo.MachineKeyStore ? "Machine" : "User"); + sb.AppendLine().Append(" Provider Name: ").Append(cspKeyContainerInfo.ProviderName); + sb.AppendLine().Append(" Provider type: ").Append(cspKeyContainerInfo.ProviderType); + sb.AppendLine().Append(" Key Spec: ").Append(cspKeyContainerInfo.KeyNumber); + sb.AppendLine().Append(" Key Container Name: ").Append(cspKeyContainerInfo.KeyContainerName); try { string uniqueKeyContainer = cspKeyContainerInfo.UniqueKeyContainerName; - sb.Append(Environment.NewLine + " Unique Key Container Name: "); - sb.Append(uniqueKeyContainer); + sb.AppendLine().Append(" Unique Key Container Name: ").Append(uniqueKeyContainer); } catch (CryptographicException) { } catch (NotSupportedException) { } - bool b = false; try { - b = cspKeyContainerInfo.HardwareDevice; - sb.Append(Environment.NewLine + " Hardware Device: "); - sb.Append(b); + bool b = cspKeyContainerInfo.HardwareDevice; + sb.AppendLine().Append(" Hardware Device: ").Append(b); } catch (CryptographicException) { } try { - b = cspKeyContainerInfo.Removable; - sb.Append(Environment.NewLine + " Removable: "); - sb.Append(b); + bool b = cspKeyContainerInfo.Removable; + sb.AppendLine().Append(" Removable: ").Append(b); } catch (CryptographicException) { } try { - b = cspKeyContainerInfo.Protected; - sb.Append(Environment.NewLine + " Protected: "); - sb.Append(b); + bool b = cspKeyContainerInfo.Protected; + sb.AppendLine().Append(" Protected: ").Append(b); } catch (CryptographicException) { } catch (NotSupportedException) { }