diff --git a/src/libraries/Common/src/Interop/Interop.Odbc.cs b/src/libraries/Common/src/Interop/Interop.Odbc.cs index 4113c59e4fefb..0b30095146989 100644 --- a/src/libraries/Common/src/Interop/Interop.Odbc.cs +++ b/src/libraries/Common/src/Interop/Interop.Odbc.cs @@ -17,20 +17,20 @@ internal static partial class Odbc // // ODBC32 // - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLAllocHandle( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLAllocHandle( /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, /*SQLHANDLE*/IntPtr InputHandle, /*SQLHANDLE* */out IntPtr OutputHandle); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLAllocHandle( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLAllocHandle( /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, /*SQLHANDLE*/OdbcHandle InputHandle, /*SQLHANDLE* */out IntPtr OutputHandle); [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLBindCol( + internal static extern /*SQLRETURN*/ODBC32.SQLRETURN SQLBindCol( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/ushort ColumnNumber, /*SQLSMALLINT*/ODBC32.SQL_C TargetType, @@ -38,8 +38,8 @@ internal static partial class Odbc /*SQLLEN*/IntPtr BufferLength, /*SQLLEN* */IntPtr StrLen_or_Ind); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLBindCol( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLBindCol( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/ushort ColumnNumber, /*SQLSMALLINT*/ODBC32.SQL_C TargetType, @@ -48,7 +48,7 @@ internal static partial class Odbc /*SQLLEN* */IntPtr StrLen_or_Ind); [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLBindParameter( + internal static extern /*SQLRETURN*/ODBC32.SQLRETURN SQLBindParameter( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/ushort ParameterNumber, /*SQLSMALLINT*/short ParamDirection, @@ -60,16 +60,16 @@ internal static partial class Odbc /*SQLLEN*/IntPtr BufferLength, /*SQLLEN* */HandleRef StrLen_or_Ind); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLCancel( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLCancel( /*SQLHSTMT*/OdbcStatementHandle StatementHandle); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLCloseCursor( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLCloseCursor( /*SQLHSTMT*/OdbcStatementHandle StatementHandle); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLColAttributeW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLColAttributeW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/short ColumnNumber, /*SQLUSMALLINT*/short FieldIdentifier, @@ -93,8 +93,8 @@ internal static partial class Odbc // SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute); // #endif - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLColumnsW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLColumnsW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLCHAR* */string CatalogName, /*SQLSMALLINT*/short NameLen1, @@ -105,12 +105,12 @@ internal static partial class Odbc /*SQLCHAR* */string ColumnName, /*SQLSMALLINT*/short NameLen4); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLDisconnect( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLDisconnect( /*SQLHDBC*/IntPtr ConnectionHandle); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLDriverConnectW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLDriverConnectW( /*SQLHDBC*/OdbcConnectionHandle hdbc, /*SQLHWND*/IntPtr hwnd, /*SQLCHAR* */string connectionstring, @@ -120,46 +120,46 @@ internal static partial class Odbc /*SQLSMALLINT* */out short cbConnectionstringout, /*SQLUSMALLINT*/short fDriverCompletion); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLEndTran( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLEndTran( /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, /*SQLHANDLE*/IntPtr Handle, /*SQLSMALLINT*/short CompletionType); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLExecDirectW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLExecDirectW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLCHAR* */string StatementText, /*SQLINTEGER*/int TextLength); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLExecute( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLExecute( /*SQLHSTMT*/OdbcStatementHandle StatementHandle); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLFetch( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLFetch( /*SQLHSTMT*/OdbcStatementHandle StatementHandle); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLFreeHandle( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLFreeHandle( /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, /*SQLHSTMT*/IntPtr StatementHandle); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLFreeStmt( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLFreeStmt( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/ODBC32.STMT Option); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetConnectAttrW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLGetConnectAttrW( /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle, /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, /*SQLPOINTER*/byte[] Value, /*SQLINTEGER*/int BufferLength, /*SQLINTEGER* */out int StringLength); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetData( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLGetData( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/ushort ColumnNumber, /*SQLSMALLINT*/ODBC32.SQL_C TargetType, @@ -167,8 +167,8 @@ internal static partial class Odbc /*SQLLEN*/IntPtr BufferLength, // sql.h differs from MSDN /*SQLLEN* */out IntPtr StrLen_or_Ind); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetDescFieldW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLGetDescFieldW( /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle, /*SQLUSMALLINT*/short RecNumber, /*SQLUSMALLINT*/ODBC32.SQL_DESC FieldIdentifier, @@ -177,7 +177,7 @@ internal static partial class Odbc /*SQLINTEGER* */out int StringLength); [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetDiagRecW( + internal static extern /*SQLRETURN*/ODBC32.SQLRETURN SQLGetDiagRecW( /*SQLSMALLINT*/ODBC32.SQL_HANDLE HandleType, /*SQLHANDLE*/OdbcHandle Handle, /*SQLSMALLINT*/short RecNumber, @@ -188,7 +188,7 @@ internal static partial class Odbc /*SQLSMALLINT* */out short TextLength); [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetDiagFieldW( + internal static extern /*SQLRETURN*/ODBC32.SQLRETURN SQLGetDiagFieldW( /*SQLSMALLINT*/ ODBC32.SQL_HANDLE HandleType, /*SQLHANDLE*/ OdbcHandle Handle, /*SQLSMALLINT*/ short RecNumber, @@ -197,58 +197,58 @@ internal static partial class Odbc /*SQLSMALLINT*/ short BufferLength, /*SQLSMALLINT* */ out short StringLength); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetFunctions( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLGetFunctions( /*SQLHBDC*/OdbcConnectionHandle hdbc, /*SQLUSMALLINT*/ODBC32.SQL_API fFunction, /*SQLUSMALLINT* */out short pfExists); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetInfoW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLGetInfoW( /*SQLHBDC*/OdbcConnectionHandle hdbc, /*SQLUSMALLINT*/ODBC32.SQL_INFO fInfoType, /*SQLPOINTER*/byte[] rgbInfoValue, /*SQLSMALLINT*/short cbInfoValueMax, /*SQLSMALLINT* */out short pcbInfoValue); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetInfoW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLGetInfoW( /*SQLHBDC*/OdbcConnectionHandle hdbc, /*SQLUSMALLINT*/ODBC32.SQL_INFO fInfoType, /*SQLPOINTER*/byte[] rgbInfoValue, /*SQLSMALLINT*/short cbInfoValueMax, /*SQLSMALLINT* */IntPtr pcbInfoValue); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetStmtAttrW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLGetStmtAttrW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, /*SQLPOINTER*/out IntPtr Value, /*SQLINTEGER*/int BufferLength, /*SQLINTEGER*/out int StringLength); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLGetTypeInfo( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLGetTypeInfo( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLSMALLINT*/short fSqlType); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLMoreResults( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLMoreResults( /*SQLHSTMT*/OdbcStatementHandle StatementHandle); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLNumResultCols( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLNumResultCols( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLSMALLINT* */out short ColumnCount); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLPrepareW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLPrepareW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLCHAR* */string StatementText, /*SQLINTEGER*/int TextLength); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLPrimaryKeysW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLPrimaryKeysW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLCHAR* */string? CatalogName, /*SQLSMALLINT*/short NameLen1, @@ -257,8 +257,8 @@ internal static partial class Odbc /*SQLCHAR* */string TableName, /*SQLSMALLINT*/short NameLen3); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLProcedureColumnsW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLProcedureColumnsW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLCHAR* */ string? CatalogName, /*SQLSMALLINT*/short NameLen1, @@ -269,8 +269,8 @@ internal static partial class Odbc /*SQLCHAR* */ string? ColumnName, /*SQLSMALLINT*/short NameLen4); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLProceduresW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLProceduresW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLCHAR* */ string CatalogName, /*SQLSMALLINT*/short NameLen1, @@ -279,72 +279,65 @@ internal static partial class Odbc /*SQLCHAR* */ string ProcName, /*SQLSMALLINT*/short NameLen3); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLRowCount( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLRowCount( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLLEN* */out IntPtr RowCount); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( - /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle, - /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, - /*SQLPOINTER*/System.Transactions.IDtcTransaction Value, - /*SQLINTEGER*/int StringLength); - - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLSetConnectAttrW( /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle, /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, /*SQLPOINTER*/string Value, /*SQLINTEGER*/int StringLength); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLSetConnectAttrW( /*SQLHBDC*/OdbcConnectionHandle ConnectionHandle, /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, /*SQLPOINTER*/IntPtr Value, /*SQLINTEGER*/int StringLength); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSetConnectAttrW( // used only for AutoCommitOn + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLSetConnectAttrW( // used only for AutoCommitOn /*SQLHBDC*/IntPtr ConnectionHandle, /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, /*SQLPOINTER*/IntPtr Value, /*SQLINTEGER*/int StringLength); [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSetDescFieldW( + internal static extern /*SQLRETURN*/ODBC32.SQLRETURN SQLSetDescFieldW( /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle, /*SQLSMALLINT*/short ColumnNumber, /*SQLSMALLINT*/ODBC32.SQL_DESC FieldIdentifier, /*SQLPOINTER*/HandleRef CharacterAttribute, /*SQLINTEGER*/int BufferLength); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSetDescFieldW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLSetDescFieldW( /*SQLHSTMT*/OdbcDescriptorHandle StatementHandle, /*SQLSMALLINT*/short ColumnNumber, /*SQLSMALLINT*/ODBC32.SQL_DESC FieldIdentifier, /*SQLPOINTER*/IntPtr CharacterAttribute, /*SQLINTEGER*/int BufferLength); - [DllImport(Interop.Libraries.Odbc32)] + [GeneratedDllImport(Interop.Libraries.Odbc32)] // user can set SQL_ATTR_CONNECTION_POOLING attribute with envHandle = null, this attribute is process-level attribute - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSetEnvAttr( + internal static partial ODBC32.SQLRETURN SQLSetEnvAttr( /*SQLHENV*/OdbcEnvironmentHandle EnvironmentHandle, /*SQLINTEGER*/ODBC32.SQL_ATTR Attribute, /*SQLPOINTER*/IntPtr Value, /*SQLINTEGER*/ODBC32.SQL_IS StringLength); - [DllImport(Interop.Libraries.Odbc32)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSetStmtAttrW( + [GeneratedDllImport(Interop.Libraries.Odbc32)] + internal static partial ODBC32.SQLRETURN SQLSetStmtAttrW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLINTEGER*/int Attribute, /*SQLPOINTER*/IntPtr Value, /*SQLINTEGER*/int StringLength); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLSpecialColumnsW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLSpecialColumnsW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLUSMALLINT*/ODBC32.SQL_SPECIALCOLS IdentifierType, /*SQLCHAR* */string? CatalogName, @@ -356,8 +349,8 @@ internal static partial class Odbc /*SQLUSMALLINT*/ODBC32.SQL_SCOPE Scope, /*SQLUSMALLINT*/ ODBC32.SQL_NULLABILITY Nullable); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLStatisticsW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLStatisticsW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLCHAR* */string? CatalogName, /*SQLSMALLINT*/short NameLen1, @@ -368,8 +361,8 @@ internal static partial class Odbc /*SQLUSMALLINT*/short Unique, /*SQLUSMALLINT*/short Reserved); - [DllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] - internal static extern /*SQLRETURN*/ODBC32.RetCode SQLTablesW( + [GeneratedDllImport(Interop.Libraries.Odbc32, CharSet = CharSet.Unicode)] + internal static partial ODBC32.SQLRETURN SQLTablesW( /*SQLHSTMT*/OdbcStatementHandle StatementHandle, /*SQLCHAR* */string CatalogName, /*SQLSMALLINT*/short NameLen1, diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libc.cs index 574faadcd1f4b..973dc0109842b 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.libc.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.libc.cs @@ -23,9 +23,11 @@ internal struct AttrList public const uint ATTR_CMN_CRTIME = 0x00000200; } +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time + // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like CULong) [DllImport(Libraries.libc, EntryPoint = "setattrlist", SetLastError = true)] - // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) internal static unsafe extern int setattrlist(string path, AttrList* attrList, void* attrBuf, nint attrBufSize, CULong options); +#pragma warning restore DLLIMPORTGENANALYZER015 internal const uint FSOPT_NOFOLLOW = 0x00000001; } diff --git a/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs b/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs index f21e6a623ad18..0752826b4eaf2 100644 --- a/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs +++ b/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Serial.cs @@ -10,14 +10,14 @@ internal static partial class Interop { internal static partial class Serial { - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_SerialPortOpen", SetLastError = true)] - internal static extern SafeSerialDeviceHandle SerialPortOpen(string name); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_SerialPortOpen", CharSet = CharSet.Ansi, SetLastError = true)] + internal static partial SafeSerialDeviceHandle SerialPortOpen(string name); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_SerialPortClose", SetLastError = true)] - internal static extern int SerialPortClose(IntPtr handle); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_SerialPortClose", SetLastError = true)] + internal static partial int SerialPortClose(IntPtr handle); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_Shutdown")] - internal static extern Error Shutdown(IntPtr socket, SocketShutdown how); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_Shutdown")] + internal static partial Error Shutdown(IntPtr socket, SocketShutdown how); /// /// Reads a number of bytes from an open file descriptor into a specified buffer. @@ -29,8 +29,8 @@ internal static partial class Serial /// Returns the number of bytes read on success; otherwise, -1 is returned /// Note - on fail. the position of the stream may change depending on the platform; consult man 2 read for more info /// - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_Read", SetLastError = true)] - internal static extern unsafe int Read(SafeHandle fd, byte* buffer, int count); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_Read", SetLastError = true)] + internal static unsafe partial int Read(SafeHandle fd, byte* buffer, int count); /// /// Writes the specified buffer to the provided open file descriptor @@ -41,8 +41,8 @@ internal static partial class Serial /// /// Returns the number of bytes written on success; otherwise, returns -1 and sets errno /// - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_Write", SetLastError = true)] - internal static extern unsafe int Write(SafeHandle fd, byte* buffer, int bufferSize); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_Write", SetLastError = true)] + internal static unsafe partial int Write(SafeHandle fd, byte* buffer, int bufferSize); /// /// Polls a set of file descriptors for signals and returns what signals have been set @@ -52,8 +52,8 @@ internal static partial class Serial /// The amount of time to wait; -1 for infinite, 0 for immediate return, and a positive number is the number of milliseconds /// The number of events triggered (i.e. the number of entries in pollEvents with a non-zero TriggeredEvents). May be zero in the event of a timeout. /// An error or Error.SUCCESS. - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_Poll")] - private static extern unsafe Error Poll(PollEvent* pollEvents, uint eventCount, int timeout, uint* triggered); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_Poll")] + private static unsafe partial Error Poll(PollEvent* pollEvents, uint eventCount, int timeout, uint* triggered); /// /// Polls a File Descriptor for the passed in flags. diff --git a/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Termios.cs b/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Termios.cs index a689c75b59876..ce98ffa9c856d 100644 --- a/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Termios.cs +++ b/src/libraries/Common/src/Interop/Unix/System.IO.Ports.Native/Interop.Termios.cs @@ -29,34 +29,34 @@ internal enum Queue SendQueue = 2, } - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosReset", SetLastError = true)] - internal static extern int TermiosReset(SafeSerialDeviceHandle handle, int speed, int data, StopBits stop, Parity parity, Handshake flow); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosReset", SetLastError = true)] + internal static partial int TermiosReset(SafeSerialDeviceHandle handle, int speed, int data, StopBits stop, Parity parity, Handshake flow); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosGetSignal", SetLastError = true)] - internal static extern int TermiosGetSignal(SafeSerialDeviceHandle handle, Signals signal); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosGetSignal", SetLastError = true)] + internal static partial int TermiosGetSignal(SafeSerialDeviceHandle handle, Signals signal); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosSetSignal", SetLastError = true)] - internal static extern int TermiosGetSignal(SafeSerialDeviceHandle handle, Signals signal, int set); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosSetSignal", SetLastError = true)] + internal static partial int TermiosGetSignal(SafeSerialDeviceHandle handle, Signals signal, int set); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosGetAllSignals")] - internal static extern Signals TermiosGetAllSignals(SafeSerialDeviceHandle handle); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosGetAllSignals")] + internal static partial Signals TermiosGetAllSignals(SafeSerialDeviceHandle handle); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosSetSpeed", SetLastError = true)] - internal static extern int TermiosSetSpeed(SafeSerialDeviceHandle handle, int speed); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosSetSpeed", SetLastError = true)] + internal static partial int TermiosSetSpeed(SafeSerialDeviceHandle handle, int speed); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosGetSpeed", SetLastError = true)] - internal static extern int TermiosGetSpeed(SafeSerialDeviceHandle handle); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosGetSpeed", SetLastError = true)] + internal static partial int TermiosGetSpeed(SafeSerialDeviceHandle handle); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosAvailableBytes", SetLastError = true)] - internal static extern int TermiosGetAvailableBytes(SafeSerialDeviceHandle handle, [MarshalAs(UnmanagedType.Bool)]bool fromReadBuffer); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosAvailableBytes", SetLastError = true)] + internal static partial int TermiosGetAvailableBytes(SafeSerialDeviceHandle handle, [MarshalAs(UnmanagedType.Bool)]bool fromReadBuffer); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosDiscard", SetLastError = true)] - internal static extern int TermiosDiscard(SafeSerialDeviceHandle handle, Queue input); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosDiscard", SetLastError = true)] + internal static partial int TermiosDiscard(SafeSerialDeviceHandle handle, Queue input); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosDrain", SetLastError = true)] - internal static extern int TermiosDrain(SafeSerialDeviceHandle handle); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosDrain", SetLastError = true)] + internal static partial int TermiosDrain(SafeSerialDeviceHandle handle); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosSendBreak", SetLastError = true)] - internal static extern int TermiosSendBreak(SafeSerialDeviceHandle handle, int duration); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_TermiosSendBreak", SetLastError = true)] + internal static partial int TermiosSendBreak(SafeSerialDeviceHandle handle, int duration); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CloseServiceHandle.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CloseServiceHandle.cs index d1103c58f8526..0ae607c6d3581 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CloseServiceHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.CloseServiceHandle.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool CloseServiceHandle(IntPtr handle); + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + internal static partial bool CloseServiceHandle(IntPtr handle); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ControlService.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ControlService.cs index 4b74a032ad124..7a69515f2c8f5 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ControlService.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ControlService.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe bool ControlService(SafeServiceHandle serviceHandle, int control, SERVICE_STATUS* pStatus); + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + internal static unsafe partial bool ControlService(SafeServiceHandle serviceHandle, int control, SERVICE_STATUS* pStatus); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs index e5112e3d52570..bcff544236ba7 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumDependentServices.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, EntryPoint = "EnumDependentServicesW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool EnumDependentServices( + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EnumDependentServicesW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + internal static partial bool EnumDependentServices( SafeServiceHandle serviceHandle, int serviceState, IntPtr bufferOfENUM_SERVICE_STATUS, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs index d8ad4ae03014e..d51170a25890d 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EnumServicesStatusEx.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, EntryPoint = "EnumServicesStatusExW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool EnumServicesStatusEx( + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EnumServicesStatusExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + internal static partial bool EnumServicesStatusEx( SafeServiceHandle databaseHandle, int infolevel, int serviceType, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs index f43a53d338fad..9490c198b02d3 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs @@ -8,8 +8,10 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, ExactSpelling = true)] +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) + [DllImport(Libraries.Advapi32, ExactSpelling = true)] internal static extern int EventActivityIdControl(ActivityControl ControlCode, ref Guid ActivityId); +#pragma warning restore DLLIMPORTGENANALYZER015 } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs index 99660f1f2ba62..1cc64001df471 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs @@ -8,12 +8,14 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, ExactSpelling = true)] +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) + [DllImport(Libraries.Advapi32, ExactSpelling = true)] internal static unsafe extern uint EventRegister( in Guid providerId, EtwEnableCallback enableCallback, void* callbackContext, ref long registrationHandle); +#pragma warning restore DLLIMPORTGENANALYZER015 } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs index c69084f20f83b..d1444792c2043 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceDisplayName.cs @@ -12,7 +12,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, EntryPoint = "GetServiceDisplayNameW", CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true)] - internal static extern unsafe bool GetServiceDisplayName(SafeServiceHandle? SCMHandle, string serviceName, char* displayName, ref int displayNameLength); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetServiceDisplayNameW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial bool GetServiceDisplayName(SafeServiceHandle? SCMHandle, string serviceName, char* displayName, ref int displayNameLength); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs index 90169a489766a..f7f83fea049a8 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetServiceKeyName.cs @@ -12,7 +12,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, EntryPoint = "GetServiceKeyNameW", CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true)] - internal static extern unsafe bool GetServiceKeyName(SafeServiceHandle? SCMHandle, string displayName, char* KeyName, ref int KeyNameLength); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetServiceKeyNameW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + internal static unsafe partial bool GetServiceKeyName(SafeServiceHandle? SCMHandle, string displayName, char* KeyName, ref int KeyNameLength); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs index 4d661e0870ec6..190aefa961b12 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenSCManager.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, EntryPoint = "OpenSCManagerW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern IntPtr OpenSCManager(string? machineName, string? databaseName, int access); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "OpenSCManagerW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + internal static partial IntPtr OpenSCManager(string? machineName, string? databaseName, int access); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs index 23a432f12cc0a..47544bc29ad6c 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.OpenService.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, EntryPoint = "OpenServiceW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern IntPtr OpenService(SafeServiceHandle? databaseHandle, string serviceName, int access); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "OpenServiceW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + internal static partial IntPtr OpenService(SafeServiceHandle? databaseHandle, string serviceName, int access); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs index f3e99c1a69c74..cf734863ab8a2 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceConfig.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, EntryPoint = "QueryServiceConfigW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool QueryServiceConfig(SafeServiceHandle serviceHandle, IntPtr queryServiceConfigPtr, int bufferSize, out int bytesNeeded); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "QueryServiceConfigW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + internal static partial bool QueryServiceConfig(SafeServiceHandle serviceHandle, IntPtr queryServiceConfigPtr, int bufferSize, out int bytesNeeded); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceStatus.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceStatus.cs index 19003e0e3982c..e29caaaf966db 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceStatus.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.QueryServiceStatus.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern unsafe bool QueryServiceStatus(SafeServiceHandle serviceHandle, SERVICE_STATUS* pStatus); + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + internal static unsafe partial bool QueryServiceStatus(SafeServiceHandle serviceHandle, SERVICE_STATUS* pStatus); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs index ea198bd4d6e74..b7bbaeb583361 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegisterServiceCtrlHandlerEx.cs @@ -10,7 +10,7 @@ internal static partial class Advapi32 { public delegate int ServiceControlCallbackEx(int control, int eventType, IntPtr eventData, IntPtr eventContext); - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern IntPtr RegisterServiceCtrlHandlerEx(string? serviceName, ServiceControlCallbackEx? callback, IntPtr userData); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegisterServiceCtrlHandlerExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + public static partial IntPtr RegisterServiceCtrlHandlerEx(string? serviceName, ServiceControlCallbackEx? callback, IntPtr userData); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetServiceStatus.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetServiceStatus.cs index 78d53da1697ab..300cedcf611f5 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetServiceStatus.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.SetServiceStatus.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern unsafe bool SetServiceStatus(IntPtr serviceStatusHandle, SERVICE_STATUS* status); + [GeneratedDllImport(Libraries.Advapi32, SetLastError = true)] + public static unsafe partial bool SetServiceStatus(IntPtr serviceStatusHandle, SERVICE_STATUS* status); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs index d56a472d92537..a3ac3631a865d 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartService.cs @@ -9,7 +9,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, EntryPoint = "StartServiceW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern bool StartService(SafeServiceHandle serviceHandle, int argNum, IntPtr argPtrs); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "StartServiceW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + internal static partial bool StartService(SafeServiceHandle serviceHandle, int argNum, IntPtr argPtrs); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs index 6a9f9f66e0c35..e307b36d8c081 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.StartServiceCtrlDispatcher.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Advapi32 { - [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)] - public static extern bool StartServiceCtrlDispatcher(IntPtr entry); + [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "StartServiceCtrlDispatcherW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + public static partial bool StartServiceCtrlDispatcher(IntPtr entry); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.COMMPROP.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.COMMPROP.cs index 8084c8a390a99..1b8d20024eadd 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.COMMPROP.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.COMMPROP.cs @@ -33,7 +33,7 @@ internal struct COMMPROP public int dwCurrentRxQueue; public int dwProvSpec1; public int dwProvSpec2; - public char wcProvChar; + public ushort /*char*/ wcProvChar; } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommBreak.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommBreak.cs index 19602498de13e..df293dec69cac 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommBreak.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommBreak.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool ClearCommBreak( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool ClearCommBreak( SafeFileHandle hFile); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommError.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommError.cs index 8d4c5d1e6c789..1d9806610ae14 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommError.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ClearCommError.cs @@ -9,14 +9,14 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool ClearCommError( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool ClearCommError( SafeFileHandle hFile, ref int lpErrors, ref COMSTAT lpStat); - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool ClearCommError( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool ClearCommError( SafeFileHandle hFile, ref int lpErrors, IntPtr lpStat); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EscapeCommFunction.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EscapeCommFunction.cs index ffd536c369186..7c55043ebb191 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EscapeCommFunction.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EscapeCommFunction.cs @@ -16,8 +16,8 @@ internal static class CommFunctions internal const int CLRDTR = 6; } - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool EscapeCommFunction( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool EscapeCommFunction( SafeFileHandle hFile, int dwFunc); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommModemStatus.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommModemStatus.cs index b0fdff93dc07a..c0d6cf9ffc17d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommModemStatus.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommModemStatus.cs @@ -15,8 +15,8 @@ internal static class CommModemState internal const int MS_RLSD_ON = 0x80; } - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool GetCommModemStatus( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool GetCommModemStatus( SafeFileHandle hFile, ref int lpModemStat); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommProperties.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommProperties.cs index c06d2a28b2c7e..6d49331ec5eb3 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommProperties.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommProperties.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool GetCommProperties( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool GetCommProperties( SafeFileHandle hFile, ref COMMPROP lpCommProp); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommState.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommState.cs index 09b81af4229d2..45f54872edb6b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommState.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCommState.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool GetCommState( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool GetCommState( SafeFileHandle hFile, ref DCB lpDCB); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PurgeComm.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PurgeComm.cs index 9a71eececb637..be4311eb4f9a1 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PurgeComm.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.PurgeComm.cs @@ -16,8 +16,8 @@ internal static class PurgeFlags internal const uint PURGE_RXCLEAR = 0x0008; // Kill the typeahead buffer if there. } - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool PurgeComm( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool PurgeComm( SafeFileHandle hFile, uint dwFlags); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommBreak.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommBreak.cs index 609b8ac46074f..0d33f40e01d0b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommBreak.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommBreak.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool SetCommBreak( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetCommBreak( SafeFileHandle hFile); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommMask.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommMask.cs index dcf7475ed73df..0fc9bb0d86941 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommMask.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommMask.cs @@ -15,8 +15,8 @@ internal static class CommEvents internal const int ALL_EVENTS = 0x1fb; } - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool SetCommMask( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetCommMask( SafeFileHandle hFile, int dwEvtMask ); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommState.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommState.cs index 135627e0ecac5..ae985844e888e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommState.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommState.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool SetCommState( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetCommState( SafeFileHandle hFile, ref DCB lpDCB); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommTimeouts.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommTimeouts.cs index 2ca02d02d4e42..affa70385442e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommTimeouts.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCommTimeouts.cs @@ -10,8 +10,8 @@ internal static partial class Kernel32 { internal const int MAXDWORD = -1; // This is 0xfffffff, or UInt32.MaxValue, here used as an int - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool SetCommTimeouts( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetCommTimeouts( SafeFileHandle hFile, ref COMMTIMEOUTS lpCommTimeouts); } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetupComm.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetupComm.cs index b36db5959bc5b..331292c4a6dcd 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetupComm.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetupComm.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern bool SetupComm( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetupComm( SafeFileHandle hFile, int dwInQueue, int dwOutQueue); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitCommEvent.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitCommEvent.cs index e9328f34beb97..ec4418d5e5000 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitCommEvent.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitCommEvent.cs @@ -9,8 +9,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)] - internal static extern unsafe bool WaitCommEvent( + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static unsafe partial bool WaitCommEvent( SafeFileHandle hFile, int* lpEvtMask, NativeOverlapped* lpOverlapped); diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs index e5769df6bf41f..fec2251f01e18 100644 --- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs +++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs @@ -8,8 +8,10 @@ internal static partial class Interop { internal static partial class Ole32 { - [DllImport(Interop.Libraries.Ole32, CharSet = CharSet.Unicode)] +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) + [DllImport(Interop.Libraries.Ole32, CharSet = CharSet.Unicode)] internal static extern int CLSIDFromProgID(string lpszProgID, out Guid lpclsid); +#pragma warning restore DLLIMPORTGENANALYZER015 } } diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs index 89dc423e96b78..f79f17e3ec637 100644 --- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs +++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs @@ -8,8 +8,10 @@ internal static partial class Interop { internal static partial class Ole32 { - [DllImport(Interop.Libraries.Ole32)] +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) + [DllImport(Interop.Libraries.Ole32)] internal static extern int CoCreateGuid(out Guid guid); +#pragma warning restore DLLIMPORTGENANALYZER015 } } diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs index 2d5a1661771e4..62bd304aa73f5 100644 --- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs +++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs @@ -8,8 +8,10 @@ internal static partial class Interop { internal static partial class Ole32 { - [DllImport(Interop.Libraries.Ole32)] +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) + [DllImport(Interop.Libraries.Ole32)] internal static extern int CoGetStandardMarshal(ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags, out IntPtr ppMarshal); +#pragma warning restore DLLIMPORTGENANALYZER015 } } diff --git a/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs b/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs index ce978ad6fab1a..1d266d08596ff 100644 --- a/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs +++ b/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs @@ -53,6 +53,7 @@ internal struct PerfCounterSetInstanceStruct internal uint InstanceNameSize; } +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) [DllImport(Libraries.Advapi32, ExactSpelling = true)] internal static extern uint PerfStartProvider( @@ -69,6 +70,7 @@ out SafePerfProviderHandle phProvider string szInstanceName, uint dwInstance ); +#pragma warning restore DLLIMPORTGENANALYZER015 [GeneratedDllImport(Libraries.Advapi32, ExactSpelling = true)] internal static unsafe partial uint PerfSetCounterSetInfo( diff --git a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs index 9dad160932bd7..5b3eaba1d14c4 100644 --- a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs +++ b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs @@ -10,14 +10,16 @@ internal static partial class Shell32 { internal const int COR_E_PLATFORMNOTSUPPORTED = unchecked((int)0x80131539); +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time // https://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx - [DllImport(Libraries.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = false)] // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) + [DllImport(Libraries.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = false)] internal static extern int SHGetKnownFolderPath( [MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out string ppszPath); +#pragma warning restore DLLIMPORTGENANALYZER015 // https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457.aspx internal static class KnownFolders diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs index c22ae17d4edb4..f555727442ae7 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs @@ -475,6 +475,7 @@ internal static partial SECURITY_STATUS SspiEncodeStringsAsAuthIdentity( string password, out SafeSspiAuthDataHandle authData); +#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid) [DllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] internal static extern SECURITY_STATUS SetCredentialsAttributesW( @@ -482,5 +483,6 @@ internal static extern SECURITY_STATUS SetCredentialsAttributesW( long ulAttribute, in SecPkgCred_ClientCertPolicy pBuffer, long cbBuffer); +#pragma warning restore DLLIMPORTGENANALYZER015 } } diff --git a/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj b/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj index 738028b8dcd6f..9cc4d09bf298b 100644 --- a/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj +++ b/src/libraries/System.Data.Odbc/src/System.Data.Odbc.csproj @@ -3,6 +3,8 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-FreeBSD;$(NetCoreAppCurrent)-illumos;$(NetCoreAppCurrent)-Solaris;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum)-FreeBSD;$(NetCoreAppMinimum)-Linux;$(NetCoreAppMinimum)-OSX;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) $(NoWarn);CA2249;CA1838 + + $(NoWarn);CA1845 enable true Provides a collection of classes used to access an ODBC data source in the managed space @@ -145,6 +147,7 @@ System.Data.Odbc.OdbcTransaction + @@ -158,6 +161,7 @@ System.Data.Odbc.OdbcTransaction + diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs index 6c326926ba576..0eefd1d2cdb85 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/Odbc32.cs @@ -90,15 +90,15 @@ internal static Exception CantSetPropertyOnOpenConnection() { return ADP.InvalidOperation(SR.GetString(SR.Odbc_CantSetPropertyOnOpenConnection)); } - internal static Exception CantEnableConnectionpooling(ODBC32.RetCode retcode) + internal static Exception CantEnableConnectionpooling(ODBC32.SQLRETURN retcode) { return ADP.DataAdapter(SR.GetString(SR.Odbc_CantEnableConnectionpooling, ODBC32.RetcodeToString(retcode))); } - internal static Exception CantAllocateEnvironmentHandle(ODBC32.RetCode retcode) + internal static Exception CantAllocateEnvironmentHandle(ODBC32.SQLRETURN retcode) { return ADP.DataAdapter(SR.GetString(SR.Odbc_CantAllocateEnvironmentHandle, ODBC32.RetcodeToString(retcode))); } - internal static Exception FailedToGetDescriptorHandle(ODBC32.RetCode retcode) + internal static Exception FailedToGetDescriptorHandle(ODBC32.SQLRETURN retcode) { return ADP.DataAdapter(SR.GetString(SR.Odbc_FailedToGetDescriptorHandle, ODBC32.RetcodeToString(retcode))); } @@ -112,7 +112,7 @@ internal static Exception UnknownOdbcType(OdbcType odbctype) } internal const string Pwd = "pwd"; - internal static void TraceODBC(int level, string method, ODBC32.RetCode retcode) + internal static void TraceODBC(int level, string method, ODBC32.SQLRETURN retcode) { } @@ -133,7 +133,7 @@ internal enum SQL_HANDLE : short } // must be public because it is serialized by OdbcException - internal enum RetCode : short + internal enum SQLRETURN : short { SUCCESS = 0, SUCCESS_WITH_INFO = 1, @@ -142,18 +142,18 @@ internal enum RetCode : short NO_DATA = 100, } - internal static string RetcodeToString(RetCode retcode) + internal static string RetcodeToString(SQLRETURN retcode) { switch (retcode) { - case RetCode.SUCCESS: return "SUCCESS"; - case RetCode.SUCCESS_WITH_INFO: return "SUCCESS_WITH_INFO"; - case RetCode.ERROR: return "ERROR"; - case RetCode.INVALID_HANDLE: return "INVALID_HANDLE"; - case RetCode.NO_DATA: return "NO_DATA"; + case SQLRETURN.SUCCESS: return "SUCCESS"; + case SQLRETURN.SUCCESS_WITH_INFO: return "SUCCESS_WITH_INFO"; + case SQLRETURN.ERROR: return "ERROR"; + case SQLRETURN.INVALID_HANDLE: return "INVALID_HANDLE"; + case SQLRETURN.NO_DATA: return "NO_DATA"; default: Debug.Fail("Unknown enumerator passed to RetcodeToString method"); - goto case RetCode.ERROR; + goto case SQLRETURN.ERROR; } } @@ -716,17 +716,17 @@ internal enum SQL_SPECIALCOLUMNSET : short internal const short SQL_RESULT_COL = 3; // Helpers - internal static OdbcErrorCollection GetDiagErrors(string? source, OdbcHandle hrHandle, RetCode retcode) + internal static OdbcErrorCollection GetDiagErrors(string? source, OdbcHandle hrHandle, SQLRETURN retcode) { OdbcErrorCollection errors = new OdbcErrorCollection(); GetDiagErrors(errors, source, hrHandle, retcode); return errors; } - internal static void GetDiagErrors(OdbcErrorCollection errors, string? source, OdbcHandle hrHandle, RetCode retcode) + internal static void GetDiagErrors(OdbcErrorCollection errors, string? source, OdbcHandle hrHandle, SQLRETURN retcode) { - Debug.Assert(retcode != ODBC32.RetCode.INVALID_HANDLE, "retcode must never be ODBC32.RetCode.INVALID_HANDLE"); - if (RetCode.SUCCESS != retcode) + Debug.Assert(retcode != ODBC32.SQLRETURN.INVALID_HANDLE, "retcode must never be ODBC32.RetCode.INVALID_HANDLE"); + if (SQLRETURN.SUCCESS != retcode) { int NativeError; short iRec = 0; @@ -740,7 +740,7 @@ internal static void GetDiagErrors(OdbcErrorCollection errors, string? source, O ++iRec; retcode = hrHandle.GetDiagnosticRecord(iRec, out sqlState, message, out NativeError, out cchActual); - if ((RetCode.SUCCESS_WITH_INFO == retcode) && (message.Capacity - 1 < cchActual)) + if ((SQLRETURN.SUCCESS_WITH_INFO == retcode) && (message.Capacity - 1 < cchActual)) { message.Capacity = cchActual + 1; retcode = hrHandle.GetDiagnosticRecord(iRec, out sqlState, message, out NativeError, out cchActual); @@ -748,7 +748,7 @@ internal static void GetDiagErrors(OdbcErrorCollection errors, string? source, O //Note: SUCCESS_WITH_INFO from SQLGetDiagRec would be because //the buffer is not large enough for the error string. - moreerrors = (retcode == RetCode.SUCCESS || retcode == RetCode.SUCCESS_WITH_INFO); + moreerrors = (retcode == SQLRETURN.SUCCESS || retcode == SQLRETURN.SUCCESS_WITH_INFO); if (moreerrors) { //Sets up the InnerException as well... diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommand.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommand.cs index eb77a4c8c1951..749c45d7f50ff 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommand.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommand.cs @@ -449,13 +449,13 @@ public override void Cancel() lock (stmt) { // Cancel the statement - ODBC32.RetCode retcode = stmt.Cancel(); + ODBC32.SQLRETURN retcode = stmt.Cancel(); // copy of StatementErrorHandler, because stmt may become null switch (retcode) { - case ODBC32.RetCode.SUCCESS: - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: // don't fire info message events on cancel break; default: @@ -602,7 +602,7 @@ private OdbcDataReader ExecuteReaderObject(CommandBehavior behavior, behavior |= CommandBehavior.SingleResult; } - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; OdbcStatementHandle stmt = GetStatementHandle().StatementHandle!; _cmdWrapper!.Canceling = false; @@ -674,7 +674,7 @@ private OdbcDataReader ExecuteReaderObject(CommandBehavior behavior, { retcode = stmt.Prepare(CommandText); - if (ODBC32.RetCode.SUCCESS != retcode) + if (ODBC32.SQLRETURN.SUCCESS != retcode) { _connection!.HandleError(stmt, retcode); } @@ -721,14 +721,14 @@ private OdbcDataReader ExecuteReaderObject(CommandBehavior behavior, { short cColsAffected; retcode = stmt.NumberOfResultColumns(out cColsAffected); - if (retcode == ODBC32.RetCode.SUCCESS || retcode == ODBC32.RetCode.SUCCESS_WITH_INFO) + if (retcode == ODBC32.SQLRETURN.SUCCESS || retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO) { if (cColsAffected > 0) { localReader.GetSchemaTable(); } } - else if (retcode == ODBC32.RetCode.NO_DATA) + else if (retcode == ODBC32.SQLRETURN.NO_DATA) { // do nothing } @@ -807,7 +807,7 @@ private OdbcDataReader ExecuteReaderObject(CommandBehavior behavior, } //Note: Execute will return NO_DATA for Update/Delete non-row returning queries - if ((ODBC32.RetCode.SUCCESS != retcode) && (ODBC32.RetCode.NO_DATA != retcode)) + if ((ODBC32.SQLRETURN.SUCCESS != retcode) && (ODBC32.SQLRETURN.NO_DATA != retcode)) { _connection!.HandleError(stmt, retcode); } @@ -890,7 +890,7 @@ private void PropertyChanging() // public override void Prepare() { - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; ValidateOpenConnection(ADP.Prepare); @@ -912,7 +912,7 @@ public override void Prepare() retcode = stmt.Prepare(CommandText); - if (ODBC32.RetCode.SUCCESS != retcode) + if (ODBC32.SQLRETURN.SUCCESS != retcode) { _connection.HandleError(stmt, retcode); } @@ -923,12 +923,12 @@ public override void Prepare() private void TrySetStatementAttribute(OdbcStatementHandle stmt, ODBC32.SQL_ATTR stmtAttribute, IntPtr value) { - ODBC32.RetCode retcode = stmt.SetStatementAttribute( + ODBC32.SQLRETURN retcode = stmt.SetStatementAttribute( stmtAttribute, value, ODBC32.SQL_IS.UINTEGER); - if (retcode == ODBC32.RetCode.ERROR) + if (retcode == ODBC32.SQLRETURN.ERROR) { string sqlState; stmt.GetDiagnosticField(out sqlState); @@ -1112,7 +1112,7 @@ internal void FreeStatementHandle(ODBC32.STMT stmt) { try { - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; retcode = handle.FreeStatement(stmt); StatementErrorHandler(retcode); } @@ -1172,12 +1172,12 @@ internal string GetDiagSqlState() return sqlstate; } - internal void StatementErrorHandler(ODBC32.RetCode retcode) + internal void StatementErrorHandler(ODBC32.SQLRETURN retcode) { switch (retcode) { - case ODBC32.RetCode.SUCCESS: - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: _connection.HandleErrorNoThrow(_stmt!, retcode); break; default: diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommandBuilder.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommandBuilder.cs index 55a1fd1c208ee..b9227c6102626 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommandBuilder.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcCommandBuilder.cs @@ -182,12 +182,12 @@ private static OdbcParameter[] DeriveParametersFromStoredProcedure(OdbcConnectio parts[3] = command.CommandText; } // note: native odbc appears to ignore all but the procedure name - ODBC32.RetCode retcode = hstmt.ProcedureColumns(parts[1], parts[2], parts[3], null); + ODBC32.SQLRETURN retcode = hstmt.ProcedureColumns(parts[1], parts[2], parts[3], null); // Note: the driver does not return an error if the given stored procedure does not exist // therefore we cannot handle that case and just return not parameters. - if (ODBC32.RetCode.SUCCESS != retcode) + if (ODBC32.SQLRETURN.SUCCESS != retcode) { connection.HandleError(hstmt, retcode); } diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs index 2444a8377503a..5c5f3e3a2c059 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnection.cs @@ -385,7 +385,7 @@ internal string GetConnectAttrString(ODBC32.SQL_ATTR attribute) OdbcConnectionHandle? connectionHandle = ConnectionHandle; if (null != connectionHandle) { - ODBC32.RetCode retcode = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual); + ODBC32.SQLRETURN retcode = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual); if (buffer.Length + 2 <= cbActual) { // 2 bytes for unicode null-termination character @@ -393,11 +393,11 @@ internal string GetConnectAttrString(ODBC32.SQL_ATTR attribute) buffer = new byte[cbActual + 2]; retcode = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual); } - if ((ODBC32.RetCode.SUCCESS == retcode) || (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode)) + if ((ODBC32.SQLRETURN.SUCCESS == retcode) || (ODBC32.SQLRETURN.SUCCESS_WITH_INFO == retcode)) { value = (BitConverter.IsLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode).GetString(buffer, 0, Math.Min(cbActual, buffer.Length)); } - else if (retcode == ODBC32.RetCode.ERROR) + else if (retcode == ODBC32.SQLRETURN.ERROR) { string sqlstate = GetDiagSqlState(); if (("HYC00" == sqlstate) || ("HY092" == sqlstate) || ("IM001" == sqlstate)) @@ -418,15 +418,15 @@ internal int GetConnectAttr(ODBC32.SQL_ATTR attribute, ODBC32.HANDLER handler) OdbcConnectionHandle? connectionHandle = ConnectionHandle; if (null != connectionHandle) { - ODBC32.RetCode retcode = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual); + ODBC32.SQLRETURN retcode = connectionHandle.GetConnectionAttribute(attribute, buffer, out cbActual); - if ((ODBC32.RetCode.SUCCESS == retcode) || (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode)) + if ((ODBC32.SQLRETURN.SUCCESS == retcode) || (ODBC32.SQLRETURN.SUCCESS_WITH_INFO == retcode)) { retval = BitConverter.ToInt32(buffer, 0); } else { - if (retcode == ODBC32.RetCode.ERROR) + if (retcode == ODBC32.SQLRETURN.ERROR) { string sqlstate = GetDiagSqlState(); if (("HYC00" == sqlstate) || ("HY092" == sqlstate) || ("IM001" == sqlstate)) @@ -451,18 +451,18 @@ private string GetDiagSqlState() return sqlstate; } - internal ODBC32.RetCode GetInfoInt16Unhandled(ODBC32.SQL_INFO info, out short resultValue) + internal ODBC32.SQLRETURN GetInfoInt16Unhandled(ODBC32.SQL_INFO info, out short resultValue) { byte[] buffer = new byte[2]; - ODBC32.RetCode retcode = ConnectionHandle!.GetInfo1(info, buffer); + ODBC32.SQLRETURN retcode = ConnectionHandle!.GetInfo1(info, buffer); resultValue = BitConverter.ToInt16(buffer, 0); return retcode; } - internal ODBC32.RetCode GetInfoInt32Unhandled(ODBC32.SQL_INFO info, out int resultValue) + internal ODBC32.SQLRETURN GetInfoInt32Unhandled(ODBC32.SQL_INFO info, out int resultValue) { byte[] buffer = new byte[4]; - ODBC32.RetCode retcode = ConnectionHandle!.GetInfo1(info, buffer); + ODBC32.SQLRETURN retcode = ConnectionHandle!.GetInfo1(info, buffer); resultValue = BitConverter.ToInt32(buffer, 0); return retcode; } @@ -488,7 +488,7 @@ private int GetInfoInt32Unhandled(ODBC32.SQL_INFO infotype) OdbcConnectionHandle? connectionHandle = ConnectionHandle; if (null != connectionHandle) { - ODBC32.RetCode retcode = connectionHandle.GetInfo2(info, buffer, out cbActual); + ODBC32.SQLRETURN retcode = connectionHandle.GetInfo2(info, buffer, out cbActual); if (buffer.Length < cbActual - 2) { // 2 bytes for unicode null-termination character @@ -496,7 +496,7 @@ private int GetInfoInt32Unhandled(ODBC32.SQL_INFO infotype) buffer = new byte[cbActual + 2]; retcode = connectionHandle.GetInfo2(info, buffer, out cbActual); } - if (retcode == ODBC32.RetCode.SUCCESS || retcode == ODBC32.RetCode.SUCCESS_WITH_INFO) + if (retcode == ODBC32.SQLRETURN.SUCCESS || retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO) { value = (BitConverter.IsLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode).GetString(buffer, 0, Math.Min(cbActual, buffer.Length)); } @@ -513,15 +513,15 @@ private int GetInfoInt32Unhandled(ODBC32.SQL_INFO infotype) } // non-throwing HandleError - internal Exception? HandleErrorNoThrow(OdbcHandle hrHandle, ODBC32.RetCode retcode) + internal Exception? HandleErrorNoThrow(OdbcHandle hrHandle, ODBC32.SQLRETURN retcode) { - Debug.Assert(retcode != ODBC32.RetCode.INVALID_HANDLE, "retcode must never be ODBC32.RetCode.INVALID_HANDLE"); + Debug.Assert(retcode != ODBC32.SQLRETURN.INVALID_HANDLE, "retcode must never be ODBC32.RetCode.INVALID_HANDLE"); switch (retcode) { - case ODBC32.RetCode.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS: break; - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: { //Optimize to only create the event objects and obtain error info if //the user is really interested in retriveing the events... @@ -545,13 +545,13 @@ private int GetInfoInt32Unhandled(ODBC32.SQL_INFO infotype) return null; } - internal void HandleError(OdbcHandle hrHandle, ODBC32.RetCode retcode) + internal void HandleError(OdbcHandle hrHandle, ODBC32.SQLRETURN retcode) { Exception? e = HandleErrorNoThrow(hrHandle, retcode); switch (retcode) { - case ODBC32.RetCode.SUCCESS: - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: Debug.Assert(null == e, "success exception"); break; default: @@ -778,7 +778,7 @@ internal void FlagUnsupportedColAttr(ODBC32.SQL_DESC v3FieldId, ODBC32.SQL_COLUM internal bool SQLGetFunctions(ODBC32.SQL_API odbcFunction) { //SQLGetFunctions - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; short fExists; Debug.Assert((short)odbcFunction != 0, "SQL_API_ALL_FUNCTIONS is not supported"); OdbcConnectionHandle? connectionHandle = ConnectionHandle; @@ -792,7 +792,7 @@ internal bool SQLGetFunctions(ODBC32.SQL_API odbcFunction) throw ODBC.ConnectionClosed(); } - if (retcode != ODBC32.RetCode.SUCCESS) + if (retcode != ODBC32.SQLRETURN.SUCCESS) this.HandleError(connectionHandle, retcode); if (fExists == 0) @@ -925,8 +925,8 @@ internal OdbcTransaction Open_BeginTransaction(IsolationLevel isolevel) //Start the transaction OdbcConnectionHandle connectionHandle = ConnectionHandle!; - ODBC32.RetCode retcode = connectionHandle.BeginTransaction(ref isolevel); - if (retcode == ODBC32.RetCode.ERROR) + ODBC32.SQLRETURN retcode = connectionHandle.BeginTransaction(ref isolevel); + if (retcode == ODBC32.SQLRETURN.ERROR) { HandleError(connectionHandle, retcode); } @@ -952,9 +952,9 @@ internal void Open_ChangeDatabase(string value) //Set the database OdbcConnectionHandle connectionHandle = ConnectionHandle!; - ODBC32.RetCode retcode = connectionHandle.SetConnectionAttribute3(ODBC32.SQL_ATTR.CURRENT_CATALOG, value, checked((int)value.Length * 2)); + ODBC32.SQLRETURN retcode = connectionHandle.SetConnectionAttribute3(ODBC32.SQL_ATTR.CURRENT_CATALOG, value, checked((int)value.Length * 2)); - if (retcode != ODBC32.RetCode.SUCCESS) + if (retcode != ODBC32.SQLRETURN.SUCCESS) { HandleError(connectionHandle, retcode); } diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionHandle.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionHandle.cs index 8339b330196f6..c23159d34b0b7 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionHandle.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcConnectionHandle.cs @@ -33,7 +33,7 @@ internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString co throw ADP.ArgumentNull(nameof(constr)); } - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; //Set connection timeout (only before open). //Note: We use login timeout since its odbc 1.0 option, instead of using @@ -53,9 +53,9 @@ internal OdbcConnectionHandle(OdbcConnection connection, OdbcConnectionString co connection.HandleError(this, retcode); } - private ODBC32.RetCode AutoCommitOff() + private ODBC32.SQLRETURN AutoCommitOff() { - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; Debug.Assert(HandleState.Connected <= _handleState, "AutoCommitOff while in wrong state?"); @@ -66,8 +66,8 @@ private ODBC32.RetCode AutoCommitOff() retcode = Interop.Odbc.SQLSetConnectAttrW(this, ODBC32.SQL_ATTR.AUTOCOMMIT, ODBC32.SQL_AUTOCOMMIT_OFF, (int)ODBC32.SQL_IS.UINTEGER); switch (retcode) { - case ODBC32.RetCode.SUCCESS: - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: _handleState = HandleState.Transacted; break; } @@ -76,9 +76,9 @@ private ODBC32.RetCode AutoCommitOff() return retcode; } - internal ODBC32.RetCode BeginTransaction(ref IsolationLevel isolevel) + internal ODBC32.SQLRETURN BeginTransaction(ref IsolationLevel isolevel) { - ODBC32.RetCode retcode = ODBC32.RetCode.SUCCESS; + ODBC32.SQLRETURN retcode = ODBC32.SQLRETURN.SUCCESS; ODBC32.SQL_ATTR isolationAttribute; if (IsolationLevel.Unspecified != isolevel) { @@ -120,7 +120,7 @@ internal ODBC32.RetCode BeginTransaction(ref IsolationLevel isolevel) //the value if th euser asks for it... //We also still propagate the info, since it could be other info as well... - if (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode) + if (ODBC32.SQLRETURN.SUCCESS_WITH_INFO == retcode) { isolevel = IsolationLevel.Unspecified; } @@ -128,8 +128,8 @@ internal ODBC32.RetCode BeginTransaction(ref IsolationLevel isolevel) switch (retcode) { - case ODBC32.RetCode.SUCCESS: - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: //Turn off auto-commit (which basically starts the transaction) retcode = AutoCommitOff(); _handleState = HandleState.TransactionInProgress; @@ -138,14 +138,14 @@ internal ODBC32.RetCode BeginTransaction(ref IsolationLevel isolevel) return retcode; } - internal ODBC32.RetCode CompleteTransaction(short transactionOperation) + internal ODBC32.SQLRETURN CompleteTransaction(short transactionOperation) { bool mustRelease = false; try { DangerousAddRef(ref mustRelease); - ODBC32.RetCode retcode = CompleteTransaction(transactionOperation, base.handle); + ODBC32.SQLRETURN retcode = CompleteTransaction(transactionOperation, base.handle); return retcode; } finally @@ -157,11 +157,11 @@ internal ODBC32.RetCode CompleteTransaction(short transactionOperation) } } - private ODBC32.RetCode CompleteTransaction(short transactionOperation, IntPtr handle) + private ODBC32.SQLRETURN CompleteTransaction(short transactionOperation, IntPtr handle) { // must only call this code from ReleaseHandle or DangerousAddRef region - ODBC32.RetCode retcode = ODBC32.RetCode.SUCCESS; + ODBC32.SQLRETURN retcode = ODBC32.SQLRETURN.SUCCESS; try { } finally @@ -169,7 +169,7 @@ private ODBC32.RetCode CompleteTransaction(short transactionOperation, IntPtr ha if (HandleState.TransactionInProgress == _handleState) { retcode = Interop.Odbc.SQLEndTran(HandleType, handle, transactionOperation); - if ((ODBC32.RetCode.SUCCESS == retcode) || (ODBC32.RetCode.SUCCESS_WITH_INFO == retcode)) + if ((ODBC32.SQLRETURN.SUCCESS == retcode) || (ODBC32.SQLRETURN.SUCCESS_WITH_INFO == retcode)) { _handleState = HandleState.Transacted; } @@ -186,11 +186,11 @@ private ODBC32.RetCode CompleteTransaction(short transactionOperation, IntPtr ha //Debug.Assert((HandleState.Connected == _handleState) || (HandleState.TransactionInProgress == _handleState), "not expected HandleState.Connected"); return retcode; } - private ODBC32.RetCode Connect(string connectionString) + private ODBC32.SQLRETURN Connect(string connectionString) { Debug.Assert(HandleState.Allocated == _handleState, "SQLDriverConnect while in wrong state?"); - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; try { } finally @@ -199,8 +199,8 @@ private ODBC32.RetCode Connect(string connectionString) retcode = Interop.Odbc.SQLDriverConnectW(this, ADP.PtrZero, connectionString, ODBC32.SQL_NTS, ADP.PtrZero, 0, out cbActualSize, (short)ODBC32.SQL_DRIVER.NOPROMPT); switch (retcode) { - case ODBC32.RetCode.SUCCESS: - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: _handleState = HandleState.Connected; break; } @@ -212,7 +212,7 @@ private ODBC32.RetCode Connect(string connectionString) protected override bool ReleaseHandle() { // NOTE: The SafeHandle class guarantees this will be called exactly once and is non-interrutible. - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; // must call complete the transaction rollback, change handle state, and disconnect the connection retcode = CompleteTransaction(ODBC32.SQL_ROLLBACK, handle); @@ -226,41 +226,41 @@ protected override bool ReleaseHandle() return base.ReleaseHandle(); } - internal ODBC32.RetCode GetConnectionAttribute(ODBC32.SQL_ATTR attribute, byte[] buffer, out int cbActual) + internal ODBC32.SQLRETURN GetConnectionAttribute(ODBC32.SQL_ATTR attribute, byte[] buffer, out int cbActual) { - ODBC32.RetCode retcode = Interop.Odbc.SQLGetConnectAttrW(this, attribute, buffer, buffer.Length, out cbActual); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetConnectAttrW(this, attribute, buffer, buffer.Length, out cbActual); return retcode; } - internal ODBC32.RetCode GetFunctions(ODBC32.SQL_API fFunction, out short fExists) + internal ODBC32.SQLRETURN GetFunctions(ODBC32.SQL_API fFunction, out short fExists) { - ODBC32.RetCode retcode = Interop.Odbc.SQLGetFunctions(this, fFunction, out fExists); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetFunctions(this, fFunction, out fExists); ODBC.TraceODBC(3, "SQLGetFunctions", retcode); return retcode; } - internal ODBC32.RetCode GetInfo2(ODBC32.SQL_INFO info, byte[] buffer, out short cbActual) + internal ODBC32.SQLRETURN GetInfo2(ODBC32.SQL_INFO info, byte[] buffer, out short cbActual) { - ODBC32.RetCode retcode = Interop.Odbc.SQLGetInfoW(this, info, buffer, checked((short)buffer.Length), out cbActual); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetInfoW(this, info, buffer, checked((short)buffer.Length), out cbActual); return retcode; } - internal ODBC32.RetCode GetInfo1(ODBC32.SQL_INFO info, byte[] buffer) + internal ODBC32.SQLRETURN GetInfo1(ODBC32.SQL_INFO info, byte[] buffer) { - ODBC32.RetCode retcode = Interop.Odbc.SQLGetInfoW(this, info, buffer, checked((short)buffer.Length), ADP.PtrZero); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetInfoW(this, info, buffer, checked((short)buffer.Length), ADP.PtrZero); return retcode; } - internal ODBC32.RetCode SetConnectionAttribute2(ODBC32.SQL_ATTR attribute, IntPtr value, int length) + internal ODBC32.SQLRETURN SetConnectionAttribute2(ODBC32.SQL_ATTR attribute, IntPtr value, int length) { - ODBC32.RetCode retcode = Interop.Odbc.SQLSetConnectAttrW(this, attribute, value, length); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLSetConnectAttrW(this, attribute, value, length); ODBC.TraceODBC(3, "SQLSetConnectAttrW", retcode); return retcode; } - internal ODBC32.RetCode SetConnectionAttribute3(ODBC32.SQL_ATTR attribute, string buffer, int length) + internal ODBC32.SQLRETURN SetConnectionAttribute3(ODBC32.SQL_ATTR attribute, string buffer, int length) { - ODBC32.RetCode retcode = Interop.Odbc.SQLSetConnectAttrW(this, attribute, buffer, length); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLSetConnectAttrW(this, attribute, buffer, length); return retcode; } } 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 496e1543d92ee..8e57c9e8f4233 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 @@ -175,8 +175,8 @@ public override int FieldCount if (null == _dataCache) { short cColsAffected; - ODBC32.RetCode retcode = this.FieldCountNoThrow(out cColsAffected); - if (retcode != ODBC32.RetCode.SUCCESS) + ODBC32.SQLRETURN retcode = this.FieldCountNoThrow(out cColsAffected); + if (retcode != ODBC32.SQLRETURN.SUCCESS) { Connection!.HandleError(StatementHandle, retcode); } @@ -208,16 +208,16 @@ public override bool HasRows } } - internal ODBC32.RetCode FieldCountNoThrow(out short cColsAffected) + internal ODBC32.SQLRETURN FieldCountNoThrow(out short cColsAffected) { if (IsCancelingCommand) { cColsAffected = 0; - return ODBC32.RetCode.ERROR; + return ODBC32.SQLRETURN.ERROR; } - ODBC32.RetCode retcode = StatementHandle.NumberOfResultColumns(out cColsAffected); - if (retcode == ODBC32.RetCode.SUCCESS) + ODBC32.SQLRETURN retcode = StatementHandle.NumberOfResultColumns(out cColsAffected); + if (retcode == ODBC32.SQLRETURN.SUCCESS) { _hiddenColumns = 0; if (IsCommandBehavior(CommandBehavior.KeyInfo)) @@ -260,8 +260,8 @@ private SQLLEN GetRowCount() if (!IsClosed) { SQLLEN cRowsAffected; - ODBC32.RetCode retcode = StatementHandle.RowCount(out cRowsAffected); - if (ODBC32.RetCode.SUCCESS == retcode || ODBC32.RetCode.SUCCESS_WITH_INFO == retcode) + ODBC32.SQLRETURN retcode = StatementHandle.RowCount(out cRowsAffected); + if (ODBC32.SQLRETURN.SUCCESS == retcode || ODBC32.SQLRETURN.SUCCESS_WITH_INFO == retcode) { return cRowsAffected; } @@ -1552,7 +1552,7 @@ private SQLLEN GetColAttribute(int iColumn, ODBC32.SQL_DESC v3FieldId, ODBC32.SQ { short cchNameLength = 0; SQLLEN numericAttribute; - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; // protect against dead connection, dead or canceling command. if ((Connection == null) || _cmdWrapper!.Canceling) @@ -1574,9 +1574,9 @@ private SQLLEN GetColAttribute(int iColumn, ODBC32.SQL_DESC v3FieldId, ODBC32.SQ { return 0; } - if (retcode != ODBC32.RetCode.SUCCESS) + if (retcode != ODBC32.SQLRETURN.SUCCESS) { - if (retcode == ODBC32.RetCode.ERROR) + if (retcode == ODBC32.SQLRETURN.ERROR) { if ("HY091" == Command!.GetDiagSqlState()) { @@ -1603,7 +1603,7 @@ private SQLLEN GetColAttribute(int iColumn, ODBC32.SQL_DESC v3FieldId, ODBC32.SQ // private string? GetColAttributeStr(int i, ODBC32.SQL_DESC v3FieldId, ODBC32.SQL_COLUMN v2FieldId, ODBC32.HANDLER handler) { - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; short cchNameLength = 0; SQLLEN numericAttribute; CNativeBuffer buffer = Buffer; @@ -1629,9 +1629,9 @@ private SQLLEN GetColAttribute(int iColumn, ODBC32.SQL_DESC v3FieldId, ODBC32.SQ { return null; } - if ((retcode != ODBC32.RetCode.SUCCESS) || (cchNameLength == 0)) + if ((retcode != ODBC32.SQLRETURN.SUCCESS) || (cchNameLength == 0)) { - if (retcode == ODBC32.RetCode.ERROR) + if (retcode == ODBC32.SQLRETURN.ERROR) { if ("HY091" == Command!.GetDiagSqlState()) { @@ -1668,7 +1668,7 @@ private SQLLEN GetColAttribute(int iColumn, ODBC32.SQL_DESC v3FieldId, ODBC32.SQ return null; } - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; CNativeBuffer buffer = Buffer; // Need to set the APP_PARAM_DESC values here @@ -1680,9 +1680,9 @@ private SQLLEN GetColAttribute(int iColumn, ODBC32.SQL_DESC v3FieldId, ODBC32.SQ //Since there are many attributes (column, statement, etc), that may or may not be //supported, we don't want to throw (which obtains all errorinfo, marshals strings, //builds exceptions, etc), in common cases, unless we absolutely need this info... - if ((retcode != ODBC32.RetCode.SUCCESS) || (numericAttribute == 0)) + if ((retcode != ODBC32.SQLRETURN.SUCCESS) || (numericAttribute == 0)) { - if (retcode == ODBC32.RetCode.ERROR) + if (retcode == ODBC32.SQLRETURN.ERROR) { if ("HY091" == Command!.GetDiagSqlState()) { @@ -1757,7 +1757,7 @@ private bool GetData(int i, ODBC32.SQL_C sqlctype, int cb, out int cbLengthOrInd // SQLGetData CNativeBuffer buffer = Buffer; - ODBC32.RetCode retcode = StatementHandle.GetData( + ODBC32.SQLRETURN retcode = StatementHandle.GetData( (i + 1), // Column ordinals start at 1 in odbc sqlctype, buffer, @@ -1766,9 +1766,9 @@ private bool GetData(int i, ODBC32.SQL_C sqlctype, int cb, out int cbLengthOrInd switch (retcode) { - case ODBC32.RetCode.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS: break; - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: if ((int)cbActual == ODBC32.SQL_NO_TOTAL) { break; @@ -1776,7 +1776,7 @@ private bool GetData(int i, ODBC32.SQL_C sqlctype, int cb, out int cbLengthOrInd // devnote: don't we want to fire an event? break; - case ODBC32.RetCode.NO_DATA: + case ODBC32.SQLRETURN.NO_DATA: // SQLBU 266054: System.Data.Odbc: Fails with truncated error when we pass BufferLength as 0 // NO_DATA return value is success value - it means that the driver has fully consumed the current column value // but did not move to the next column yet. @@ -1852,7 +1852,7 @@ public override bool Read() return false; } - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; //SQLFetch is only valid to call for row returning queries //We get: [24000]Invalid cursor state. So we could either check the count @@ -1863,16 +1863,16 @@ public override bool Read() switch (retcode) { - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: Connection!.HandleErrorNoThrow(StatementHandle, retcode); _hasRows = HasRowsStatus.HasRows; _isRead = true; break; - case ODBC32.RetCode.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS: _hasRows = HasRowsStatus.HasRows; _isRead = true; break; - case ODBC32.RetCode.NO_DATA: + case ODBC32.SQLRETURN.NO_DATA: _isRead = false; if (_hasRows == HasRowsStatus.DontKnow) { @@ -1910,8 +1910,8 @@ internal void FirstResult() cRowsAffected = GetRowCount(); // get rowcount of the current resultset (if any) CalculateRecordsAffected(cRowsAffected); // update recordsaffected - ODBC32.RetCode retcode = FieldCountNoThrow(out cCols); - if ((retcode == ODBC32.RetCode.SUCCESS) && (cCols == 0)) + ODBC32.SQLRETURN retcode = FieldCountNoThrow(out cCols); + if ((retcode == ODBC32.SQLRETURN.SUCCESS) && (cCols == 0)) { NextResult(); } @@ -1936,7 +1936,7 @@ private bool NextResult(bool disposing, bool allresults) SQLLEN cRowsAffected; short cColsAffected; - ODBC32.RetCode retcode, firstRetCode = ODBC32.RetCode.SUCCESS; + ODBC32.SQLRETURN retcode, firstRetCode = ODBC32.SQLRETURN.SUCCESS; bool hasMoreResults; bool hasColumns = false; bool singleResult = IsCommandBehavior(CommandBehavior.SingleResult); @@ -1966,14 +1966,14 @@ private bool NextResult(bool disposing, bool allresults) { _isValidResult = false; retcode = StatementHandle.MoreResults(); - hasMoreResults = ((retcode == ODBC32.RetCode.SUCCESS) - || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)); + hasMoreResults = ((retcode == ODBC32.SQLRETURN.SUCCESS) + || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)); - if (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO) + if (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO) { Connection!.HandleErrorNoThrow(StatementHandle, retcode); } - else if (!disposing && (retcode != ODBC32.RetCode.NO_DATA) && (ODBC32.RetCode.SUCCESS != retcode)) + else if (!disposing && (retcode != ODBC32.SQLRETURN.NO_DATA) && (ODBC32.SQLRETURN.SUCCESS != retcode)) { // allow for building comulative error messages. if (null == errors) @@ -1999,10 +1999,10 @@ private bool NextResult(bool disposing, bool allresults) } } } while ((!singleResult && hasMoreResults && !hasColumns) // repeat for results with no columns - || ((ODBC32.RetCode.NO_DATA != retcode) && allresults && (loop < MaxConsecutiveFailure)) // or process all results until done + || ((ODBC32.SQLRETURN.NO_DATA != retcode) && allresults && (loop < MaxConsecutiveFailure)) // or process all results until done || (singleResult && hasMoreResults)); // or for any result in singelResult mode - if (retcode == ODBC32.RetCode.NO_DATA) + if (retcode == ODBC32.SQLRETURN.NO_DATA) { _dataCache = null; _noMoreResults = true; @@ -2330,7 +2330,7 @@ internal int RetrieveKeyInfo(bool needkeyinfo, QualifiedTableName qualifiedTable { Debug.Assert(_metadata != null); - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; string columnname; int ordinal; int keyColumns = 0; @@ -2360,7 +2360,7 @@ internal int RetrieveKeyInfo(bool needkeyinfo, QualifiedTableName qualifiedTable qualifiedTableName.Schema, qualifiedTableName.GetTable(quoted)!); - if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)) + if ((retcode == ODBC32.SQLRETURN.SUCCESS) || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)) { bool noUniqueKey = false; @@ -2372,7 +2372,7 @@ internal int RetrieveKeyInfo(bool needkeyinfo, QualifiedTableName qualifiedTable buffer.PtrOffset(0, 256), (IntPtr)256, buffer.PtrOffset(256, IntPtr.Size).Handle); - while (ODBC32.RetCode.SUCCESS == (retcode = KeyInfoStatementHandle.Fetch())) + while (ODBC32.SQLRETURN.SUCCESS == (retcode = KeyInfoStatementHandle.Fetch())) { cbActual = buffer.ReadIntPtr(256); columnname = buffer.PtrToStringUni(0, (int)cbActual / 2/*cch*/); @@ -2440,7 +2440,7 @@ internal int RetrieveKeyInfo(bool needkeyinfo, QualifiedTableName qualifiedTable // Get the special columns for version retcode = KeyInfoStatementHandle.SpecialColumns(qualifiedTableName.GetTable(quoted)!); - if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)) + if ((retcode == ODBC32.SQLRETURN.SUCCESS) || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)) { // We are only interested in column name cbActual = IntPtr.Zero; @@ -2452,7 +2452,7 @@ internal int RetrieveKeyInfo(bool needkeyinfo, QualifiedTableName qualifiedTable (IntPtr)256, buffer.PtrOffset(256, IntPtr.Size).Handle); - while (ODBC32.RetCode.SUCCESS == (retcode = KeyInfoStatementHandle.Fetch())) + while (ODBC32.SQLRETURN.SUCCESS == (retcode = KeyInfoStatementHandle.Fetch())) { cbActual = buffer.ReadIntPtr(256); columnname = buffer.PtrToStringUni(0, (int)cbActual / 2/*cch*/); @@ -2500,7 +2500,7 @@ private int RetrieveKeyInfoFromStatistics(QualifiedTableName qualifiedTableName, { Debug.Assert(_metadata != null); - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; string columnname = string.Empty; string indexname = string.Empty; string currentindexname = string.Empty; @@ -2523,7 +2523,7 @@ private int RetrieveKeyInfoFromStatistics(QualifiedTableName qualifiedTableName, // Select only unique indexes retcode = KeyInfoStatementHandle.Statistics(tablename1); - if (retcode != ODBC32.RetCode.SUCCESS) + if (retcode != ODBC32.SQLRETURN.SUCCESS) { // We give up at this point return 0; @@ -2574,7 +2574,7 @@ private int RetrieveKeyInfoFromStatistics(QualifiedTableName qualifiedTableName, colnameActual); // Find the best unique index on the table, use the ones whose columns are // completely covered by the query. - while (ODBC32.RetCode.SUCCESS == (retcode = KeyInfoStatementHandle.Fetch())) + while (ODBC32.SQLRETURN.SUCCESS == (retcode = KeyInfoStatementHandle.Fetch())) { cbColnameLen = buffer.ReadIntPtr(colnameActualOffset); cbIndexLen = buffer.ReadIntPtr(indexActualOffset); diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcEnvironmentHandle.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcEnvironmentHandle.cs index f816b2aa77717..07fa28c0884a8 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcEnvironmentHandle.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcEnvironmentHandle.cs @@ -10,7 +10,7 @@ internal sealed class OdbcEnvironmentHandle : OdbcHandle { public OdbcEnvironmentHandle() : base(ODBC32.SQL_HANDLE.ENV, null) { - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; //Set the expected driver manager version // @@ -34,8 +34,8 @@ public OdbcEnvironmentHandle() : base(ODBC32.SQL_HANDLE.ENV, null) switch (retcode) { - case ODBC32.RetCode.SUCCESS: - case ODBC32.RetCode.SUCCESS_WITH_INFO: + case ODBC32.SQLRETURN.SUCCESS: + case ODBC32.SQLRETURN.SUCCESS_WITH_INFO: break; default: Dispose(); diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs index 7a2f87ef4e110..52b70dc15e815 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcException.cs @@ -12,7 +12,7 @@ public sealed class OdbcException : System.Data.Common.DbException { private readonly OdbcErrorCollection _odbcErrors = new OdbcErrorCollection(); - internal static OdbcException CreateException(OdbcErrorCollection errors, ODBC32.RetCode retcode) + internal static OdbcException CreateException(OdbcErrorCollection errors, ODBC32.SQLRETURN retcode) { StringBuilder builder = new StringBuilder(); foreach (OdbcError error in errors) 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 a5432b8240539..5c4cfbe5823b3 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 @@ -21,7 +21,7 @@ protected OdbcHandle(ODBC32.SQL_HANDLE handleType, OdbcHandle? parentHandle) : b _handleType = handleType; bool mustRelease = false; - ODBC32.RetCode retcode = ODBC32.RetCode.SUCCESS; + ODBC32.SQLRETURN retcode = ODBC32.SQLRETURN.SUCCESS; try { @@ -70,7 +70,7 @@ protected OdbcHandle(ODBC32.SQL_HANDLE handleType, OdbcHandle? parentHandle) : b } } - if ((ADP.PtrZero == base.handle) || (ODBC32.RetCode.SUCCESS != retcode)) + if ((ADP.PtrZero == base.handle) || (ODBC32.SQLRETURN.SUCCESS != retcode)) { // throw ODBC.CantAllocateEnvironmentHandle(retcode); @@ -83,7 +83,7 @@ internal OdbcHandle(OdbcStatementHandle parentHandle, ODBC32.SQL_ATTR attribute) _handleType = ODBC32.SQL_HANDLE.DESC; int cbActual; - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; bool mustRelease = false; try @@ -176,12 +176,12 @@ protected override bool ReleaseHandle() return true; } - internal ODBC32.RetCode GetDiagnosticField(out string sqlState) + internal ODBC32.SQLRETURN GetDiagnosticField(out string sqlState) { short cbActual; // ODBC (MSDN) documents it expects a buffer large enough to hold 5(+L'\0') unicode characters StringBuilder sb = new StringBuilder(6); - ODBC32.RetCode retcode = Interop.Odbc.SQLGetDiagFieldW( + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetDiagFieldW( HandleType, this, (short)1, @@ -190,7 +190,7 @@ internal ODBC32.RetCode GetDiagnosticField(out string sqlState) checked((short)(2 * sb.Capacity)), // expects number of bytes, see \\kbinternal\kb\articles\294\1\69.HTM out cbActual); ODBC.TraceODBC(3, "SQLGetDiagFieldW", retcode); - if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)) + if ((retcode == ODBC32.SQLRETURN.SUCCESS) || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)) { sqlState = sb.ToString(); } @@ -201,14 +201,14 @@ internal ODBC32.RetCode GetDiagnosticField(out string sqlState) return retcode; } - internal ODBC32.RetCode GetDiagnosticRecord(short record, out string sqlState, StringBuilder message, out int nativeError, out short cchActual) + internal ODBC32.SQLRETURN GetDiagnosticRecord(short record, out string sqlState, StringBuilder message, out int nativeError, out short cchActual) { // ODBC (MSDN) documents it expects a buffer large enough to hold 4(+L'\0') unicode characters StringBuilder sb = new StringBuilder(5); - ODBC32.RetCode retcode = Interop.Odbc.SQLGetDiagRecW(HandleType, this, record, sb, out nativeError, message, checked((short)message.Capacity), out cchActual); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetDiagRecW(HandleType, this, record, sb, out nativeError, message, checked((short)message.Capacity), out cchActual); ODBC.TraceODBC(3, "SQLGetDiagRecW", retcode); - if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)) + if ((retcode == ODBC32.SQLRETURN.SUCCESS) || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)) { sqlState = sb.ToString(); } @@ -226,23 +226,23 @@ internal OdbcDescriptorHandle(OdbcStatementHandle statementHandle, ODBC32.SQL_AT { } - internal ODBC32.RetCode GetDescriptionField(int i, ODBC32.SQL_DESC attribute, CNativeBuffer buffer, out int numericAttribute) + internal ODBC32.SQLRETURN GetDescriptionField(int i, ODBC32.SQL_DESC attribute, CNativeBuffer buffer, out int numericAttribute) { - ODBC32.RetCode retcode = Interop.Odbc.SQLGetDescFieldW(this, checked((short)i), attribute, buffer, buffer.ShortLength, out numericAttribute); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetDescFieldW(this, checked((short)i), attribute, buffer, buffer.ShortLength, out numericAttribute); ODBC.TraceODBC(3, "SQLGetDescFieldW", retcode); return retcode; } - internal ODBC32.RetCode SetDescriptionField1(short ordinal, ODBC32.SQL_DESC type, IntPtr value) + internal ODBC32.SQLRETURN SetDescriptionField1(short ordinal, ODBC32.SQL_DESC type, IntPtr value) { - ODBC32.RetCode retcode = Interop.Odbc.SQLSetDescFieldW(this, ordinal, type, value, 0); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLSetDescFieldW(this, ordinal, type, value, 0); ODBC.TraceODBC(3, "SQLSetDescFieldW", retcode); return retcode; } - internal ODBC32.RetCode SetDescriptionField2(short ordinal, ODBC32.SQL_DESC type, HandleRef value) + internal ODBC32.SQLRETURN SetDescriptionField2(short ordinal, ODBC32.SQL_DESC type, HandleRef value) { - ODBC32.RetCode retcode = Interop.Odbc.SQLSetDescFieldW(this, ordinal, type, value, 0); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLSetDescFieldW(this, ordinal, type, value, 0); ODBC.TraceODBC(3, "SQLSetDescFieldW", retcode); return retcode; } diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcMetaDataFactory.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcMetaDataFactory.cs index 852265e095d87..f92e61e23acf0 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcMetaDataFactory.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcMetaDataFactory.cs @@ -590,7 +590,7 @@ private DataTable GetDataSourceInformationCollection(string?[]? restrictions, string? stringValue; short int16Value; int int32Value; - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; // update the catalog separator stringValue = connection.GetInfoStringUnhandled(ODBC32.SQL_INFO.CATALOG_NAME_SEPARATOR); @@ -631,7 +631,7 @@ private DataTable GetDataSourceInformationCollection(string?[]? restrictions, retcode = connection.GetInfoInt32Unhandled(ODBC32.SQL_INFO.SQL_OJ_CAPABILITIES_20, out int32Value); } - if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)) + if ((retcode == ODBC32.SQLRETURN.SUCCESS) || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)) { Common.SupportedJoinOperators supportedJoinOperators = Common.SupportedJoinOperators.None; if ((int32Value & (int)ODBC32.SQL_OJ_CAPABILITIES.LEFT) != 0) @@ -658,7 +658,7 @@ private DataTable GetDataSourceInformationCollection(string?[]? restrictions, retcode = connection.GetInfoInt16Unhandled(ODBC32.SQL_INFO.GROUP_BY, out int16Value); Common.GroupByBehavior groupByBehavior = Common.GroupByBehavior.Unknown; - if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)) + if ((retcode == ODBC32.SQLRETURN.SUCCESS) || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)) { switch (int16Value) { @@ -691,7 +691,7 @@ private DataTable GetDataSourceInformationCollection(string?[]? restrictions, retcode = connection.GetInfoInt16Unhandled(ODBC32.SQL_INFO.IDENTIFIER_CASE, out int16Value); Common.IdentifierCase identifierCase = Common.IdentifierCase.Unknown; - if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)) + if ((retcode == ODBC32.SQLRETURN.SUCCESS) || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)) { switch (int16Value) { @@ -758,7 +758,7 @@ private DataTable GetDataSourceInformationCollection(string?[]? restrictions, retcode = connection.GetInfoInt16Unhandled(ODBC32.SQL_INFO.QUOTED_IDENTIFIER_CASE, out int16Value); Common.IdentifierCase quotedIdentifierCase = Common.IdentifierCase.Unknown; - if ((retcode == ODBC32.RetCode.SUCCESS) || (retcode == ODBC32.RetCode.SUCCESS_WITH_INFO)) + if ((retcode == ODBC32.SQLRETURN.SUCCESS) || (retcode == ODBC32.SQLRETURN.SUCCESS_WITH_INFO)) { switch (int16Value) { diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameter.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameter.cs index 7bcba69eb243d..15f00fd2c8b9f 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameter.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcParameter.cs @@ -792,7 +792,7 @@ internal void Bind(OdbcStatementHandle hstmt, OdbcCommand command, short ordinal { Debug.Assert(command.Connection != null); - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; ODBC32.SQL_C sql_c_type = _prepared_Sql_C_Type; ODBC32.SQL_PARAM sqldirection = SqlDirectionFromParameterDirection(); @@ -871,7 +871,7 @@ internal void Bind(OdbcStatementHandle hstmt, OdbcCommand command, short ordinal (IntPtr)_preparedBufferSize, intBuffer); // StrLen_or_IndPtr - if (ODBC32.RetCode.SUCCESS != retcode) + if (ODBC32.SQLRETURN.SUCCESS != retcode) { if ("07006" == command.GetDiagSqlState()) { @@ -902,7 +902,7 @@ internal void Bind(OdbcStatementHandle hstmt, OdbcCommand command, short ordinal //SQLSetDescField(hdesc, i+1, SQL_DESC_TYPE, (void *)SQL_C_NUMERIC, 0); retcode = hdesc.SetDescriptionField1(ordinal, ODBC32.SQL_DESC.TYPE, (IntPtr)ODBC32.SQL_C.NUMERIC); - if (ODBC32.RetCode.SUCCESS != retcode) + if (ODBC32.SQLRETURN.SUCCESS != retcode) { command.Connection.HandleError(hstmt, retcode); } @@ -914,7 +914,7 @@ internal void Bind(OdbcStatementHandle hstmt, OdbcCommand command, short ordinal //SQLSetDescField(hdesc, i+1, SQL_DESC_PRECISION, (void *)precision, 0); retcode = hdesc.SetDescriptionField1(ordinal, ODBC32.SQL_DESC.PRECISION, (IntPtr)cbActual); - if (ODBC32.RetCode.SUCCESS != retcode) + if (ODBC32.SQLRETURN.SUCCESS != retcode) { command.Connection.HandleError(hstmt, retcode); } @@ -926,7 +926,7 @@ internal void Bind(OdbcStatementHandle hstmt, OdbcCommand command, short ordinal cbActual = (int)scale; retcode = hdesc.SetDescriptionField1(ordinal, ODBC32.SQL_DESC.SCALE, (IntPtr)cbActual); - if (ODBC32.RetCode.SUCCESS != retcode) + if (ODBC32.SQLRETURN.SUCCESS != retcode) { command.Connection.HandleError(hstmt, retcode); } @@ -936,7 +936,7 @@ internal void Bind(OdbcStatementHandle hstmt, OdbcCommand command, short ordinal // SQLSetDescField(hdesc, i+1, SQL_DESC_DATA_PTR, (void *)&numeric, 0); retcode = hdesc.SetDescriptionField2(ordinal, ODBC32.SQL_DESC.DATA_PTR, valueBuffer); - if (ODBC32.RetCode.SUCCESS != retcode) + if (ODBC32.SQLRETURN.SUCCESS != retcode) { command.Connection.HandleError(hstmt, retcode); } diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcStatementHandle.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcStatementHandle.cs index f8384b7a20b47..cdbd81af51fc8 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcStatementHandle.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcStatementHandle.cs @@ -59,23 +59,23 @@ internal OdbcStatementHandle(OdbcConnectionHandle? connectionHandle) : base(ODBC { } - internal ODBC32.RetCode BindColumn2(int columnNumber, ODBC32.SQL_C targetType, HandleRef buffer, IntPtr length, IntPtr srLen_or_Ind) + internal ODBC32.SQLRETURN BindColumn2(int columnNumber, ODBC32.SQL_C targetType, HandleRef buffer, IntPtr length, IntPtr srLen_or_Ind) { - ODBC32.RetCode retcode = Interop.Odbc.SQLBindCol(this, checked((ushort)columnNumber), targetType, buffer, length, srLen_or_Ind); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLBindCol(this, checked((ushort)columnNumber), targetType, buffer, length, srLen_or_Ind); ODBC.TraceODBC(3, "SQLBindCol", retcode); return retcode; } - internal ODBC32.RetCode BindColumn3(int columnNumber, ODBC32.SQL_C targetType, IntPtr srLen_or_Ind) + internal ODBC32.SQLRETURN BindColumn3(int columnNumber, ODBC32.SQL_C targetType, IntPtr srLen_or_Ind) { - ODBC32.RetCode retcode = Interop.Odbc.SQLBindCol(this, checked((ushort)columnNumber), targetType, ADP.PtrZero, ADP.PtrZero, srLen_or_Ind); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLBindCol(this, checked((ushort)columnNumber), targetType, ADP.PtrZero, ADP.PtrZero, srLen_or_Ind); ODBC.TraceODBC(3, "SQLBindCol", retcode); return retcode; } - internal ODBC32.RetCode BindParameter(short ordinal, short parameterDirection, ODBC32.SQL_C sqlctype, ODBC32.SQL_TYPE sqltype, IntPtr cchSize, IntPtr scale, HandleRef buffer, IntPtr bufferLength, HandleRef intbuffer) + internal ODBC32.SQLRETURN BindParameter(short ordinal, short parameterDirection, ODBC32.SQL_C sqlctype, ODBC32.SQL_TYPE sqltype, IntPtr cchSize, IntPtr scale, HandleRef buffer, IntPtr bufferLength, HandleRef intbuffer) { - ODBC32.RetCode retcode = Interop.Odbc.SQLBindParameter(this, + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLBindParameter(this, checked((ushort)ordinal), // Parameter Number parameterDirection, // InputOutputType sqlctype, // ValueType @@ -89,37 +89,37 @@ internal ODBC32.RetCode BindParameter(short ordinal, short parameterDirection, O return retcode; } - internal ODBC32.RetCode Cancel() + internal ODBC32.SQLRETURN Cancel() { // In ODBC3.0 ... a call to SQLCancel when no processing is done has no effect at all // (ODBC Programmer's Reference ...) - ODBC32.RetCode retcode = Interop.Odbc.SQLCancel(this); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLCancel(this); ODBC.TraceODBC(3, "SQLCancel", retcode); return retcode; } - internal ODBC32.RetCode CloseCursor() + internal ODBC32.SQLRETURN CloseCursor() { - ODBC32.RetCode retcode = Interop.Odbc.SQLCloseCursor(this); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLCloseCursor(this); ODBC.TraceODBC(3, "SQLCloseCursor", retcode); return retcode; } - internal ODBC32.RetCode ColumnAttribute(int columnNumber, short fieldIdentifier, CNativeBuffer characterAttribute, out short stringLength, out SQLLEN numericAttribute) + internal ODBC32.SQLRETURN ColumnAttribute(int columnNumber, short fieldIdentifier, CNativeBuffer characterAttribute, out short stringLength, out SQLLEN numericAttribute) { IntPtr result; - ODBC32.RetCode retcode = Interop.Odbc.SQLColAttributeW(this, checked((short)columnNumber), fieldIdentifier, characterAttribute, characterAttribute.ShortLength, out stringLength, out result); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLColAttributeW(this, checked((short)columnNumber), fieldIdentifier, characterAttribute, characterAttribute.ShortLength, out stringLength, out result); numericAttribute = new SQLLEN(result); ODBC.TraceODBC(3, "SQLColAttributeW", retcode); return retcode; } - internal ODBC32.RetCode Columns(string tableCatalog, + internal ODBC32.SQLRETURN Columns(string tableCatalog, string tableSchema, string tableName, string columnName) { - ODBC32.RetCode retcode = Interop.Odbc.SQLColumnsW(this, + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLColumnsW(this, tableCatalog, ODBC.ShortStringLength(tableCatalog), tableSchema, @@ -133,37 +133,37 @@ internal ODBC32.RetCode Columns(string tableCatalog, return retcode; } - internal ODBC32.RetCode Execute() + internal ODBC32.SQLRETURN Execute() { - ODBC32.RetCode retcode = Interop.Odbc.SQLExecute(this); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLExecute(this); ODBC.TraceODBC(3, "SQLExecute", retcode); return retcode; } - internal ODBC32.RetCode ExecuteDirect(string commandText) + internal ODBC32.SQLRETURN ExecuteDirect(string commandText) { - ODBC32.RetCode retcode = Interop.Odbc.SQLExecDirectW(this, commandText, ODBC32.SQL_NTS); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLExecDirectW(this, commandText, ODBC32.SQL_NTS); ODBC.TraceODBC(3, "SQLExecDirectW", retcode); return retcode; } - internal ODBC32.RetCode Fetch() + internal ODBC32.SQLRETURN Fetch() { - ODBC32.RetCode retcode = Interop.Odbc.SQLFetch(this); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLFetch(this); ODBC.TraceODBC(3, "SQLFetch", retcode); return retcode; } - internal ODBC32.RetCode FreeStatement(ODBC32.STMT stmt) + internal ODBC32.SQLRETURN FreeStatement(ODBC32.STMT stmt) { - ODBC32.RetCode retcode = Interop.Odbc.SQLFreeStmt(this, stmt); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLFreeStmt(this, stmt); ODBC.TraceODBC(3, "SQLFreeStmt", retcode); return retcode; } - internal ODBC32.RetCode GetData(int index, ODBC32.SQL_C sqlctype, CNativeBuffer buffer, int cb, out IntPtr cbActual) + internal ODBC32.SQLRETURN GetData(int index, ODBC32.SQL_C sqlctype, CNativeBuffer buffer, int cb, out IntPtr cbActual) { - ODBC32.RetCode retcode = Interop.Odbc.SQLGetData(this, + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetData(this, checked((ushort)index), sqlctype, buffer, @@ -173,44 +173,44 @@ internal ODBC32.RetCode GetData(int index, ODBC32.SQL_C sqlctype, CNativeBuffer return retcode; } - internal ODBC32.RetCode GetStatementAttribute(ODBC32.SQL_ATTR attribute, out IntPtr value, out int stringLength) + internal ODBC32.SQLRETURN GetStatementAttribute(ODBC32.SQL_ATTR attribute, out IntPtr value, out int stringLength) { - ODBC32.RetCode retcode = Interop.Odbc.SQLGetStmtAttrW(this, attribute, out value, ADP.PtrSize, out stringLength); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetStmtAttrW(this, attribute, out value, ADP.PtrSize, out stringLength); ODBC.TraceODBC(3, "SQLGetStmtAttrW", retcode); return retcode; } - internal ODBC32.RetCode GetTypeInfo(short fSqlType) + internal ODBC32.SQLRETURN GetTypeInfo(short fSqlType) { - ODBC32.RetCode retcode = Interop.Odbc.SQLGetTypeInfo(this, fSqlType); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLGetTypeInfo(this, fSqlType); ODBC.TraceODBC(3, "SQLGetTypeInfo", retcode); return retcode; } - internal ODBC32.RetCode MoreResults() + internal ODBC32.SQLRETURN MoreResults() { - ODBC32.RetCode retcode = Interop.Odbc.SQLMoreResults(this); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLMoreResults(this); ODBC.TraceODBC(3, "SQLMoreResults", retcode); return retcode; } - internal ODBC32.RetCode NumberOfResultColumns(out short columnsAffected) + internal ODBC32.SQLRETURN NumberOfResultColumns(out short columnsAffected) { - ODBC32.RetCode retcode = Interop.Odbc.SQLNumResultCols(this, out columnsAffected); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLNumResultCols(this, out columnsAffected); ODBC.TraceODBC(3, "SQLNumResultCols", retcode); return retcode; } - internal ODBC32.RetCode Prepare(string commandText) + internal ODBC32.SQLRETURN Prepare(string commandText) { - ODBC32.RetCode retcode = Interop.Odbc.SQLPrepareW(this, commandText, ODBC32.SQL_NTS); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLPrepareW(this, commandText, ODBC32.SQL_NTS); ODBC.TraceODBC(3, "SQLPrepareW", retcode); return retcode; } - internal ODBC32.RetCode PrimaryKeys(string? catalogName, string? schemaName, string tableName) + internal ODBC32.SQLRETURN PrimaryKeys(string? catalogName, string? schemaName, string tableName) { - ODBC32.RetCode retcode = Interop.Odbc.SQLPrimaryKeysW(this, + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLPrimaryKeysW(this, catalogName, ODBC.ShortStringLength(catalogName), // CatalogName schemaName, ODBC.ShortStringLength(schemaName), // SchemaName tableName, ODBC.ShortStringLength(tableName) // TableName @@ -219,11 +219,11 @@ internal ODBC32.RetCode PrimaryKeys(string? catalogName, string? schemaName, str return retcode; } - internal ODBC32.RetCode Procedures(string procedureCatalog, + internal ODBC32.SQLRETURN Procedures(string procedureCatalog, string procedureSchema, string procedureName) { - ODBC32.RetCode retcode = Interop.Odbc.SQLProceduresW(this, + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLProceduresW(this, procedureCatalog, ODBC.ShortStringLength(procedureCatalog), procedureSchema, @@ -235,12 +235,12 @@ internal ODBC32.RetCode Procedures(string procedureCatalog, return retcode; } - internal ODBC32.RetCode ProcedureColumns(string? procedureCatalog, + internal ODBC32.SQLRETURN ProcedureColumns(string? procedureCatalog, string? procedureSchema, string? procedureName, string? columnName) { - ODBC32.RetCode retcode = Interop.Odbc.SQLProcedureColumnsW(this, + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLProcedureColumnsW(this, procedureCatalog, ODBC.ShortStringLength(procedureCatalog), procedureSchema, @@ -254,25 +254,25 @@ internal ODBC32.RetCode ProcedureColumns(string? procedureCatalog, return retcode; } - internal ODBC32.RetCode RowCount(out SQLLEN rowCount) + internal ODBC32.SQLRETURN RowCount(out SQLLEN rowCount) { IntPtr result; - ODBC32.RetCode retcode = Interop.Odbc.SQLRowCount(this, out result); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLRowCount(this, out result); rowCount = new SQLLEN(result); ODBC.TraceODBC(3, "SQLRowCount", retcode); return retcode; } - internal ODBC32.RetCode SetStatementAttribute(ODBC32.SQL_ATTR attribute, IntPtr value, ODBC32.SQL_IS stringLength) + internal ODBC32.SQLRETURN SetStatementAttribute(ODBC32.SQL_ATTR attribute, IntPtr value, ODBC32.SQL_IS stringLength) { - ODBC32.RetCode retcode = Interop.Odbc.SQLSetStmtAttrW(this, (int)attribute, value, (int)stringLength); + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLSetStmtAttrW(this, (int)attribute, value, (int)stringLength); ODBC.TraceODBC(3, "SQLSetStmtAttrW", retcode); return retcode; } - internal ODBC32.RetCode SpecialColumns(string quotedTable) + internal ODBC32.SQLRETURN SpecialColumns(string quotedTable) { - ODBC32.RetCode retcode = Interop.Odbc.SQLSpecialColumnsW(this, + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLSpecialColumnsW(this, ODBC32.SQL_SPECIALCOLS.ROWVER, null, 0, null, 0, quotedTable, ODBC.ShortStringLength(quotedTable), ODBC32.SQL_SCOPE.SESSION, ODBC32.SQL_NULLABILITY.NO_NULLS); @@ -280,13 +280,13 @@ internal ODBC32.RetCode SpecialColumns(string quotedTable) return retcode; } - internal ODBC32.RetCode Statistics(string? tableCatalog, + internal ODBC32.SQLRETURN Statistics(string? tableCatalog, string? tableSchema, string tableName, short unique, short accuracy) { - ODBC32.RetCode retcode; + ODBC32.SQLRETURN retcode; // MDAC Bug 75928 - SQLStatisticsW damages the string passed in // To protect the tablename we need to pass in a copy of that string @@ -313,17 +313,17 @@ internal ODBC32.RetCode Statistics(string? tableCatalog, return retcode; } - internal ODBC32.RetCode Statistics(string tableName) + internal ODBC32.SQLRETURN Statistics(string tableName) { return Statistics(null, null, tableName, (short)ODBC32.SQL_INDEX.UNIQUE, (short)ODBC32.SQL_STATISTICS_RESERVED.ENSURE); } - internal ODBC32.RetCode Tables(string tableCatalog, + internal ODBC32.SQLRETURN Tables(string tableCatalog, string tableSchema, string tableName, string tableType) { - ODBC32.RetCode retcode = Interop.Odbc.SQLTablesW(this, + ODBC32.SQLRETURN retcode = Interop.Odbc.SQLTablesW(this, tableCatalog, ODBC.ShortStringLength(tableCatalog), tableSchema, diff --git a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcTransaction.cs b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcTransaction.cs index aceee7efbe499..7e1856c16f07d 100644 --- a/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcTransaction.cs +++ b/src/libraries/System.Data.Odbc/src/System/Data/Odbc/OdbcTransaction.cs @@ -82,8 +82,8 @@ public override void Commit() throw ODBC.NotInTransaction(); } - ODBC32.RetCode retcode = _handle.CompleteTransaction(ODBC32.SQL_COMMIT); - if (retcode == ODBC32.RetCode.ERROR) + ODBC32.SQLRETURN retcode = _handle.CompleteTransaction(ODBC32.SQL_COMMIT); + if (retcode == ODBC32.SQLRETURN.ERROR) { //If an error has occurred, we will throw an exception in HandleError, //and leave the transaction active for the user to retry @@ -106,8 +106,8 @@ protected override void Dispose(bool disposing) { try { - ODBC32.RetCode retcode = handle.CompleteTransaction(ODBC32.SQL_ROLLBACK); - if (retcode == ODBC32.RetCode.ERROR) + ODBC32.SQLRETURN retcode = handle.CompleteTransaction(ODBC32.SQL_ROLLBACK); + if (retcode == ODBC32.SQLRETURN.ERROR) { //don't throw an exception here, but trace it so it can be logged if (_connection != null) @@ -155,8 +155,8 @@ public override void Rollback() throw ODBC.NotInTransaction(); } - ODBC32.RetCode retcode = _handle.CompleteTransaction(ODBC32.SQL_ROLLBACK); - if (retcode == ODBC32.RetCode.ERROR) + ODBC32.SQLRETURN retcode = _handle.CompleteTransaction(ODBC32.SQL_ROLLBACK); + if (retcode == ODBC32.SQLRETURN.ERROR) { //If an error has occurred, we will throw an exception in HandleError, //and leave the transaction active for the user to retry diff --git a/src/libraries/System.ServiceProcess.ServiceController/tests/System.ServiceProcess.ServiceController.TestService/System.ServiceProcess.ServiceController.TestService.csproj b/src/libraries/System.ServiceProcess.ServiceController/tests/System.ServiceProcess.ServiceController.TestService/System.ServiceProcess.ServiceController.TestService.csproj index 489f6bbf553f3..fe1302370b388 100644 --- a/src/libraries/System.ServiceProcess.ServiceController/tests/System.ServiceProcess.ServiceController.TestService/System.ServiceProcess.ServiceController.TestService.csproj +++ b/src/libraries/System.ServiceProcess.ServiceController/tests/System.ServiceProcess.ServiceController.TestService/System.ServiceProcess.ServiceController.TestService.csproj @@ -4,6 +4,7 @@ Exe $(NetCoreAppCurrent);$(NetFrameworkMinimum) annotations + true