From: Stephen Toub Date: Mon, 5 Aug 2019 15:05:14 +0000 (-0400) Subject: Remove some unused locals (dotnet/corefx#39956) X-Git-Tag: submit/tizen/20210909.063632~11031^2~779 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd386d1dbbc33fef4d77550b0e0c1d3c40524816;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Remove some unused locals (dotnet/corefx#39956) * 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 --- diff --git a/src/libraries/Common/src/System/Data/ProviderBase/DbConnectionInternal.cs b/src/libraries/Common/src/System/Data/ProviderBase/DbConnectionInternal.cs index 45fed43..80014f9 100644 --- a/src/libraries/Common/src/System/Data/ProviderBase/DbConnectionInternal.cs +++ b/src/libraries/Common/src/System/Data/ProviderBase/DbConnectionInternal.cs @@ -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 diff --git a/src/libraries/Common/src/System/Net/CaseInsensitiveAscii.cs b/src/libraries/Common/src/System/Net/CaseInsensitiveAscii.cs index 80cc924..d09f0d4 100644 --- a/src/libraries/Common/src/System/Net/CaseInsensitiveAscii.cs +++ b/src/libraries/Common/src/System/Net/CaseInsensitiveAscii.cs @@ -112,7 +112,6 @@ namespace System.Net { if (FastGetHashCode(firstString) == FastGetHashCode(secondString)) { - int comparisons = firstString.Length; while (index > 0) { index--; diff --git a/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs b/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs index 24911ad..344e775 100644 --- a/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs +++ b/src/libraries/Common/src/System/Net/WebSockets/ManagedWebSocket.cs @@ -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); diff --git a/src/libraries/Common/src/System/Reflection/Emit/IgnoreAccessChecksToAttributeBuilder.cs b/src/libraries/Common/src/System/Reflection/Emit/IgnoreAccessChecksToAttributeBuilder.cs index e64e96e..239da51 100644 --- a/src/libraries/Common/src/System/Reflection/Emit/IgnoreAccessChecksToAttributeBuilder.cs +++ b/src/libraries/Common/src/System/Reflection/Emit/IgnoreAccessChecksToAttributeBuilder.cs @@ -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", diff --git a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs index 4565b8f..a7960b7 100644 --- a/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs +++ b/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs @@ -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. diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs index f611c38..706ce5a 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Minimal.cs @@ -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; } /// diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs b/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs index 80b89a0..030c697 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/SortedSet.cs @@ -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) { diff --git a/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/RegistrationBuilder.cs b/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/RegistrationBuilder.cs index 9fc6308..47f2526 100644 --- a/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/RegistrationBuilder.cs +++ b/src/libraries/System.ComponentModel.Composition.Registration/src/System/ComponentModel/Composition/Registration/RegistrationBuilder.cs @@ -93,7 +93,6 @@ namespace System.ComponentModel.Composition.Registration private IEnumerable>> EvaluateThisTypeAgainstTheConvention(Type type) { - List>> results = new List>>(); List attributes = new List(); var configuredMembers = new List>>(); diff --git a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/GenericServices.cs b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/GenericServices.cs index 875da0d..9820f56 100644 --- a/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/GenericServices.cs +++ b/src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/GenericServices.cs @@ -46,7 +46,6 @@ namespace System.ComponentModel.Composition.ReflectionModel int genericArity = 0; if (type.IsGenericType && type.ContainsGenericParameters) { - List pureGenericParameters = new List(); TraverseGenericType(type, (Type t) => { if (t.IsGenericParameter) diff --git a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs index f8ffcae..057c8ea 100644 --- a/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs +++ b/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TypeDescriptor.cs @@ -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); } diff --git a/src/libraries/System.Composition.Convention/src/System/Composition/Convention/ConventionBuilder.cs b/src/libraries/System.Composition.Convention/src/System/Composition/Convention/ConventionBuilder.cs index 6f19e9d..41ef55f 100644 --- a/src/libraries/System.Composition.Convention/src/System/Composition/Convention/ConventionBuilder.cs +++ b/src/libraries/System.Composition.Convention/src/System/Composition/Convention/ConventionBuilder.cs @@ -126,7 +126,6 @@ namespace System.Composition.Convention private IEnumerable>> EvaluateThisTypeInfoAgainstTheConvention(TypeInfo typeInfo) { - List>> results = new List>>(); List attributes = new List(); var configuredMembers = new List>>(); bool specifiedConstructor = false; diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigurationHost.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigurationHost.cs index 6bc3693..33f5b44 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigurationHost.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigurationHost.cs @@ -209,7 +209,7 @@ namespace System.Configuration _configPaths = null; // Force loading of user.config file information under lock. - ClientConfigPaths configPaths = ConfigPaths; + _ = ConfigPaths; } } } diff --git a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs index 6a1b68a..30ef519 100644 --- a/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs +++ b/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/Configuration.cs @@ -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 +} diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs index aa315f4..00adf02 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbDataAdapter.cs @@ -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"); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataRelation.cs b/src/libraries/System.Data.Common/src/System/Data/DataRelation.cs index 873c2c0..5ee84f3 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataRelation.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataRelation.cs @@ -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) { diff --git a/src/libraries/System.Data.Common/src/System/Data/DataSet.cs b/src/libraries/System.Data.Common/src/System/Data/DataSet.cs index 81f36b3..8bbd6b8 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataSet.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataSet.cs @@ -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(" {0}, mode={1}", ObjectID, mode); try { - string ns = xdoc.DocumentElement.NamespaceURI; if (null == excludedNamespaces) { excludedNamespaces = Array.Empty(); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index 5fdd3a3..6540ec6 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -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) { diff --git a/src/libraries/System.Data.Common/src/System/Data/DataView.cs b/src/libraries/System.Data.Common/src/System/Data/DataView.cs index 482e232..2211729 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataView.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataView.cs @@ -1600,8 +1600,6 @@ namespace System.Data return; } - DataTable table = _index != null ? _index.Table : newIndex.Table; - if (_index != null) { _dvListener.UnregisterListChangedEvent(); diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs index d15a423..e2f3bb1 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/ExpressionParser.cs @@ -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; diff --git a/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs b/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs index d757274..a17b9560 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Filter/FunctionNode.cs @@ -573,7 +573,6 @@ namespace System.Data internal void Check() { - Function f = s_funcs[_info]; if (_info < 0) throw ExprException.UndefinedFunction(_name); diff --git a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs index 2de681f..ba6fe84 100644 --- a/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs +++ b/src/libraries/System.Data.Common/src/System/Data/SQLTypes/SQLDecimal.cs @@ -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(); diff --git a/src/libraries/System.Data.Common/src/System/Data/Select.cs b/src/libraries/System.Data.Common/src/System/Data/Select.cs index 127e285..0d57aa4 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Select.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Select.cs @@ -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) diff --git a/src/libraries/System.Data.Common/src/System/Data/Selection.cs b/src/libraries/System.Data.Common/src/System/Data/Selection.cs index ed6607e..276c0ae 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Selection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Selection.cs @@ -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) { diff --git a/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs b/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs index b40ce0c..c3c9dd5 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XDRSchema.cs @@ -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) { diff --git a/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs b/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs index 5f47086..7fb0b3e 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XMLDiffLoader.cs @@ -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); diff --git a/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs b/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs index 7f2859b..7e5c296 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XmlDataLoader.cs @@ -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++; } diff --git a/src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs b/src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs index fe7946d..64d45f4 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/XPathNodePointer.cs @@ -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) diff --git a/src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs b/src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs index e0d67ec..6096379 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/XmlBoundElement.cs @@ -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; } } diff --git a/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs b/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs index a6c3955..38798f1 100644 --- a/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs +++ b/src/libraries/System.Data.Common/src/System/Xml/XmlDataDocument.cs @@ -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; } diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs index d67bfc9..6166b0f 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcDataReader.cs @@ -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; diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcHandle.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcHandle.cs index 1ecd9b6..d690cc1 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcHandle.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcHandle.cs @@ -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: diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/LocalDBAPI.Common.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/LocalDBAPI.Common.cs index 0a84175..eb4f91a 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/LocalDBAPI.Common.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/LocalDBAPI.Common.cs @@ -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(functionAddr); diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs index 68d7112..1e99f79 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs @@ -1026,7 +1026,6 @@ namespace System.Data.SqlClient private void WaitForAsyncResults(IAsyncResult asyncResult) { - Task completionTask = (Task)asyncResult; if (!asyncResult.IsCompleted) { asyncResult.AsyncWaitHandle.WaitOne(); diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnection.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnection.cs index a88c5ac..65ff452 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnection.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlConnection.cs @@ -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); diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependency.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependency.cs index a3095a4..c37dd3d 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependency.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependency.cs @@ -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. diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs index 5640f45..c7731ac 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/SqlDependencyListener.cs @@ -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; diff --git a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs index 08bff5ae7..a8451d5 100644 --- a/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs +++ b/src/libraries/System.Data.SqlClient/src/System/Data/SqlClient/TdsParser.cs @@ -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) { diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs index b599680..6ecfc10 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/DiagnosticSourceEventSource.cs @@ -484,9 +484,7 @@ namespace System.Diagnostics /// 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 /// 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= diff --git a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogInternal.cs b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogInternal.cs index f3f37de..7ed86cb 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogInternal.cs +++ b/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLogInternal.cs @@ -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; } } diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs index fd2d23e..ab33bac 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceCounterLib.cs @@ -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; diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceData/CounterSetInstance.cs b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceData/CounterSetInstance.cs index de27f58..cf9aeac 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceData/CounterSetInstance.cs +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System/Diagnostics/PerformanceData/CounterSetInstance.cs @@ -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; } diff --git a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs index 2c09a5f..3dd1c68 100644 --- a/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs +++ b/src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/ldap/LdapPartialResultsProcessor.cs @@ -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 diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs index 326ea36..3013b4e 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/Domain.cs @@ -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; diff --git a/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs b/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs index 892fec1..58d84b6 100644 --- a/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs +++ b/src/libraries/System.IO.Compression.Brotli/src/System/IO/Compression/dec/BrotliStream.Decompress.cs @@ -120,7 +120,6 @@ namespace System.IO.Compression try { int totalWritten = 0; - Memory source = Memory.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) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseParser.cs b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseParser.cs index 7374402..d5efa2e 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseParser.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpResponseParser.cs @@ -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; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs index 8f31281..504a0d1 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs @@ -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; } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs index 808c402..bba10f3 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs @@ -243,7 +243,6 @@ namespace System.Net.Http } TimeSpan pooledConnectionLifetime = _poolManager.Settings._pooledConnectionLifetime; - TimeSpan pooledConnectionIdleTimeout = _poolManager.Settings._pooledConnectionIdleTimeout; long nowTicks = Environment.TickCount64; List list = _idleConnections; diff --git a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBase.cs b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBase.cs index a111310..1ca1050 100644 --- a/src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBase.cs +++ b/src/libraries/System.Net.HttpListener/src/System/Net/Windows/WebSockets/WebSocketBase.cs @@ -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(); diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs index 7e6d0bd..ab38795 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs @@ -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; } } diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs index d490988..486bbe9 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs @@ -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, diff --git a/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs b/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs index 03e42f6..07c3715 100644 --- a/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs +++ b/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs @@ -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); } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs index c91fbda..1207827 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatReader.cs @@ -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++; diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatWriter.cs index d6ece99..5c80c45 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/ReflectionJsonFormatWriter.cs @@ -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++) { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs index a5a037f..d9d9277 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionReader.cs @@ -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) => diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionXmlFormatWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionXmlFormatWriter.cs index c961520..61f2984 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionXmlFormatWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ReflectionXmlFormatWriter.cs @@ -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); diff --git a/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Custom/CustomType.cs b/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Custom/CustomType.cs index 4efa403..c78f5d4 100644 --- a/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Custom/CustomType.cs +++ b/src/libraries/System.Reflection.Context/src/System/Reflection/Context/Custom/CustomType.cs @@ -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) diff --git a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/DebugDirectory/DebugDirectoryBuilder.cs b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/DebugDirectory/DebugDirectoryBuilder.cs index 3b589d5..a9dfaff 100644 --- a/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/DebugDirectory/DebugDirectoryBuilder.cs +++ b/src/libraries/System.Reflection.Metadata/src/System/Reflection/PortableExecutable/DebugDirectory/DebugDirectoryBuilder.cs @@ -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); diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/RoPseudoCustomAttributeData.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/RoPseudoCustomAttributeData.cs index e510778..f6a9809 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/RoPseudoCustomAttributeData.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/CustomAttributes/RoPseudoCustomAttributeData.cs @@ -19,8 +19,6 @@ namespace System.Reflection.TypeLoading // internal RoPseudoCustomAttributeData(ConstructorInfo constructor, Func argumentsPromise) { - CustomAttributeArguments ca = argumentsPromise(); - _constructor = constructor; _argumentsPromise = argumentsPromise; } diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/Ecma/EcmaGenericTypeParameterType.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/Ecma/EcmaGenericTypeParameterType.cs index b86217e..6bd5741 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/Ecma/EcmaGenericTypeParameterType.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/Ecma/EcmaGenericTypeParameterType.cs @@ -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; diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs index 2f661b5..be58946 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/Types/RoArrayType.cs @@ -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); diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs index ccea174..688d3e6 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs @@ -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; diff --git a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AesCcm.Unix.cs b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AesCcm.Unix.cs index 81bc011..ababe11 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AesCcm.Unix.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/AesCcm.Unix.cs @@ -32,8 +32,6 @@ namespace System.Security.Cryptography Span tag, ReadOnlySpan associatedData = default) { - ref byte nullRef = ref MemoryMarshal.GetReference(Span.Empty); - using (SafeEvpCipherCtxHandle ctx = Interop.Crypto.EvpCipherCreatePartial(GetCipher(_key.Length * 8))) { Interop.Crypto.CheckValidOpenSslHandle(ctx); diff --git a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoRetrievalMethod.cs b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoRetrievalMethod.cs index dd20962..284747d 100644 --- a/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoRetrievalMethod.cs +++ b/src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/KeyInfoRetrievalMethod.cs @@ -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); } diff --git a/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs b/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs index aef5d49..94616a0 100644 --- a/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs +++ b/src/libraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsIdentity.cs @@ -622,8 +622,6 @@ namespace System.Security.Principal IdentityReferenceCollection groups = new IdentityReferenceCollection(); using (SafeLocalAllocHandle pGroups = GetTokenInformation(_safeTokenHandle, TokenInformationClass.TokenGroups)) { - uint groupCount = pGroups.Read(0); - Interop.TOKEN_GROUPS tokenGroups = pGroups.Read(0); Interop.SID_AND_ATTRIBUTES[] groupDetails = new Interop.SID_AND_ATTRIBUTES[tokenGroups.GroupCount]; pGroups.ReadArray((uint)Marshal.OffsetOf("Groups").ToInt32(), diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs index ab72151..ec633df 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.MultiSegment.cs @@ -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; diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs index 05f5879..60084a6 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.cs @@ -295,6 +295,7 @@ namespace System.Text.Json #else Debug.Assert(_arrayBufferWriter.WrittenMemory.Length == _arrayBufferWriter.WrittenCount); bool result = MemoryMarshal.TryGetArray(_arrayBufferWriter.WrittenMemory, out ArraySegment 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 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 underlyingBuffer); + Debug.Assert(result); Debug.Assert(underlyingBuffer.Offset == 0); Debug.Assert(_arrayBufferWriter.WrittenCount == underlyingBuffer.Count); _stream.Write(underlyingBuffer.Array, underlyingBuffer.Offset, underlyingBuffer.Count); diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs index 0dca404..ca6a214 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs @@ -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 diff --git a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/BoundedChannel.cs b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/BoundedChannel.cs index 254303f..287e8d8 100644 --- a/src/libraries/System.Threading.Channels/src/System/Threading/Channels/BoundedChannel.cs +++ b/src/libraries/System.Threading.Channels/src/System/Threading/Channels/BoundedChannel.cs @@ -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; } diff --git a/src/libraries/System.Threading/src/System/Threading/Barrier.cs b/src/libraries/System.Threading/src/System/Threading/Barrier.cs index 95544c1..497c40b 100644 --- a/src/libraries/System.Threading/src/System/Threading/Barrier.cs +++ b/src/libraries/System.Threading/src/System/Threading/Barrier.cs @@ -764,8 +764,6 @@ namespace System.Threading _actionCallerID = Environment.CurrentManagedThreadId; if (_ownerThreadContext != null) { - var currentContext = _ownerThreadContext; - ContextCallback? handler = s_invokePostPhaseAction; if (handler == null) {