Remove some unused locals (dotnet/corefx#39956)
authorStephen Toub <stoub@microsoft.com>
Mon, 5 Aug 2019 15:05:14 +0000 (11:05 -0400)
committerGitHub <noreply@github.com>
Mon, 5 Aug 2019 15:05:14 +0000 (11:05 -0400)
* Remove some unused locals

Trying out various analyzers, including one to flag unused locals.  There are more than this, but this is a first batch.  Some of these are just clean-up.  Others are saving unnecessary cost.  At least one appears to be a real functional bug.

* Address PR feedback

Commit migrated from https://github.com/dotnet/corefx/commit/545d9959aebded62a26d20c7c1bf86785a92e52a

69 files changed:
src/libraries/Common/src/System/Data/ProviderBase/DbConnectionInternal.cs
src/libraries/Common/src/System/Net/CaseInsensitiveAscii.cs
src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs
src/libraries/Common/src/System/Reflection/Emit/IgnoreAccessChecksToAttributeBuilder.cs
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs
src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs
src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs
src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/RegistrationBuilder.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/GenericServices.cs
src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs
src/libraries/System.Composition.Convention/src/System/Composition/Convention/ConventionBuilder.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigurationHost.cs
src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs
src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs
src/libraries/System.Data.Common/src/System/Data/DataRelation.cs
src/libraries/System.Data.Common/src/System/Data/DataSet.cs
src/libraries/System.Data.Common/src/System/Data/DataTable.cs
src/libraries/System.Data.Common/src/System/Data/DataView.cs
src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs
src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs
src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs
src/libraries/System.Data.Common/src/System/Data/Select.cs
src/libraries/System.Data.Common/src/System/Data/Selection.cs
src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs
src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs
src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs
src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs
src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs
src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs
src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcHandle.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/LocalDBAPI.Common.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnection.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependency.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs
src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogInternal.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs
src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceData/CounterSetInstance.cs
src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs
src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseParser.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBase.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs
src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatWriter.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionXmlFormatWriter.cs
src/libraries/System.Reflection.Context/src/System/Reflection/Context/Custom/CustomType.cs
src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/DebugDirectory/DebugDirectoryBuilder.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/RoPseudoCustomAttributeData.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/Ecma/EcmaGenericTypeParameterType.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs
src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs
src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AesCcm.Unix.cs
src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoRetrievalMethod.cs
src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs
src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs
src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs
src/libraries/System.Threading.Channels/src/System/Threading/Channels/BoundedChannel.cs
src/libraries/System.Threading/src/System/Threading/Barrier.cs

index 45fed43..80014f9 100644 (file)
@@ -223,7 +223,7 @@ namespace System.Data.ProviderBase
             // the Deactivate method publicly.
 
 #if DEBUG
-            int activateCount = Interlocked.Decrement(ref _activateCount);
+            Interlocked.Decrement(ref _activateCount);
 #endif // DEBUG
 
 
index 80cc924..d09f0d4 100644 (file)
@@ -112,7 +112,6 @@ namespace System.Net
                 {
                     if (FastGetHashCode(firstString) == FastGetHashCode(secondString))
                     {
-                        int comparisons = firstString.Length;
                         while (index > 0)
                         {
                             index--;
index 24911ad..344e775 100644 (file)
@@ -522,7 +522,7 @@ namespace System.Net.WebSockets
                 else
                 {
                     // "Observe" any exception, ignoring it to prevent the unobserved exception event from being raised.
-                    t.AsTask().ContinueWith(p => { Exception ignored = p.Exception; },
+                    t.AsTask().ContinueWith(p => { _ = p.Exception; },
                         CancellationToken.None,
                         TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
                         TaskScheduler.Default);
index e64e96e..239da51 100644 (file)
@@ -48,12 +48,12 @@ namespace System.Reflection.Emit
 
             // Define property as:
             // public string AssemblyName {get { return this.assemblyName; } }
-            PropertyBuilder getterPropertyBuilder = attributeTypeBuilder.DefineProperty(
-                                                   "AssemblyName",
-                                                   PropertyAttributes.None,
-                                                   CallingConventions.HasThis,
-                                                   returnType: typeof(string),
-                                                   parameterTypes: null);
+            _ = attributeTypeBuilder.DefineProperty(
+                    "AssemblyName",
+                    PropertyAttributes.None,
+                    CallingConventions.HasThis,
+                    returnType: typeof(string),
+                    parameterTypes: null);
 
             MethodBuilder getterMethodBuilder = attributeTypeBuilder.DefineMethod(
                                                    "get_AssemblyName",
index 4565b8f..a7960b7 100644 (file)
@@ -1104,7 +1104,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics
             int paramCount = mp.Params.Count;
             TypeArray @params = mp.Params;
             int iDst = 0;
-            MethodSymbol m = mp as MethodSymbol;
             int argCount = ExpressionIterator.Count(argsPtr);
 
             Debug.Assert(!@params.Items.Any(p => p is ArgumentListType)); // We should never have picked a varargs method to bind to.
index f611c38..706ce5a 100644 (file)
@@ -423,7 +423,7 @@ namespace System.Collections.Immutable
             // if we are going to do anything with the array, we will need Length anyways
             // so touching it, and potentially causing a cache miss, is not going to be an
             // extra expense.
-            var unused = this.array.Length;
+            _ = this.array.Length;
         }
 
         /// <summary>
index 80b89a0..030c697 100644 (file)
@@ -1034,7 +1034,6 @@ namespace System.Collections.Generic
                 Enumerator theirs = asSorted.GetEnumerator();
                 bool mineEnded = !mine.MoveNext(), theirsEnded = !theirs.MoveNext();
                 T max = Max;
-                T min = Min;
 
                 while (!mineEnded && !theirsEnded && Comparer.Compare(theirs.Current, max) <= 0)
                 {
index 9fc6308..47f2526 100644 (file)
@@ -93,7 +93,6 @@ namespace System.ComponentModel.Composition.Registration
 
         private IEnumerable<Tuple<object, List<Attribute>>> EvaluateThisTypeAgainstTheConvention(Type type)
         {
-            List<Tuple<object, List<Attribute>>> results = new List<Tuple<object, List<Attribute>>>();
             List<Attribute> attributes = new List<Attribute>();
 
             var configuredMembers = new List<Tuple<object, List<Attribute>>>();
index 875da0d..9820f56 100644 (file)
@@ -46,7 +46,6 @@ namespace System.ComponentModel.Composition.ReflectionModel
             int genericArity = 0;
             if (type.IsGenericType && type.ContainsGenericParameters)
             {
-                List<Type> pureGenericParameters = new List<Type>();
                 TraverseGenericType(type, (Type t) =>
                 {
                     if (t.IsGenericParameter)
index f8ffcae..057c8ea 100644 (file)
@@ -286,7 +286,6 @@ namespace System.ComponentModel
                 throw new ArgumentNullException(nameof(instance));
             }
 
-            Type type = instance.GetType();
             AddProvider(provider, instance);
         }
 
@@ -2527,8 +2526,6 @@ namespace System.ComponentModel
                 throw new ArgumentNullException(nameof(instance));
             }
 
-            Type type = instance.GetType();
-
             RemoveProvider(provider, instance);
         }
 
index 6f19e9d..41ef55f 100644 (file)
@@ -126,7 +126,6 @@ namespace System.Composition.Convention
 
         private IEnumerable<Tuple<object, List<Attribute>>> EvaluateThisTypeInfoAgainstTheConvention(TypeInfo typeInfo)
         {
-            List<Tuple<object, List<Attribute>>> results = new List<Tuple<object, List<Attribute>>>();
             List<Attribute> attributes = new List<Attribute>();
             var configuredMembers = new List<Tuple<object, List<Attribute>>>();
             bool specifiedConstructor = false;
index 6bc3693..33f5b44 100644 (file)
@@ -209,7 +209,7 @@ namespace System.Configuration
                     _configPaths = null;
 
                     // Force loading of user.config file information under lock.
-                    ClientConfigPaths configPaths = ConfigPaths;
+                    _ = ConfigPaths;
                 }
             }
         }
index 6a1b68a..30ef519 100644 (file)
@@ -223,11 +223,11 @@ namespace System.Configuration
             foreach (ConfigurationSection configSection in group.Sections)
             {
                 // Force the section to be read into the cache
-                ConfigurationSection section = group.Sections[configSection.SectionInformation.Name];
+                _ = group.Sections[configSection.SectionInformation.Name];
             }
 
             foreach (ConfigurationSectionGroup sectionGroup in group.SectionGroups)
                 ForceGroupsRecursive(group.SectionGroups[sectionGroup.Name]);
         }
     }
-}
\ No newline at end of file
+}
index aa315f4..00adf02 100644 (file)
@@ -925,7 +925,6 @@ namespace System.Data.Common
 
                 int rowsAffected = 0;
 
-                System.Data.MissingMappingAction missingMapping = UpdateMappingAction;
                 DataTableMapping tableMapping = GetTableMappingBySchemaAction(srcTable, srcTable, UpdateMappingAction);
                 Debug.Assert(null != tableMapping, "null TableMapping when MissingMappingAction.Error");
 
index 873c2c0..5ee84f3 100644 (file)
@@ -417,10 +417,6 @@ namespace System.Data
             //  This is not valid for Whidbey anymore so the code has been removed
 
             // 2. There is no loop in nested relations
-#if DEBUG
-            int numTables = ParentTable.DataSet.Tables.Count;
-#endif
-            DataTable dt = ParentTable;
 
             if (ChildTable == ParentTable)
             {
index 81f36b3..8bbd6b8 100644 (file)
@@ -859,7 +859,7 @@ namespace System.Data
                 {
                     if (!table.ShouldSerializeLocale())
                     {
-                        bool retchk = table.SetLocaleValue(value, false, false);
+                        table.SetLocaleValue(value, false, false);
                     }
                 }
 
@@ -2287,7 +2287,6 @@ namespace System.Data
             long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataSet.InferSchema|INFO> {0}, mode={1}", ObjectID, mode);
             try
             {
-                string ns = xdoc.DocumentElement.NamespaceURI;
                 if (null == excludedNamespaces)
                 {
                     excludedNamespaces = Array.Empty<string>();
index 5fdd3a3..6540ec6 100644 (file)
@@ -1969,8 +1969,6 @@ namespace System.Data
             {
                 if ((rel.Nested) && (rel.ChildTable != this))
                 {
-                    DataTable childTable = rel.ChildTable;
-
                     rel.ChildTable.DoRaiseNamespaceChange();
                 }
             }
@@ -2361,7 +2359,7 @@ namespace System.Data
             // start cloning relation
             foreach (DataRelation r in sourceTable.ChildRelations)
             {
-                DataTable childTable = CloneHierarchy(r.ChildTable, ds, visitedMap);
+                CloneHierarchy(r.ChildTable, ds, visitedMap);
             }
 
             return destinationTable;
@@ -6219,7 +6217,7 @@ namespace System.Data
         internal void ReadXDRSchema(XmlReader reader)
         {
             XmlDocument xdoc = new XmlDocument(); // we may need this to infer the schema
-            XmlNode schNode = xdoc.ReadNode(reader); ;
+            xdoc.ReadNode(reader);
             //consume and ignore it - No support
         }
 
@@ -6511,7 +6509,7 @@ namespace System.Data
                         dataset.Tables.Add(this);
                     }
 
-                    DataTable targetTable = CloneHierarchy(currentTable, DataSet, null);
+                    CloneHierarchy(currentTable, DataSet, null);
 
                     foreach (DataTable tempTable in tableList)
                     {
index 482e232..2211729 100644 (file)
@@ -1600,8 +1600,6 @@ namespace System.Data
                         return;
                     }
 
-                    DataTable table = _index != null ? _index.Table : newIndex.Table;
-
                     if (_index != null)
                     {
                         _dvListener.UnregisterListChangedEvent();
index d15a423..e2f3bb1 100644 (file)
@@ -941,7 +941,6 @@ namespace System.Data
                         /* Check for binary constant */
                         if (ch == '0' && (text[_pos] == 'x' || text[_pos] == 'X'))
                         {
-                            ScanBinaryConstant();
                             _token = Tokens.BinaryConst;
                             goto end_loop;
                         }
@@ -1103,11 +1102,6 @@ namespace System.Data
             _pos++;
         }
 
-        private void ScanBinaryConstant()
-        {
-            char[] text = _text;
-        }
-
         private void ScanReserved()
         {
             char[] text = _text;
index d757274..a17b956 100644 (file)
@@ -573,7 +573,6 @@ namespace System.Data
 
         internal void Check()
         {
-            Function f = s_funcs[_info];
             if (_info < 0)
                 throw ExprException.UndefinedFunction(_name);
 
index 2de681f..ba6fe84 100644 (file)
@@ -2350,7 +2350,6 @@ namespace System.Data.SqlTypes
 
             SqlDecimal ret = n;
 
-            int lPrecAdjust = precision - ret._bPrec;//Adjustment to precision
             int lScaleAdjust = scale - ret._bScale;//Adjustment to scale
 
             //Adjust scale
@@ -3230,7 +3229,6 @@ namespace System.Data.SqlTypes
             if (n.IsNull)
                 return SqlDecimal.Null;
 
-            byte prec = n.Precision;
             int scale = n.Scale;
             double dBaseNum = n.ToDouble();
 
index 127e285..0d57aa4 100644 (file)
@@ -202,7 +202,6 @@ namespace System.Data
             try
             {
                 int count = _table._indexes.Count;
-                int rowsCount = _table.Rows.Count;
                 for (int i = 0; i < count; i++)
                 {
                     Index ndx = _table._indexes[i];
@@ -257,7 +256,6 @@ namespace System.Data
             try
             {
                 int count = _table._indexes.Count;
-                int rowsCount = _table.Rows.Count;
                 for (int i = 0; i < count; i++)
                 {
                     Index ndx = _table._indexes[i];
@@ -343,7 +341,6 @@ namespace System.Data
                         }
                     }
                     int indexNotInCandidates = lenIndexDesc - j;
-                    int candidatesNotInIndex = _nCandidates - j;
                     IndexField[] ndxFields = new IndexField[_nCandidates + indexNotInCandidates];
 
                     if (equalsOperator)
index ed6607e..276c0ae 100644 (file)
@@ -124,7 +124,6 @@ namespace System.Data
             _recordStates = recordStates;
             _comparison = comparison;
 
-            DataColumnCollection columns = table.Columns;
             _isSharable = (rowFilter == null) && (comparison == null); // a filter or comparison make an index unsharable
             if (null != rowFilter)
             {
index b40ce0c..c3c9dd5 100644 (file)
@@ -350,10 +350,6 @@ namespace System.Data
             string strDefault;
             DataColumn column;
 
-            string strUse = node.GetAttribute(Keywords.USE);
-
-
-
             // Get the name
             if (node.Attributes.Count > 0)
             {
index 5f47086..7fb0b3e 100644 (file)
@@ -89,8 +89,6 @@ namespace System.Data
 
                 // the diffgramm always contains sql:before and sql:after pairs
 
-                int iTempDepth = ssync.Depth;
-
                 diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS);
                 bool hasErrors = ssync.GetAttribute(Keywords.HASERRORS, Keywords.DFFNS) == Keywords.TRUE;
                 oldRowRecord = ReadOldRowData(ds, ref tableBefore, ref pos, ssync);
@@ -142,8 +140,6 @@ namespace System.Data
 
                 // the diffgramm always contains sql:before and sql:after pairs
 
-                int iTempDepth = ssync.Depth;
-
                 diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS);
                 bool hasErrors = ssync.GetAttribute(Keywords.HASERRORS, Keywords.DFFNS) == Keywords.TRUE;
                 oldRowRecord = ReadOldRowData(_dataSet, ref tableBefore, ref pos, ssync);
index 7f2859b..7e5c296 100644 (file)
@@ -127,7 +127,6 @@ namespace System.Data
             int count = 0;
             for (int i = 0; i < node.Attributes.Count; i++)
             {
-                XmlAttribute attr = node.Attributes[i];
                 if (!FExcludedNamespace(node.Attributes[i].NamespaceURI))
                     count++;
             }
index fe7946d..64d45f4 100644 (file)
@@ -577,7 +577,6 @@ namespace System.Xml
             DataTable table = row.Table;
             DataColumnCollection columns = table.Columns;
             int iColumn = (col != null) ? col.Ordinal - 1 : columns.Count - 1;
-            int cColumns = columns.Count;
             DataRowVersion rowVersion = (row.RowState == DataRowState.Detached) ? DataRowVersion.Proposed : DataRowVersion.Current;
 
             for (; iColumn >= 0; iColumn--)
@@ -1071,7 +1070,7 @@ namespace System.Xml
             XPathNodePointer xp2 = other.Clone((DataDocumentXPathNavigator)(other._owner.Target));
             while (xp1.MoveToNextNamespace(XPathNamespaceScope.All))
             {
-                if (xp1.IsSamePosition(other))
+                if (xp1.IsSamePosition(xp2))
                     return XmlNodeOrder.Before;
             }
             return XmlNodeOrder.After;
@@ -1409,7 +1408,6 @@ namespace System.Xml
                 attrName = "xmlns";
             RealFoliate();
             XmlNode node = _node;
-            XmlNodeType nt = node.NodeType;
             XmlAttribute attr = null;
             XmlBoundElement be = null;
             while (node != null)
index e0d67ec..6096379 100644 (file)
@@ -397,7 +397,7 @@ namespace System.Xml
             // before iteration, so iteration will not cause foliation (and as a result of this, creation of new nodes).
             XmlNodeList tempNodeList = base.GetElementsByTagName(name);
 
-            int tempint = tempNodeList.Count;
+            _ = tempNodeList.Count;
             return tempNodeList;
         }
     }
index a6c3955..38798f1 100644 (file)
@@ -1237,7 +1237,7 @@ namespace System.Xml
                     foreach (DataRow r in t.Rows)
                     {
                         Debug.Assert(r.Element == null);
-                        XmlBoundElement rowElem = AttachBoundElementToDataRow(r);
+                        AttachBoundElementToDataRow(r);
 
                         switch (r.RowState)
                         {
@@ -1580,7 +1580,6 @@ namespace System.Xml
             {
                 DataRow row = args.Row;
                 DataColumn col = args.Column;
-                object oVal = args.ProposedValue;
 
                 if (row.RowState == DataRowState.Detached)
                 {
@@ -2444,7 +2443,6 @@ namespace System.Xml
 
             DataRow row = rowElement.Row;
             Debug.Assert(row != null);
-            DataTable table = row.Table;
 
             Hashtable foundColumns = new Hashtable();
             string xsi_attrVal = string.Empty;
@@ -3007,7 +3005,7 @@ namespace System.Xml
             // before iteration, so iteration will not cause foliation (and as a result of this, creation of new nodes).
             XmlNodeList tempNodeList = base.GetElementsByTagName(name);
 
-            int tempint = tempNodeList.Count;
+            _ = tempNodeList.Count;
             return tempNodeList;
         }
 
index d67bfc9..6166b0f 100644 (file)
@@ -1364,7 +1364,6 @@ namespace System.Data.Odbc
             Debug.Assert(buffer == null || bytesOrCharsLength <= (buffer.Length - bufferIndex), "Not enough space in user's buffer");
 
             int totalBytesOrCharsRead = 0;
-            string originalMethodName = isCharsBuffer ? "GetChars" : "GetBytes";
 
             // we need length in bytes, b/c that is what SQLGetData expects
             long cbLength = (isCharsBuffer) ? checked(bytesOrCharsLength * 2) : bytesOrCharsLength;
index 1ecd9b6..d690cc1 100644 (file)
@@ -151,7 +151,7 @@ namespace System.Data.Odbc
                     // Disconnect happens in OdbcConnectionHandle.ReleaseHandle
                     case ODBC32.SQL_HANDLE.ENV:
                     case ODBC32.SQL_HANDLE.STMT:
-                        ODBC32.RetCode retcode = Interop.Odbc.SQLFreeHandle(handleType, handle);
+                        Interop.Odbc.SQLFreeHandle(handleType, handle);
                         break;
 
                     case ODBC32.SQL_HANDLE.DESC:
index 0a84175..eb4f91a 100644 (file)
@@ -36,7 +36,6 @@ namespace System.Data
 
                             if (functionAddr == IntPtr.Zero)
                             {
-                                int hResult = Marshal.GetLastWin32Error();
                                 throw CreateLocalDBException(errorMessage: SR.LocalDB_MethodNotFound);
                             }
                             s_localDBFormatMessage = Marshal.GetDelegateForFunctionPointer<LocalDBFormatMessageDelegate>(functionAddr);
index 68d7112..1e99f79 100644 (file)
@@ -1026,7 +1026,6 @@ namespace System.Data.SqlClient
 
         private void WaitForAsyncResults(IAsyncResult asyncResult)
         {
-            Task completionTask = (Task)asyncResult;
             if (!asyncResult.IsCompleted)
             {
                 asyncResult.AsyncWaitHandle.WaitOne();
index a88c5ac..65ff452 100644 (file)
@@ -256,7 +256,6 @@ namespace System.Data.SqlClient
         {
             get
             {
-                string result = _accessToken;
                 // When a connection is connecting or is ever opened, make AccessToken available only if "Persist Security Info" is set to true
                 // otherwise, return null
                 SqlConnectionString connectionOptions = (SqlConnectionString)UserConnectionOptions;
@@ -1110,7 +1109,6 @@ namespace System.Data.SqlClient
 
                         if (retryTask.IsFaulted)
                         {
-                            Exception e = retryTask.Exception.InnerException;
                             _parent.CloseInnerConnection();
                             _parent._currentCompletion = null;
                             _result.SetException(retryTask.Exception.InnerException);
index a3095a4..c37dd3d 100644 (file)
@@ -843,8 +843,6 @@ namespace System.Data.SqlClient
         {
             if (cmd != null)
             {
-                SqlConnection connection = cmd.Connection;
-
                 if (cmd.Notification != null)
                 {
                     // Fail if cmd has notification that is not already associated with this dependency.
index 5640f45..c7731ac 100644 (file)
@@ -75,11 +75,6 @@ internal class SqlDependencyProcessDispatcher : MarshalByRefObject
                 // Always use ConnectionStringBuilder since in default case it is different from the 
                 // connection string used in the hashHelper.
                 _con = new SqlConnection(_hashHelper.ConnectionStringBuilder.ConnectionString); // Create connection and open.
-
-                // Assert permission for this particular connection string since it differs from the user passed string
-                // which we have already demanded upon.  
-                SqlConnectionString connStringObj = (SqlConnectionString)_con.ConnectionOptions;
-
                 _con.Open();
 
                 _cachedServer = _con.DataSource;
@@ -411,7 +406,7 @@ internal class SqlDependencyProcessDispatcher : MarshalByRefObject
         internal void IncrementStartCount(string appDomainKey, out bool appDomainStart)
         {
             appDomainStart = false; // Reset out param.
-            int result = Interlocked.Increment(ref _startCount); // Add to refCount.
+            Interlocked.Increment(ref _startCount); // Add to refCount.
 
             // Dictionary used to track how many times start has been called per app domain.
             // For each increment, add to count, and create entry if not present.
@@ -886,8 +881,6 @@ internal class SqlDependencyProcessDispatcher : MarshalByRefObject
         {
             using (XmlReader xmlReader = xmlMessage.CreateReader())
             {
-                string keyvalue = string.Empty;
-
                 MessageAttributes messageAttributes = MessageAttributes.None;
 
                 SqlNotificationType type = SqlNotificationType.Unknown;
index 08bff5a..a8451d5 100644 (file)
@@ -706,10 +706,6 @@ namespace System.Data.SqlClient
                         payloadLength = payload[offset++] << 8 | payload[offset++];
 
                         byte majorVersion = payload[payloadOffset];
-                        byte minorVersion = payload[payloadOffset + 1];
-                        int level = (payload[payloadOffset + 2] << 8) |
-                                             payload[payloadOffset + 3];
-
                         isYukonOrLater = majorVersion >= 9;
                         if (!isYukonOrLater)
                         {
index b599680..6ecfc10 100644 (file)
@@ -484,9 +484,7 @@ namespace System.Diagnostics
             /// </summary>
             public FilterAndTransform(string filterAndPayloadSpec, int startIdx, int endIdx, DiagnosticSourceEventSource eventSource, FilterAndTransform next)
             {
-#if DEBUG
-                string spec = filterAndPayloadSpec.Substring(startIdx, endIdx - startIdx);
-#endif 
+                Debug.Assert(filterAndPayloadSpec != null && startIdx >= 0 && startIdx <= endIdx && endIdx <= filterAndPayloadSpec.Length);
                 Next = next;
                 _eventSource = eventSource;
 
@@ -711,7 +709,6 @@ namespace System.Diagnostics
                 TypeInfo curTypeInfo = type.GetTypeInfo();
                 foreach (PropertyInfo property in curTypeInfo.DeclaredProperties)
                 {
-                    Type propertyType = property.PropertyType;
                     newSerializableArgs = new TransformSpec(property.Name, 0, property.Name.Length, newSerializableArgs);
                 }
                 return Reverse(newSerializableArgs);
@@ -762,10 +759,7 @@ namespace System.Diagnostics
             /// </summary>
             public TransformSpec(string transformSpec, int startIdx, int endIdx, TransformSpec next = null)
             {
-                Debug.Assert(transformSpec != null && startIdx < endIdx);
-#if DEBUG
-                string spec = transformSpec.Substring(startIdx, endIdx - startIdx);
-#endif
+                Debug.Assert(transformSpec != null && startIdx >= 0 && startIdx < endIdx && endIdx <= transformSpec.Length);
                 Next = next;
 
                 // Pick off the Var=
index f3f37de..7ed86cb 100644 (file)
@@ -134,8 +134,6 @@ namespace System.Diagnostics
         {
             get
             {
-                string currentMachineName = this.machineName;
-
                 if (entriesCollection == null)
                     entriesCollection = new EventLogEntryCollection(this);
                 return entriesCollection;
@@ -335,7 +333,6 @@ namespace System.Diagnostics
         {
             get
             {
-                string currentMachineName = this.machineName;
                 return boolFlags[Flag_monitoring];
             }
             set
@@ -386,7 +383,6 @@ namespace System.Diagnostics
         {
             get
             {
-                string currentMachineName = this.machineName;
                 if (this.synchronizingObject == null && parent.ComponentDesignMode)
                 {
                     IDesignerHost host = (IDesignerHost)parent.ComponentGetService(typeof(IDesignerHost));
@@ -411,7 +407,6 @@ namespace System.Diagnostics
         {
             get
             {
-                string currentMachineName = this.machineName;
                 return sourceName;
             }
         }
@@ -449,12 +444,10 @@ namespace System.Diagnostics
         {
             add
             {
-                string currentMachineName = this.machineName;
                 onEntryWrittenHandler += value;
             }
             remove
             {
-                string currentMachineName = this.machineName;
                 onEntryWrittenHandler -= value;
             }
         }
index fd2d23e..ab33bac 100644 (file)
@@ -718,7 +718,6 @@ namespace System.Diagnostics
                             object objectID = key.GetValue("First Counter");
                             if (objectID != null)
                             {
-                                int firstID = (int)objectID;
                                 lock (table)
                                 {
                                     table[category] = categoryType;
index de27f58..cf9aeac 100644 (file)
@@ -107,7 +107,7 @@ namespace System.Diagnostics.PerformanceData
                     {
                         if (_counterSet._provider != null)
                         {
-                            uint Status = Interop.PerfCounter.PerfDeleteInstance(_counterSet._provider._hProvider, _nativeInst);
+                            Interop.PerfCounter.PerfDeleteInstance(_counterSet._provider._hProvider, _nativeInst);
                         }
                         _nativeInst = null;
                     }
index 2c09a5f..3dd1c68 100644 (file)
@@ -187,8 +187,6 @@ namespace System.DirectoryServices.Protocols
                 }
                 else if (exception is LdapException ldapException)
                 {
-                    LdapError errorCode = (LdapError)ldapException.ErrorCode;
-
                     if (asyncResult._response != null)
                     {
                         // add previous retrieved entries if available
index 326ea36..3013b4e 100644 (file)
@@ -1284,7 +1284,6 @@ namespace System.DirectoryServices.ActiveDirectory
             int count = 0;
             ArrayList unmanagedTrustList = new ArrayList();
             ArrayList tmpTrustList = new ArrayList();
-            TrustRelationshipInformationCollection collection = new TrustRelationshipInformationCollection();
             int localDomainIndex = 0;
             string localDomainParent = null;
             int error = 0;
index 892fec1..58d84b6 100644 (file)
@@ -120,7 +120,6 @@ namespace System.IO.Compression
             try
             {
                 int totalWritten = 0;
-                Memory<byte> source = Memory<byte>.Empty;
                 OperationStatus lastResult = OperationStatus.DestinationTooSmall;
                 // We want to continue calling Decompress until we're either out of space for output or until Decompress indicates it is finished.
                 while (buffer.Length > 0 && lastResult != OperationStatus.Done)
index 7374402..d5efa2e 100644 (file)
@@ -24,8 +24,6 @@ namespace System.Net.Http
         {
             HttpRequestMessage request = state.RequestMessage;
             SafeWinHttpHandle requestHandle = state.RequestHandle;
-            CookieUsePolicy cookieUsePolicy = state.Handler.CookieUsePolicy;
-            CookieContainer cookieContainer = state.Handler.CookieContainer;
             var response = new HttpResponseMessage();
             bool stripEncodingHeaders = false;
 
index 8f31281..504a0d1 100644 (file)
@@ -90,7 +90,7 @@ namespace System.Net.Http
             {
                 CancellationToken = cancellationToken;
                 var b = new AsyncTaskMethodBuilder();
-                var ignored = b.Task; // force initialization
+                _ = b.Task; // force initialization
                 Builder = b;
             }
 
index 808c402..bba10f3 100644 (file)
@@ -243,7 +243,6 @@ namespace System.Net.Http
             }
 
             TimeSpan pooledConnectionLifetime = _poolManager.Settings._pooledConnectionLifetime;
-            TimeSpan pooledConnectionIdleTimeout = _poolManager.Settings._pooledConnectionIdleTimeout;
             long nowTicks = Environment.TickCount64;
             List<CachedConnection> list = _idleConnections;
 
index a111310..1ca1050 100644 (file)
@@ -336,8 +336,6 @@ namespace System.Net.WebSockets
                         NetEventSource.DumpBuffer(this, buffer.Array, buffer.Offset, buffer.Count);
                     }
 
-                    int position = buffer.Offset;
-
                     EnsureSendOperation();
                     _sendOperation.BufferType = GetBufferType(messageType, endOfMessage);
                     await _sendOperation.Process(buffer, linkedCancellationToken).SuppressContextFlow();
index 7e6d0bd..ab38795 100644 (file)
@@ -792,7 +792,7 @@ namespace System.Net.Sockets
                 {
                     responsibleForReturningToPool = _accessed;
                     _accessed = true;
-                    var ignored = _builder.Task; // force initialization under the lock (builder itself lazily initializes w/o synchronization)
+                    _ = _builder.Task; // force initialization under the lock (builder itself lazily initializes w/o synchronization)
                     return _builder;
                 }
             }
index d490988..486bbe9 100644 (file)
@@ -1285,7 +1285,7 @@ namespace System.Net.Sockets
                     {
                         // The Async IO completed with a failure.
                         // here we need to call WSAGetOverlappedResult() just so GetLastSocketError() will return the correct error.
-                        bool success = Interop.Winsock.WSAGetOverlappedResult(
+                        Interop.Winsock.WSAGetOverlappedResult(
                             _currentSocket.SafeHandle,
                             nativeOverlapped,
                             out numBytes,
index 03e42f6..07c3715 100644 (file)
@@ -265,7 +265,7 @@ namespace System.Net
             // be used to get the response, and it needs to be passed the IAsyncResult that was returned
             // from WebRequest.BeginGetResponse.
             var awaitable = new BeginEndAwaitableAdapter();
-            IAsyncResult iar = request.BeginGetResponse(BeginEndAwaitableAdapter.Callback, awaitable);
+            request.BeginGetResponse(BeginEndAwaitableAdapter.Callback, awaitable);
             return GetWebResponse(request, await awaitable);
         }
 
index c91fbda..1207827 100644 (file)
@@ -59,7 +59,7 @@ namespace System.Runtime.Serialization.Json
             context.IncrementItemCount(memberCount);
 
             DataMember[] members = new DataMember[memberCount];
-            int reflectedMemberCount = ReflectionGetMembers(classContract, members);
+            ReflectionGetMembers(classContract, members);
 
             int memberIndex = -1;
 
@@ -136,7 +136,6 @@ namespace System.Runtime.Serialization.Json
             Type valueType = keyValueTypes[1];
 
             int keyTypeNullableDepth = 0;
-            Type keyTypeOriginal = keyType;
             while (keyType.IsGenericType && keyType.GetGenericTypeDefinition() == Globals.TypeOfNullable)
             {
                 keyTypeNullableDepth++;
index d6ece99..5c80c45 100644 (file)
@@ -197,7 +197,6 @@ namespace System.Runtime.Serialization.Json
 
             childElementIndex += memberCount;
 
-            Type classType = classContract.UnadaptedClassType;
             context.IncrementItemCount(classContract.Members.Count);
             for (int i = 0; i < classContract.Members.Count; i++, memberCount++)
             {
index a5a037f..d9d9277 100644 (file)
@@ -85,7 +85,6 @@ namespace System.Runtime.Serialization
             bool isArray = (collectionContract.Kind == CollectionKind.Array);
 
             int arraySize = context.GetArraySize();
-            string objectId = context.GetObjectId();
             object resultArray = null;
             if (isArray && ReflectionTryReadPrimitiveArray(xmlReader, context, collectionItemName, collectionItemNamespace, collectionContract.UnderlyingType, collectionContract.ItemType, arraySize, out resultArray))
             {
@@ -196,7 +195,6 @@ namespace System.Runtime.Serialization
             DataMember dataMember = members[memberIndex];
 
             Debug.Assert(dataMember != null);
-            Type memberType = dataMember.MemberType;
             if (dataMember.IsGetOnlyCollection)
             {
                 var memberValue = ReflectionGetMemberValue(obj, dataMember);
@@ -314,7 +312,6 @@ namespace System.Runtime.Serialization
             }
 
             PrimitiveDataContract primitiveContract = PrimitiveDataContract.GetPrimitiveDataContract(type);
-            bool hasValidPrimitiveContract = primitiveContract != null && primitiveContract.UnderlyingType != Globals.TypeOfObject;
             if ((primitiveContract != null && primitiveContract.UnderlyingType != Globals.TypeOfObject) || nullables != 0 || type.IsValueType)
             {
                 return (xmlReaderArg, contextArg, collectionContract, typeArg, nameArg, nsArg) =>
index c961520..61f2984 100644 (file)
@@ -132,7 +132,6 @@ namespace System.Runtime.Serialization
 
             childElementIndex += memberCount;
 
-            Type classType = classContract.UnadaptedClassType;
             XmlDictionaryString[] memberNames = classContract.MemberNames;
             XmlDictionaryString ns = classContract.Namespace;
             context.IncrementItemCount(classContract.Members.Count);
index 4efa403..c78f5d4 100644 (file)
@@ -205,7 +205,6 @@ namespace System.Reflection.Context.Custom
             if (name.Length > 4)
             {
                 // Right now we don't support adding fabricated indexers on types
-                string prefix = name.Substring(0, 4);
                 getPropertyGetter = (types == null || types.Length == 0) && name.StartsWith("get_", comparison);
 
                 if (!getPropertyGetter)
index 3b589d5..a9dfaff 100644 (file)
@@ -156,7 +156,6 @@ namespace System.Reflection.PortableExecutable
             builder.WriteInt32(age);
 
             // UTF-8 encoded zero-terminated path to PDB
-            int pathStart = builder.Count;
             builder.WriteUTF8(pdbPath, allowUnpairedSurrogates: true);
             builder.WriteByte(0);
 
index e510778..f6a9809 100644 (file)
@@ -19,8 +19,6 @@ namespace System.Reflection.TypeLoading
         //
         internal RoPseudoCustomAttributeData(ConstructorInfo constructor, Func<CustomAttributeArguments> argumentsPromise)
         {
-            CustomAttributeArguments ca = argumentsPromise();
-
             _constructor = constructor;
             _argumentsPromise = argumentsPromise;
         }
index b86217e..6bd5741 100644 (file)
@@ -21,7 +21,6 @@ namespace System.Reflection.TypeLoading.Ecma
 
         protected sealed override RoType ComputeDeclaringType()
         {
-            MetadataReader reader = Reader;
             TypeDefinitionHandle declaringTypeHandle = (TypeDefinitionHandle)(GenericParameter.Parent);
             EcmaDefinitionType declaringType = declaringTypeHandle.ResolveTypeDef(GetEcmaModule());
             return declaringType;
index 2f661b5..be58946 100644 (file)
@@ -154,7 +154,6 @@ namespace System.Reflection.TypeLoading
 
             int uniquifier = 0;
             RoType systemInt32 = Loader.GetCoreType(CoreType.Int32);
-            RoArrayType arrayType = this;
             RoType elementType = GetRoElementType();
             RoType systemVoid = Loader.GetCoreType(CoreType.Void);
 
index ccea174..688d3e6 100644 (file)
@@ -761,8 +761,8 @@ namespace System.Numerics
             if (value._sign < 0)
             {
                 string negativeSign = info.NegativeSign;
-                for (int i = info.NegativeSign.Length - 1; i > -1; i--)
-                    rgch[--ichDst] = info.NegativeSign[i];
+                for (int i = negativeSign.Length - 1; i > -1; i--)
+                    rgch[--ichDst] = negativeSign[i];
             }
 
             int resultLength = cchMax - ichDst;
index 81bc011..ababe11 100644 (file)
@@ -32,8 +32,6 @@ namespace System.Security.Cryptography
             Span<byte> tag,
             ReadOnlySpan<byte> associatedData = default)
         {
-            ref byte nullRef = ref MemoryMarshal.GetReference(Span<byte>.Empty);
-
             using (SafeEvpCipherCtxHandle ctx = Interop.Crypto.EvpCipherCreatePartial(GetCipher(_key.Length * 8)))
             {
                 Interop.Crypto.CheckValidOpenSslHandle(ctx);
index dd20962..284747d 100644 (file)
@@ -75,7 +75,6 @@ namespace System.Security.Cryptography.Xml
             if (value == null)
                 throw new ArgumentNullException(nameof(value));
 
-            XmlElement retrievalMethodElement = value;
             _uri = Utils.GetAttribute(value, "URI", SignedXml.XmlDsigNamespaceUrl);
             _type = Utils.GetAttribute(value, "Type", SignedXml.XmlDsigNamespaceUrl);
         }
index aef5d49..94616a0 100644 (file)
@@ -622,8 +622,6 @@ namespace System.Security.Principal
                     IdentityReferenceCollection groups = new IdentityReferenceCollection();
                     using (SafeLocalAllocHandle pGroups = GetTokenInformation(_safeTokenHandle, TokenInformationClass.TokenGroups))
                     {
-                        uint groupCount = pGroups.Read<uint>(0);
-
                         Interop.TOKEN_GROUPS tokenGroups = pGroups.Read<Interop.TOKEN_GROUPS>(0);
                         Interop.SID_AND_ATTRIBUTES[] groupDetails = new Interop.SID_AND_ATTRIBUTES[tokenGroups.GroupCount];
                         pGroups.ReadArray((uint)Marshal.OffsetOf<Interop.TOKEN_GROUPS>("Groups").ToInt32(),
index ab72151..ec633df 100644 (file)
@@ -989,7 +989,6 @@ namespace System.Text.Json
             int leftOver = _buffer.Length - idx;
             int leftOverFromConsumed = _buffer.Length - _consumed;
 
-            long prevTotalConsumed = _totalConsumed;
             long prevLineBytePosition = _bytePositionInLine;
             long prevLineNumber = _lineNumber;
 
index 05f5879..60084a6 100644 (file)
@@ -295,6 +295,7 @@ namespace System.Text.Json
 #else
                     Debug.Assert(_arrayBufferWriter.WrittenMemory.Length == _arrayBufferWriter.WrittenCount);
                     bool result = MemoryMarshal.TryGetArray(_arrayBufferWriter.WrittenMemory, out ArraySegment<byte> underlyingBuffer);
+                    Debug.Assert(result);
                     Debug.Assert(underlyingBuffer.Offset == 0);
                     Debug.Assert(_arrayBufferWriter.WrittenCount == underlyingBuffer.Count);
                     _stream.Write(underlyingBuffer.Array, underlyingBuffer.Offset, underlyingBuffer.Count);
@@ -408,6 +409,7 @@ namespace System.Text.Json
 #else
                     Debug.Assert(_arrayBufferWriter.WrittenMemory.Length == _arrayBufferWriter.WrittenCount);
                     bool result = MemoryMarshal.TryGetArray(_arrayBufferWriter.WrittenMemory, out ArraySegment<byte> underlyingBuffer);
+                    Debug.Assert(result);
                     Debug.Assert(underlyingBuffer.Offset == 0);
                     Debug.Assert(_arrayBufferWriter.WrittenCount == underlyingBuffer.Count);
                     await _stream.WriteAsync(underlyingBuffer.Array, underlyingBuffer.Offset, underlyingBuffer.Count, cancellationToken).ConfigureAwait(false);
@@ -1048,6 +1050,7 @@ namespace System.Text.Json
 #else
                 Debug.Assert(_arrayBufferWriter.WrittenMemory.Length == _arrayBufferWriter.WrittenCount);
                 bool result = MemoryMarshal.TryGetArray(_arrayBufferWriter.WrittenMemory, out ArraySegment<byte> underlyingBuffer);
+                Debug.Assert(result);
                 Debug.Assert(underlyingBuffer.Offset == 0);
                 Debug.Assert(_arrayBufferWriter.WrittenCount == underlyingBuffer.Count);
                 _stream.Write(underlyingBuffer.Array, underlyingBuffer.Offset, underlyingBuffer.Count);
index 0dca404..ca6a214 100644 (file)
@@ -1013,7 +1013,6 @@ namespace System.Text.RegularExpressions
          */
         private void GenerateMiddleSection()
         {
-            Label l1 = DefineLabel();
             Label[] table;
             int i;
 
@@ -1227,7 +1226,6 @@ namespace System.Text.RegularExpressions
                 Label lAdvance = DefineLabel();
                 Label lFail = DefineLabel();
                 Label lStart = DefineLabel();
-                Label lOutOfRange = DefineLabel();
                 Label lPartialMatch = DefineLabel();
 
 
@@ -1398,7 +1396,6 @@ namespace System.Text.RegularExpressions
             else
             {
                 LocalBuilder cV = _temp2V;
-                LocalBuilder chV = _tempV;
                 Label l1 = DefineLabel();
                 Label l2 = DefineLabel();
                 Label l3 = DefineLabel();
@@ -2141,8 +2138,6 @@ namespace System.Text.RegularExpressions
                         LocalBuilder count = _tempV;
                         LocalBuilder mark = _temp2V;
                         Label l1 = DefineLabel();
-                        Label l2 = DefineLabel();
-                        Label l3 = _labels[NextCodepos()];
 
                         PopStack();
                         Stloc(count);                           // count -> temp
index 254303f..287e8d8 100644 (file)
@@ -367,9 +367,14 @@ namespace System.Threading.Channels
                     {
                         // The channel is full, and we're in a dropping mode.
                         // Drop either the oldest or the newest and write the new item.
-                        T droppedItem = parent._mode == BoundedChannelFullMode.DropNewest ?
-                            parent._items.DequeueTail() :
+                        if (parent._mode == BoundedChannelFullMode.DropNewest)
+                        {
+                            parent._items.DequeueTail();
+                        }
+                        else
+                        {
                             parent._items.DequeueHead();
+                        }
                         parent._items.EnqueueTail(item);
                         return true;
                     }
@@ -539,9 +544,14 @@ namespace System.Threading.Channels
                     {
                         // The channel is full, and we're in a dropping mode.
                         // Drop either the oldest or the newest and write the new item.
-                        T droppedItem = parent._mode == BoundedChannelFullMode.DropNewest ?
-                            parent._items.DequeueTail() :
+                        if (parent._mode == BoundedChannelFullMode.DropNewest)
+                        {
+                            parent._items.DequeueTail();
+                        }
+                        else
+                        {
                             parent._items.DequeueHead();
+                        }
                         parent._items.EnqueueTail(item);
                         return default;
                     }
index 95544c1..497c40b 100644 (file)
@@ -764,8 +764,6 @@ namespace System.Threading
                     _actionCallerID = Environment.CurrentManagedThreadId;
                     if (_ownerThreadContext != null)
                     {
-                        var currentContext = _ownerThreadContext;
-
                         ContextCallback? handler = s_invokePostPhaseAction;
                         if (handler == null)
                         {