diff --git a/src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs b/src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs index 9034672936b880..9a94083b7ac8c5 100644 --- a/src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs +++ b/src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs @@ -8,6 +8,9 @@ namespace System.Data.OleDb { [System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.OleDbCommandDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] [System.ComponentModel.ToolboxItemAttribute(true)] +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public sealed partial class OleDbCommand : System.Data.Common.DbCommand, System.Data.IDbCommand, System.ICloneable, System.IDisposable { public OleDbCommand() { } @@ -81,6 +84,9 @@ protected override void SetRowUpdatingHandler(System.Data.Common.DbDataAdapter a public string UnquoteIdentifier(string quotedIdentifier, System.Data.OleDb.OleDbConnection? connection) { throw null; } } [System.ComponentModel.DefaultEventAttribute("InfoMessage")] +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public sealed partial class OleDbConnection : System.Data.Common.DbConnection, System.Data.IDbConnection, System.ICloneable, System.IDisposable { public OleDbConnection() { } @@ -127,6 +133,9 @@ public void ResetState() { } } [System.ComponentModel.DefaultPropertyAttribute("Provider")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public sealed partial class OleDbConnectionStringBuilder : System.Data.Common.DbConnectionStringBuilder { public OleDbConnectionStringBuilder() { } @@ -151,6 +160,9 @@ public override void Clear() { } } [System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.OleDbDataAdapterDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] [System.ComponentModel.ToolboxItemAttribute("Microsoft.VSDesigner.Data.VS.OleDbDataAdapterToolboxItem, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public sealed partial class OleDbDataAdapter : System.Data.Common.DbDataAdapter, System.Data.IDataAdapter, System.Data.IDbDataAdapter, System.ICloneable { public OleDbDataAdapter() { } @@ -183,6 +195,9 @@ protected override void OnRowUpdated(System.Data.Common.RowUpdatedEventArgs valu protected override void OnRowUpdating(System.Data.Common.RowUpdatingEventArgs value) { } object System.ICloneable.Clone() { throw null; } } +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public sealed partial class OleDbDataReader : System.Data.Common.DbDataReader { internal OleDbDataReader() { } @@ -229,8 +244,17 @@ public override void Close() { } public sealed partial class OleDbEnumerator { public OleDbEnumerator() { } +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public System.Data.DataTable GetElements() { throw null; } +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public static System.Data.OleDb.OleDbDataReader GetEnumerator(System.Type type) { throw null; } +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public static System.Data.OleDb.OleDbDataReader GetRootEnumerator() { throw null; } } public sealed partial class OleDbError @@ -265,6 +289,9 @@ internal OleDbException() { } #endif public override void GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { } } +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public sealed partial class OleDbFactory : System.Data.Common.DbProviderFactory { internal OleDbFactory() { } @@ -477,6 +504,9 @@ public sealed partial class OleDbSchemaGuid public static readonly System.Guid View_Table_Usage; public OleDbSchemaGuid() { } } +#if NET + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("OleDbConnection is not AOT-compatible.")] +#endif public sealed partial class OleDbTransaction : System.Data.Common.DbTransaction { internal OleDbTransaction() { } diff --git a/src/libraries/System.Data.OleDb/src/OleDbCommand.cs b/src/libraries/System.Data.OleDb/src/OleDbCommand.cs index 44bb0aceee66d0..279dcf22329a04 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbCommand.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbCommand.cs @@ -14,6 +14,7 @@ namespace System.Data.OleDb { [Designer("Microsoft.VSDesigner.Data.VS.OleDbCommandDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] [ToolboxItem(true)] + [RequiresDynamicCode(OleDbConnection.TrimWarning)] public sealed class OleDbCommand : DbCommand, ICloneable, IDbCommand { // command data diff --git a/src/libraries/System.Data.OleDb/src/OleDbConnection.cs b/src/libraries/System.Data.OleDb/src/OleDbConnection.cs index dc9368dca808b6..686aa0ee323308 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbConnection.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbConnection.cs @@ -19,8 +19,11 @@ namespace System.Data.OleDb // it won't happen if you directly create the provider and set its properties // 2. First call on IDBInitialize must be Initialize, can't QI for any other interfaces before that [DefaultEvent("InfoMessage")] + [RequiresDynamicCode(OleDbConnection.TrimWarning)] public sealed partial class OleDbConnection : DbConnection, ICloneable, IDbConnection { + internal const string TrimWarning = "OleDbConnection is not AOT-compatible."; + private static readonly object EventInfoMessage = new object(); public OleDbConnection(string? connectionString) : this() diff --git a/src/libraries/System.Data.OleDb/src/OleDbConnectionFactory.cs b/src/libraries/System.Data.OleDb/src/OleDbConnectionFactory.cs index f74fda12f94f33..ea4f81c99203c3 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbConnectionFactory.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbConnectionFactory.cs @@ -6,11 +6,13 @@ using System.Data.Common; using System.Data.ProviderBase; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Runtime.Versioning; namespace System.Data.OleDb { + [RequiresDynamicCode("XML deserialization requires dynamic code")] internal sealed class OleDbConnectionFactory : DbConnectionFactory { private OleDbConnectionFactory() : base() { } diff --git a/src/libraries/System.Data.OleDb/src/OleDbConnectionInternal.cs b/src/libraries/System.Data.OleDb/src/OleDbConnectionInternal.cs index e5635abaf90af6..a816de5b7e39ab 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbConnectionInternal.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbConnectionInternal.cs @@ -5,6 +5,7 @@ using System.Data.Common; using System.Data.ProviderBase; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime.InteropServices; using System.Threading; @@ -12,6 +13,9 @@ namespace System.Data.OleDb { +#if NET + [RequiresDynamicCode(OleDbConnection.TrimWarning)] +#endif internal sealed class OleDbConnectionInternal : DbConnectionInternal, IDisposable { private static volatile OleDbServicesWrapper? idataInitialize; @@ -414,7 +418,11 @@ internal void EnlistTransactionInternal(SysTx.Transaction? transaction) tagDBLITERALINFO tag = new tagDBLITERALINFO(); for (int i = 0; i < literalCount; ++i, offset += ODB.SizeOf_tagDBLITERALINFO) { - Marshal.PtrToStructure((nint)offset, tag); + if (offset is null) + { + throw new NullReferenceException(); + } + tag = Marshal.PtrToStructure((IntPtr)offset)!; DataRow row = table.NewRow(); row[literalName] = ((OleDbLiteral)tag.it).ToString(); @@ -591,7 +599,7 @@ internal DataTable BuildSchemaGuids() for (int i = 0, offset = 0; i < supportedSchemas.Length; ++i, offset += ODB.SizeOf_Guid) { IntPtr ptr = ADP.IntPtrOffset(schemaGuids, i * ODB.SizeOf_Guid); - supportedSchemas[i]._schemaRowset = (Guid)Marshal.PtrToStructure(ptr, typeof(Guid))!; + supportedSchemas[i]._schemaRowset = Marshal.PtrToStructure(ptr)!; } } if (IntPtr.Zero != schemaRestrictions) diff --git a/src/libraries/System.Data.OleDb/src/OleDbConnectionStringBuilder.cs b/src/libraries/System.Data.OleDb/src/OleDbConnectionStringBuilder.cs index 8aeb9fefbb47a1..e3827a3ac40302 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbConnectionStringBuilder.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbConnectionStringBuilder.cs @@ -15,6 +15,9 @@ namespace System.Data.OleDb [DefaultProperty("Provider")] [RefreshProperties(RefreshProperties.All)] [TypeConverter(typeof(OleDbConnectionStringBuilder.OleDbConnectionStringBuilderConverter))] +#if NET + [RequiresDynamicCode(OleDbConnection.TrimWarning)] +#endif public sealed class OleDbConnectionStringBuilder : DbConnectionStringBuilder { private enum Keywords @@ -528,6 +531,7 @@ private Dictionary GetProviderInfo(string provider) return providerInfo; } + [RequiresDynamicCode(OleDbConnection.TrimWarning)] private sealed class OleDbProviderConverter : StringConverter { private const int DBSOURCETYPE_DATASOURCE_TDP = 1; @@ -599,6 +603,7 @@ internal enum OleDbServiceValues : int Default = ~(ClientCursor | AggregationAfterSession), }; + [RequiresDynamicCode(OleDbConnection.TrimWarning)] internal sealed class OleDbServicesConverter : TypeConverter { private StandardValuesCollection? _standardValues; diff --git a/src/libraries/System.Data.OleDb/src/OleDbDataAdapter.cs b/src/libraries/System.Data.OleDb/src/OleDbDataAdapter.cs index 0ef683f9af61cf..8253b092bb7a0d 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbDataAdapter.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbDataAdapter.cs @@ -4,12 +4,14 @@ using System.ComponentModel; using System.Data.Common; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace System.Data.OleDb { [Designer("Microsoft.VSDesigner.Data.VS.OleDbDataAdapterDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] [ToolboxItem("Microsoft.VSDesigner.Data.VS.OleDbDataAdapterToolboxItem, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] + [RequiresDynamicCode(OleDbConnection.TrimWarning)] public sealed class OleDbDataAdapter : DbDataAdapter, IDbDataAdapter, ICloneable { private static readonly object EventRowUpdated = new object(); diff --git a/src/libraries/System.Data.OleDb/src/OleDbDataReader.cs b/src/libraries/System.Data.OleDb/src/OleDbDataReader.cs index bb84814aff863e..5aed9b32222f6f 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbDataReader.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbDataReader.cs @@ -14,6 +14,7 @@ namespace System.Data.OleDb { + [RequiresDynamicCode(OleDbConnection.TrimWarning)] public sealed class OleDbDataReader : DbDataReader { private readonly CommandBehavior _commandBehavior; diff --git a/src/libraries/System.Data.OleDb/src/OleDbEnumerator.cs b/src/libraries/System.Data.OleDb/src/OleDbEnumerator.cs index c129596108615f..070cc703293dc9 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbEnumerator.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbEnumerator.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Data.Common; +using System.Diagnostics.CodeAnalysis; using System.Globalization; namespace System.Data.OleDb @@ -12,6 +13,9 @@ public OleDbEnumerator() { } +#if NET + [RequiresDynamicCode(OleDbConnection.TrimWarning)] +#endif public DataTable GetElements() { DataTable dataTable = new DataTable("MSDAENUM"); @@ -21,17 +25,26 @@ public DataTable GetElements() return dataTable; } +#if NET + [RequiresDynamicCode(OleDbConnection.TrimWarning)] +#endif public static OleDbDataReader GetEnumerator(Type type) { return GetEnumeratorFromType(type); } +#if NET + [RequiresDynamicCode(OleDbConnection.TrimWarning)] +#endif internal static OleDbDataReader GetEnumeratorFromType(Type type) { object? value = Activator.CreateInstance(type, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, null, CultureInfo.InvariantCulture, null); return GetEnumeratorReader(value); } +#if NET + [RequiresDynamicCode(OleDbConnection.TrimWarning)] +#endif private static OleDbDataReader GetEnumeratorReader(object? value) { NativeMethods.ISourcesRowset? srcrowset; @@ -66,6 +79,9 @@ private static OleDbDataReader GetEnumeratorReader(object? value) return dataReader; } +#if NET + [RequiresDynamicCode(OleDbConnection.TrimWarning)] +#endif public static OleDbDataReader GetRootEnumerator() { //readonly Guid CLSID_MSDAENUM = new Guid(0xc8b522d0,0x5cf3,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); diff --git a/src/libraries/System.Data.OleDb/src/OleDbFactory.cs b/src/libraries/System.Data.OleDb/src/OleDbFactory.cs index e8d1272d106beb..059a670f1a2be0 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbFactory.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbFactory.cs @@ -2,9 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Data.Common; +using System.Diagnostics.CodeAnalysis; namespace System.Data.OleDb { + [RequiresDynamicCode(OleDbConnection.TrimWarning)] public sealed class OleDbFactory : DbProviderFactory { public static readonly OleDbFactory Instance = new OleDbFactory(); diff --git a/src/libraries/System.Data.OleDb/src/OleDbMetaDataFactory.cs b/src/libraries/System.Data.OleDb/src/OleDbMetaDataFactory.cs index f07aecefb55f69..601ee56bb0874a 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbMetaDataFactory.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbMetaDataFactory.cs @@ -4,12 +4,14 @@ using System.Data.Common; using System.Data.ProviderBase; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Text; namespace System.Data.OleDb { + [RequiresDynamicCode(OleDbConnection.TrimWarning)] internal sealed class OleDbMetaDataFactory : DbMetaDataFactory { // V1.2.3300 diff --git a/src/libraries/System.Data.OleDb/src/OleDbTransaction.cs b/src/libraries/System.Data.OleDb/src/OleDbTransaction.cs index fd7fd548e0b85a..3099e82752447f 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbTransaction.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbTransaction.cs @@ -4,11 +4,13 @@ using System.Data.Common; using System.Data.ProviderBase; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Data.OleDb { + [RequiresDynamicCode(OleDbConnection.TrimWarning)] public sealed class OleDbTransaction : DbTransaction { private readonly OleDbTransaction? _parentTransaction; // strong reference to keep parent alive diff --git a/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs b/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs index 4fc5470229df12..feb7274616730d 100644 --- a/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs +++ b/src/libraries/System.Data.OleDb/src/OleDbWrapper.cs @@ -4,6 +4,7 @@ using System.Data.Common; using System.Data.ProviderBase; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -11,6 +12,7 @@ namespace System.Data.OleDb { // SafeHandle wrapper around 'DataLinks' object which pools the native OLE DB providers. // expect 1 per app-domain + [RequiresDynamicCode(OleDbConnection.TrimWarning)] internal sealed class OleDbServicesWrapper : WrappedIUnknown { // we expect to store IDataInitialize instance pointer in base.handle @@ -37,7 +39,7 @@ internal OleDbServicesWrapper(object? unknown) : base() // since IDataInitialize is a public,shipped COM interface, its layout will not change (ever) IntPtr vtable = Marshal.ReadIntPtr(base.handle, 0); IntPtr method = Marshal.ReadIntPtr(vtable, 3 * IntPtr.Size); // GetDataSource is the 4'th vtable entry - DangerousIDataInitializeGetDataSource = (UnsafeNativeMethods.IDataInitializeGetDataSource)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IDataInitializeGetDataSource)); + DangerousIDataInitializeGetDataSource = Marshal.GetDelegateForFunctionPointer(method); } } @@ -143,7 +145,7 @@ internal unsafe OleDbHResult InitializeAndCreateSession(OleDbConnectionString co // we double check before each usage to verify the delegates function pointer if ((null == QueryInterface) || (method != Marshal.GetFunctionPointerForDelegate(QueryInterface))) { - QueryInterface = (UnsafeNativeMethods.IUnknownQueryInterface)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IUnknownQueryInterface)); + QueryInterface = Marshal.GetDelegateForFunctionPointer(method); constr.DangerousDataSourceIUnknownQueryInterface = QueryInterface; } @@ -160,7 +162,7 @@ internal unsafe OleDbHResult InitializeAndCreateSession(OleDbConnectionString co // we double check before each usage to verify the delegates function pointer if ((null == Initialize) || (method != Marshal.GetFunctionPointerForDelegate(Initialize))) { - Initialize = (UnsafeNativeMethods.IDBInitializeInitialize)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IDBInitializeInitialize)); + Initialize = Marshal.GetDelegateForFunctionPointer(method); constr.DangerousIDBInitializeInitialize = Initialize; } @@ -189,7 +191,7 @@ internal unsafe OleDbHResult InitializeAndCreateSession(OleDbConnectionString co // we double check before each usage to verify the delegates function pointer if ((null == CreateSession) || (method != Marshal.GetFunctionPointerForDelegate(CreateSession))) { - CreateSession = (UnsafeNativeMethods.IDBCreateSessionCreateSession)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IDBCreateSessionCreateSession)); + CreateSession = Marshal.GetDelegateForFunctionPointer(method); constr.DangerousIDBCreateSessionCreateSession = CreateSession; } @@ -335,7 +337,7 @@ internal unsafe void QueryInterfaceIDBCreateCommand(OleDbConnectionString constr // since IUnknown is a public,shipped COM interface, its layout will not change (ever) IntPtr vtable = Marshal.ReadIntPtr(base.handle, 0); IntPtr method = Marshal.ReadIntPtr(vtable, 0); - UnsafeNativeMethods.IUnknownQueryInterface QueryInterface = (UnsafeNativeMethods.IUnknownQueryInterface)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IUnknownQueryInterface)); + UnsafeNativeMethods.IUnknownQueryInterface QueryInterface = Marshal.GetDelegateForFunctionPointer(method); int hresult; fixed (Guid* riid = &ODB.IID_IDBCreateCommand) @@ -347,7 +349,7 @@ internal unsafe void QueryInterfaceIDBCreateCommand(OleDbConnectionString constr vtable = Marshal.ReadIntPtr(idbCreateCommand, 0); method = Marshal.ReadIntPtr(vtable, 3 * IntPtr.Size); - DangerousIDBCreateCommandCreateCommand = (UnsafeNativeMethods.IDBCreateCommandCreateCommand)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IDBCreateCommandCreateCommand)); + DangerousIDBCreateCommandCreateCommand = Marshal.GetDelegateForFunctionPointer(method); constr.DangerousIDBCreateCommandCreateCommand = DangerousIDBCreateCommandCreateCommand; } @@ -388,7 +390,7 @@ internal void VerifyIDBCreateCommand(OleDbConnectionString constr) // we double check before each usage to verify the delegates function pointer if ((null == CreateCommand) || (method != Marshal.GetFunctionPointerForDelegate(CreateCommand))) { - CreateCommand = (UnsafeNativeMethods.IDBCreateCommandCreateCommand)Marshal.GetDelegateForFunctionPointer(method, typeof(UnsafeNativeMethods.IDBCreateCommandCreateCommand)); + CreateCommand = Marshal.GetDelegateForFunctionPointer(method); constr.DangerousIDBCreateCommandCreateCommand = CreateCommand; } // since this instance can be used to create multiple commands diff --git a/src/libraries/System.Data.OleDb/src/OleDb_Util.cs b/src/libraries/System.Data.OleDb/src/OleDb_Util.cs index 961e0c050f0f26..b6881ba53000c4 100644 --- a/src/libraries/System.Data.OleDb/src/OleDb_Util.cs +++ b/src/libraries/System.Data.OleDb/src/OleDb_Util.cs @@ -559,16 +559,16 @@ internal static InvalidOperationException IDBInfoNotSupported() internal static readonly bool IsRunningOnX86 = RuntimeInformation.ProcessArchitecture == Architecture.X86; - /*internal static readonly int SizeOf_tagDBPARAMINFO = Marshal.SizeOf(typeof(tagDBPARAMINFO));*/ - internal static readonly int SizeOf_tagDBBINDING = Marshal.SizeOf(typeof(tagDBBINDING)); - internal static readonly int SizeOf_tagDBCOLUMNINFO = Marshal.SizeOf(typeof(tagDBCOLUMNINFO)); - internal static readonly int SizeOf_tagDBLITERALINFO = Marshal.SizeOf(typeof(tagDBLITERALINFO)); - internal static readonly int SizeOf_tagDBPROPSET = Marshal.SizeOf(typeof(tagDBPROPSET)); - internal static readonly int SizeOf_tagDBPROP = IsRunningOnX86 ? Marshal.SizeOf(typeof(tagDBPROP_x86)) : Marshal.SizeOf(typeof(tagDBPROP)); - internal static readonly int SizeOf_tagDBPROPINFOSET = Marshal.SizeOf(typeof(tagDBPROPINFOSET)); - internal static readonly int SizeOf_tagDBPROPINFO = IsRunningOnX86 ? Marshal.SizeOf(typeof(tagDBPROPINFO_x86)) : Marshal.SizeOf(typeof(tagDBPROPINFO)); - internal static readonly int SizeOf_tagDBPROPIDSET = Marshal.SizeOf(typeof(tagDBPROPIDSET)); - internal static readonly int SizeOf_Guid = Marshal.SizeOf(typeof(Guid)); + /*internal static readonly int SizeOf_tagDBPARAMINFO = Marshal.SizeOf();*/ + internal static readonly int SizeOf_tagDBBINDING = Marshal.SizeOf(); + internal static readonly int SizeOf_tagDBCOLUMNINFO = Marshal.SizeOf(); + internal static readonly int SizeOf_tagDBLITERALINFO = Marshal.SizeOf(); + internal static readonly int SizeOf_tagDBPROPSET = Marshal.SizeOf(); + internal static readonly int SizeOf_tagDBPROP = IsRunningOnX86 ? Marshal.SizeOf() : Marshal.SizeOf(); + internal static readonly int SizeOf_tagDBPROPINFOSET = Marshal.SizeOf(); + internal static readonly int SizeOf_tagDBPROPINFO = IsRunningOnX86 ? Marshal.SizeOf() : Marshal.SizeOf(); + internal static readonly int SizeOf_tagDBPROPIDSET = Marshal.SizeOf(); + internal static readonly int SizeOf_Guid = Marshal.SizeOf(); internal static readonly int SizeOf_Variant = 8 + (2 * IntPtr.Size); // 16 on 32bit, 24 on 64bit internal static readonly int OffsetOf_tagDBPROP_Status = IsRunningOnX86 ? Marshal.OffsetOf(typeof(tagDBPROP_x86), "dwStatus").ToInt32() : Marshal.OffsetOf(typeof(tagDBPROP), "dwStatus").ToInt32(); diff --git a/src/libraries/System.Data.OleDb/src/System.Data.OleDb.csproj b/src/libraries/System.Data.OleDb/src/System.Data.OleDb.csproj index c750562b756c6b..91422a3cde6375 100644 --- a/src/libraries/System.Data.OleDb/src/System.Data.OleDb.csproj +++ b/src/libraries/System.Data.OleDb/src/System.Data.OleDb.csproj @@ -12,6 +12,7 @@ $(NoWarn);CS3016 false true + true Provides a collection of classes for OLEDB. Commonly Used Types: diff --git a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbBuffer.cs b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbBuffer.cs index 7b089085879bbc..9421102c20b9b8 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbBuffer.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbBuffer.cs @@ -353,11 +353,11 @@ protected override unsafe bool ReleaseHandle() return true; } - private void StructureToPtr(int offset, object structure) + private void StructureToPtr(int offset, T structure) { Debug.Assert(null != structure, "null structure"); offset += BaseOffset; - ValidateCheck(offset, Marshal.SizeOf(structure.GetType())); + ValidateCheck(offset, Marshal.SizeOf()); Debug.Assert(0 == offset % IntPtr.Size, "invalid alignment"); bool mustRelease = false; @@ -367,7 +367,7 @@ private void StructureToPtr(int offset, object structure) DangerousAddRef(ref mustRelease); IntPtr ptr = ADP.IntPtrOffset(DangerousGetHandle(), offset); - Marshal.StructureToPtr(structure, ptr, false/*fDeleteOld*/); + Marshal.StructureToPtr(structure, ptr, false/*fDeleteOld*/); } finally { diff --git a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionHelper.cs b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionHelper.cs index 13eee27ff776e8..0251a3ec131da6 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionHelper.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbConnectionHelper.cs @@ -4,6 +4,7 @@ using System.Data.Common; using System.Data.ProviderBase; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Threading; using SysTx = System.Transactions; @@ -45,6 +46,7 @@ private void CopyFrom(OleDbConnection connection) private static DbConnectionFactory ConnectionFactory { + [RequiresDynamicCode(OleDbConnection.TrimWarning)] get { return _connectionFactory; diff --git a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbMetaDataFactory.cs b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbMetaDataFactory.cs index 1ace12d34a134c..9a66324d50f8fa 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbMetaDataFactory.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbMetaDataFactory.cs @@ -32,6 +32,7 @@ internal class DbMetaDataFactory private const string _sqlCommand = "SQLCommand"; private const string _prepareCollection = "PrepareCollection"; + [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Members from serialized types may use dynamic code generation.")] public DbMetaDataFactory(Stream xmlStream, string serverVersion, string normalizedServerVersion) { ADP.CheckArgumentNull(xmlStream, "xmlStream");