Remove unused locals in System.Data.OleDb (dotnet/corefx#42485)
authorEriawan Kusumawardhono <eriawan@live.com>
Wed, 13 Nov 2019 19:23:52 +0000 (02:23 +0700)
committermsftbot[bot] <48340428+msftbot[bot]@users.noreply.github.com>
Wed, 13 Nov 2019 19:23:52 +0000 (19:23 +0000)
* emove unused locals in System.Data.OleDband keep some logic using discard. Partially fix issue dotnet/corefx#39962

* Update src/System.Data.OleDb/src/OleDbDataReader.cs

update as suggested (OleDbDataReader)

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
* Update src/System.Data.OleDb/src/OleDbTransaction.cs

Done update as suggested

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
* Update src/System.Data.OleDb/src/RowBinding.cs

Done update as suggested (RowDataBinding)

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
* Update src/System.Data.OleDb/src/RowBinding.cs

Done as suggested

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
* Update src/System.Data.OleDb/src/SafeHandles.cs

Done updating as suggested (SafeHandles)

Co-Authored-By: Stephen Toub <stoub@microsoft.com>
Commit migrated from https://github.com/dotnet/corefx/commit/eceea8b4284ca42d8bd0134414b43c835bd80e4c

src/libraries/System.Data.OleDb/src/OleDbConnection.cs
src/libraries/System.Data.OleDb/src/OleDbConnectionInternal.cs
src/libraries/System.Data.OleDb/src/OleDbDataAdapter.cs
src/libraries/System.Data.OleDb/src/OleDbDataReader.cs
src/libraries/System.Data.OleDb/src/OleDbTransaction.cs
src/libraries/System.Data.OleDb/src/RowBinding.cs
src/libraries/System.Data.OleDb/src/SafeHandles.cs

index d337db4..3a9a17c 100644 (file)
@@ -515,12 +515,6 @@ namespace System.Data.OleDb
                     ADP.TraceExceptionWithoutRethrow(e);
                 }
             }
-#if DEBUG
-            else
-            {
-                OleDbException exception = OleDbException.CreateException(errorInfo, errorCode, null);
-            }
-#endif
         }
 
         public override void Open()
index 6cabd02..ebd13dc 100644 (file)
@@ -321,7 +321,6 @@ namespace System.Data.OleDb
 
         public override void EnlistTransaction(SysTx.Transaction transaction)
         {
-            OleDbConnection outerConnection = Connection;
             if (null != LocalTransaction)
             {
                 throw ADP.LocalTransactionPresent();
@@ -821,8 +820,6 @@ namespace System.Data.OleDb
 
         internal Dictionary<string, OleDbPropertyInfo> GetPropertyInfo(Guid[] propertySets)
         {
-            bool isopen = HasSession;
-            OleDbConnectionString constr = ConnectionString;
             Dictionary<string, OleDbPropertyInfo> properties = null;
 
             if (null == propertySets)
index cdd5c63..e50b7b5 100644 (file)
@@ -262,10 +262,6 @@ namespace System.Data.OleDb
                                 UnsafeNativeMethods.GetErrorInfo(0, out errorInfo);
 
                                 string message = string.Empty;
-                                if (null != errorInfo)
-                                {
-                                    OleDbHResult hresult = ODB.GetErrorDescription(errorInfo, hr, out message);
-                                }
                                 throw new COMException(message, (int)hr);
                             }
                             break;
@@ -436,10 +432,6 @@ namespace System.Data.OleDb
                 UnsafeNativeMethods.IErrorInfo errorInfo = null;
                 UnsafeNativeMethods.GetErrorInfo(0, out errorInfo);
                 string message = string.Empty;
-                if (null != errorInfo)
-                {
-                    OleDbHResult hresult = ODB.GetErrorDescription(errorInfo, hr, out message);
-                }
                 throw new COMException(message, (int)hr);
             }
         }
index 1359e81..5ee968c 100644 (file)
@@ -1166,7 +1166,7 @@ namespace System.Data.OleDb
             {
                 throw ADP.ArgumentNull("values");
             }
-            MetaData info = DoValueCheck(0);
+            DoValueCheck(0);
             int count = Math.Min(values.Length, _visibleFieldCount);
             for (int i = 0; (i < _metadata.Length) && (i < count); ++i)
             {
@@ -2163,7 +2163,6 @@ namespace System.Data.OleDb
                     {
                         bool isPKey = (!dataRow.IsNull(pkeyColumn, DataRowVersion.Default) && (bool)dataRow[pkeyColumn, DataRowVersion.Default]);
                         bool isUniq = (!dataRow.IsNull(uniqCOlumn, DataRowVersion.Default) && (bool)dataRow[uniqCOlumn, DataRowVersion.Default]);
-                        bool nullsVal = (null != nulls) && (dataRow.IsNull(nulls, DataRowVersion.Default) || (ODB.DBPROPVAL_IN_ALLOWNULL == Convert.ToInt32(dataRow[nulls, DataRowVersion.Default], CultureInfo.InvariantCulture)));
 
                         if (isPKey || isUniq)
                         {
index 2c05339..0db6714 100644 (file)
@@ -108,7 +108,7 @@ namespace System.Data.OleDb
             {
                 if (_mustComplete && (IntPtr.Zero != base.handle))
                 {
-                    OleDbHResult hr = (OleDbHResult)NativeOledbWrapper.ITransactionAbort(base.handle);
+                    NativeOledbWrapper.ITransactionAbort(base.handle);
                     _mustComplete = false;
                 }
                 return base.ReleaseHandle();
index 6b0f762..9bd1c70 100644 (file)
@@ -478,8 +478,7 @@ namespace System.Data.OleDb
             IntPtr chapter = SafeNativeMethods.InterlockedExchangePointer(ADP.IntPtrOffset(buffer, valueOffset), ADP.PtrZero);
             if (ODB.DB_NULL_HCHAPTER != chapter)
             {
-                int refCount;
-                OleDbHResult hr = chapteredRowset.ReleaseChapter(chapter, out refCount);
+                chapteredRowset.ReleaseChapter(chapter, out _);
             }
         }
 
index cf48722..727d3d4 100644 (file)
@@ -160,7 +160,7 @@ namespace System.Data.OleDb
 
             if ((IntPtr.Zero != base.handle) && (IntPtr.Zero != chapter))
             {
-                OleDbHResult hr = (OleDbHResult)NativeOledbWrapper.IChapteredRowsetReleaseChapter(base.handle, chapter);
+                NativeOledbWrapper.IChapteredRowsetReleaseChapter(base.handle, chapter);
             }
             return base.ReleaseHandle();
         }