removed unused vars from System.DirectoryServices (#34161)
authorStefan Nikolei <stefan@nikolei.eu>
Tue, 5 May 2020 13:51:22 +0000 (15:51 +0200)
committerGitHub <noreply@github.com>
Tue, 5 May 2020 13:51:22 +0000 (09:51 -0400)
* removed unused vars from System.DirectoryServices

removed unused vars. added _ to unused return values

* use discard in GlobalCatalog instead of deleting

* removed unused var in ConfigSet

src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaClass.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySchemaProperty.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ActiveDirectorySite.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ConfigSet.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/DirectoryServer.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/GlobalCatalog.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Utils.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/PropertyCollection.cs

index 71b87ab..8b4b2d4 100644 (file)
@@ -998,8 +998,6 @@ namespace System.DirectoryServices.ActiveDirectory
             {
                 CheckIfDisposed();
 
-                Guid schemaGuid = Guid.Empty;
-
                 if (isBound)
                 {
                     if (_schemaGuidBinaryForm == null)
index 62ac720..f13544e 100644 (file)
@@ -1086,8 +1086,6 @@ namespace System.DirectoryServices.ActiveDirectory
             {
                 CheckIfDisposed();
 
-                Guid schemaGuid = Guid.Empty;
-
                 if (isBound)
                 {
                     if (_schemaGuidBinaryForm == null)
index b4f5125..a5290e5 100644 (file)
@@ -419,7 +419,7 @@ namespace System.DirectoryServices.ActiveDirectory
                 if (existing)
                 {
                     // for existing site, nTDSSiteSettings needs to exist
-                    DirectoryEntry tmp = NTDSSiteEntry;
+                    _ = NTDSSiteEntry;
                 }
 
                 _topologyTouched = true;
@@ -1329,7 +1329,6 @@ namespace System.DirectoryServices.ActiveDirectory
                     if (count > 0)
                     {
                         Debug.Assert(val != (IntPtr)0);
-                        int status = Marshal.ReadInt32(val);
                         IntPtr tmpPtr = (IntPtr)0;
                         for (int i = 0; i < count; i++)
                         {
index 675a72e..6fc8639 100644 (file)
@@ -436,7 +436,6 @@ namespace System.DirectoryServices.ActiveDirectory
 
             try
             {
-                string entryName = (string)rootEntry.Properties["distinguishedName"].Value;
                 // Search for computer "serviceConnectionObjects" where the keywords attribute
                 // contains the specified keyword
                 // set up the searcher object
index 2d9f940..5f191c7 100644 (file)
@@ -109,7 +109,7 @@ namespace System.DirectoryServices.ActiveDirectory
                     DirectoryEntry serverEntry = directoryEntryMgr.GetCachedDirectoryEntry(serverName);
 
                     // force binding (needed otherwise S.DS throw an exception while releasing the COM interface pointer)
-                    string dn = (string)PropertyManager.GetPropertyValue(context, serverEntry, PropertyManager.DistinguishedName);
+                    _ = (string)PropertyManager.GetPropertyValue(context, serverEntry, PropertyManager.DistinguishedName);
 
                     // move the object to the servers container of the target site
                     serverEntry.MoveTo(newParentEntry);
index e472e98..cab5dfb 100644 (file)
@@ -263,7 +263,7 @@ namespace System.DirectoryServices.ActiveDirectory
                 {
                     throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                 }
-                DirectoryContext schemaContext = Utils.GetNewDirectoryContext(Name, DirectoryContextType.DirectoryServer, context);
+                _ = Utils.GetNewDirectoryContext(Name, DirectoryContextType.DirectoryServer, context);
                 _schema = new ActiveDirectorySchema(context, schemaNC);
             }
 
index f7f6dd5..805418b 100644 (file)
@@ -689,7 +689,7 @@ namespace System.DirectoryServices.ActiveDirectory
                     throw ExceptionHelper.GetExceptionFromErrorCode(Marshal.GetLastWin32Error());
                 }
                 NativeMethods.DsUnBind dsUnBind = (NativeMethods.DsUnBind)Marshal.GetDelegateForFunctionPointer(functionPtr, typeof(NativeMethods.DsUnBind));
-                int result = dsUnBind(ref dsHandle);
+                _ = dsUnBind(ref dsHandle);
             }
         }
 
@@ -782,7 +782,7 @@ namespace System.DirectoryServices.ActiveDirectory
                 throw ExceptionHelper.GetExceptionFromCOMException(context, e);
             }
 
-            string crossRefDN = (string)PropertyManager.GetSearchResultPropertyValue(res, PropertyManager.DistinguishedName);
+            _ = (string)PropertyManager.GetSearchResultPropertyValue(res, PropertyManager.DistinguishedName);
             return res.GetDirectoryEntry();
         }
 
@@ -1447,8 +1447,6 @@ namespace System.DirectoryServices.ActiveDirectory
                     }
                 }
 
-                string[] propertiesToLoad2 = new string[5];
-
                 ADSearcher searcher2 = new ADSearcher(searchRootEntry, filter2, Array.Empty<string>(), SearchScope.Subtree);
                 SearchResultCollection resCol = null;
                 bool needToContinueRangeRetrieval = false;
index 5855d93..c9f9e28 100644 (file)
@@ -110,7 +110,7 @@ namespace System.DirectoryServices
             DirectoryEntry entryToUse = _entry.CloneBrowsable();
             entryToUse.FillCache("");
 
-            UnsafeNativeMethods.IAdsPropertyList propList = (UnsafeNativeMethods.IAdsPropertyList)entryToUse.AdsObject;
+            _ = (UnsafeNativeMethods.IAdsPropertyList)entryToUse.AdsObject;
 
             entryToUse.propertiesAlreadyEnumerated = true;
             return new PropertyEnumerator(_entry, entryToUse);