From dee70aa8ddafa0d03f9d7502b9815c9ed0173f52 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sat, 28 Mar 2020 14:06:21 -0400 Subject: [PATCH] Remove a couple unnecessary ToStrings in System.DirectoryServices These are calling ToString on a StringBuilder, but StringBuilder.Append has a StringBuilder-based overload in netcoreapp. On other builds this will just fall back to the object-based overload, which will call ToString. --- .../AccountManagement/AD/ADStoreCtx_LoadStore.cs | 2 +- .../System.DirectoryServices/src/Interop/AdsValueHelper2.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs index c0e4c99e7fa7d..f27aad7412f00 100644 --- a/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs +++ b/src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx_LoadStore.cs @@ -630,7 +630,7 @@ private Principal FindPrincipalByIdentRefHelper( innerLdapFilter.Append(')'); - ldapFilter.Append(innerLdapFilter.ToString()); + ldapFilter.Append(innerLdapFilter); } // Wrap off the filter diff --git a/src/libraries/System.DirectoryServices/src/Interop/AdsValueHelper2.cs b/src/libraries/System.DirectoryServices/src/Interop/AdsValueHelper2.cs index 9bf258bf70e27..1579abce666c5 100644 --- a/src/libraries/System.DirectoryServices/src/Interop/AdsValueHelper2.cs +++ b/src/libraries/System.DirectoryServices/src/Interop/AdsValueHelper2.cs @@ -153,7 +153,7 @@ public object GetValue() strb.Append("B:"); strb.Append(binaryPart.Length); strb.Append(':'); - strb.Append(binaryPart.ToString()); + strb.Append(binaryPart); strb.Append(':'); strb.Append(Marshal.PtrToStringUni(dnb.pszDNString));