From 322d208c7f48f378ccaf487905403589ae889f5e Mon Sep 17 00:00:00 2001 From: Eriawan Kusumawardhono Date: Wed, 23 Oct 2019 20:33:22 +0700 Subject: [PATCH] Remove unused locals in System.Data.Common and keep some logic using discard (dotnet/corefx#41962) * remove unused locals in System.Data.Common and keep some logic using discard * revert the HandleTable(element) removal as PR feedback. Use discard as return value is ignored. Commit migrated from https://github.com/dotnet/corefx/commit/ae71c86289d759318e212144b94c58d0a586a33c --- .../src/System/Data/DataColumnCollection.cs | 5 ----- .../System.Data.Common/src/System/Data/XMLSchema.cs | 5 ++--- .../System.Data.Common/src/System/Data/xmlsaver.cs | 10 ++-------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs b/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs index 7598e2c598692..014ad8b400b0a 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataColumnCollection.cs @@ -802,11 +802,6 @@ private void OnCollectionChanged(CollectionChangeEventArgs ccevent) { _table.UpdatePropertyDescriptorCollectionCache(); - if ((null != ccevent) && !_table.SchemaLoading && !_table.fInitInProgress) - { - DataColumn column = (DataColumn)ccevent.Element; - } - CollectionChanged?.Invoke(this, ccevent); } diff --git a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs index e88572c8f1f04..726c377f61e15 100644 --- a/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs +++ b/src/libraries/System.Data.Common/src/System/Data/XMLSchema.cs @@ -783,7 +783,8 @@ public void LoadSchema(XmlSchemaSet schemaSet, DataSet ds) continue; } - DataTable table = HandleTable(element); + _ = HandleTable(element); + } if (_dsElement != null) @@ -2364,7 +2365,6 @@ internal void HandleElementColumn(XmlSchemaElement elem, DataTable table, bool i // it should be user defined Named simple type if (((XmlSchemaSimpleType)typeNode).Name != null && ((XmlSchemaSimpleType)typeNode).Name.Length != 0 && ((XmlSchemaSimpleType)typeNode).QualifiedName.Namespace != Keywords.XSDNS) { - string targetNamespace = XSDSchema.GetMsdataAttribute(typeNode, Keywords.TARGETNAMESPACE); strType = ((XmlSchemaSimpleType)typeNode).QualifiedName.ToString(); // use qualifed name type = ParseDataType(strType); } @@ -2536,7 +2536,6 @@ internal void HandleDataSet(XmlSchemaElement node, bool isNewDataSet) { string dsName = node.Name; string dsNamespace = node.QualifiedName.Namespace; - int initialTableCount = _ds.Tables.Count; // just use for inference backward compatablity List tableSequenceList = new List(); diff --git a/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs b/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs index 59c86728cfe4b..c8cee2a4d2c2b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs +++ b/src/libraries/System.Data.Common/src/System/Data/xmlsaver.cs @@ -949,7 +949,7 @@ internal XmlElement SchemaTree(XmlDocument xd, DataTable dt) _sRoot = rootSchema; WriteSchemaRoot(xd, rootSchema, dt.Namespace); - XmlElement dsCompositor = FillDataSetElement(xd, null, dt); + _ = FillDataSetElement(xd, null, dt); _constraintSeparator = xd.CreateElement(Keywords.XSD_PREFIX, "SHOULDNOTBEHERE", Keywords.XSDNS); _dsElement.AppendChild(_constraintSeparator); @@ -1493,8 +1493,7 @@ internal XmlElement HandleColumn(DataColumn col, XmlDocument dc, XmlElement sche root.SetAttribute(Keywords.REF, _prefixes[col.Namespace] + ":" + col.EncodedColumnName); if (col.Table.Namespace != _ds.Namespace) { - string prefix = (string)_prefixes[col.Namespace]; - XmlElement tNode = GetSchema(col.Table.Namespace); + _ = GetSchema(col.Table.Namespace); } } } @@ -2486,9 +2485,6 @@ private void GenerateRow(DataRow row) string tablePrefix = (table.Namespace.Length != 0) ? table.Prefix : string.Empty; - // read value if the TextOnly column (if any) - object val = (table.XmlText == null ? DBNull.Value : row[table.XmlText, DataRowVersion.Original]); - //old row _xmlw.WriteStartElement(tablePrefix, row.Table.EncodedTableName, row.Table.Namespace); @@ -2774,8 +2770,6 @@ internal void SaveDiffgramData(XmlWriter xw, Hashtable rowsOrder) _isDiffgram = true; _rowsOrder = rowsOrder; - int countTopTable = _topLevelTables.Length; - string prefix = (_ds != null) ? ((_ds.Namespace.Length == 0) ? "" : _ds.Prefix) : ((_dt.Namespace.Length == 0) ? "" : _dt.Prefix); if (_ds == null || _ds.DataSetName == null || _ds.DataSetName.Length == 0)