Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/libraries/System.Data.OleDb/ref/System.Data.OleDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
Expand Down Expand Up @@ -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() { }
Expand Down Expand Up @@ -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() { }
Expand All @@ -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() { }
Expand Down Expand Up @@ -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() { }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() { }
Expand Down Expand Up @@ -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() { }
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Data.OleDb/src/OleDbCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/libraries/System.Data.OleDb/src/OleDbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.Data.OleDb/src/OleDbConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
Expand Down
12 changes: 10 additions & 2 deletions src/libraries/System.Data.OleDb/src/OleDbConnectionInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
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;
using SysTx = System.Transactions;

namespace System.Data.OleDb
{
#if NET
[RequiresDynamicCode(OleDbConnection.TrimWarning)]
#endif
internal sealed class OleDbConnectionInternal : DbConnectionInternal, IDisposable
{
private static volatile OleDbServicesWrapper? idataInitialize;
Expand Down Expand Up @@ -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<tagDBLITERALINFO>((IntPtr)offset)!;

DataRow row = table.NewRow();
row[literalName] = ((OleDbLiteral)tag.it).ToString();
Expand Down Expand Up @@ -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<Guid>(ptr)!;
}
}
if (IntPtr.Zero != schemaRestrictions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -528,6 +531,7 @@ private Dictionary<string, OleDbPropertyInfo> GetProviderInfo(string provider)
return providerInfo;
}

[RequiresDynamicCode(OleDbConnection.TrimWarning)]
private sealed class OleDbProviderConverter : StringConverter
{
private const int DBSOURCETYPE_DATASOURCE_TDP = 1;
Expand Down Expand Up @@ -599,6 +603,7 @@ internal enum OleDbServiceValues : int
Default = ~(ClientCursor | AggregationAfterSession),
};

[RequiresDynamicCode(OleDbConnection.TrimWarning)]
internal sealed class OleDbServicesConverter : TypeConverter
{
private StandardValuesCollection? _standardValues;
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.Data.OleDb/src/OleDbDataAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Data.OleDb/src/OleDbDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace System.Data.OleDb
{
[RequiresDynamicCode(OleDbConnection.TrimWarning)]
public sealed class OleDbDataReader : DbDataReader
{
private readonly CommandBehavior _commandBehavior;
Expand Down
16 changes: 16 additions & 0 deletions src/libraries/System.Data.OleDb/src/OleDbEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -12,6 +13,9 @@ public OleDbEnumerator()
{
}

#if NET
[RequiresDynamicCode(OleDbConnection.TrimWarning)]
#endif
public DataTable GetElements()
{
DataTable dataTable = new DataTable("MSDAENUM");
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.Data.OleDb/src/OleDbFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.Data.OleDb/src/OleDbMetaDataFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/libraries/System.Data.OleDb/src/OleDbTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions src/libraries/System.Data.OleDb/src/OleDbWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
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
{
// 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
Expand All @@ -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<UnsafeNativeMethods.IDataInitializeGetDataSource>(method);
}
}

Expand Down Expand Up @@ -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<UnsafeNativeMethods.IUnknownQueryInterface>(method);
constr.DangerousDataSourceIUnknownQueryInterface = QueryInterface;
}

Expand All @@ -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<UnsafeNativeMethods.IDBInitializeInitialize>(method);
constr.DangerousIDBInitializeInitialize = Initialize;
}

Expand Down Expand Up @@ -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<UnsafeNativeMethods.IDBCreateSessionCreateSession>(method);
constr.DangerousIDBCreateSessionCreateSession = CreateSession;
}

Expand Down Expand Up @@ -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<UnsafeNativeMethods.IUnknownQueryInterface>(method);

int hresult;
fixed (Guid* riid = &ODB.IID_IDBCreateCommand)
Expand All @@ -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<UnsafeNativeMethods.IDBCreateCommandCreateCommand>(method);
constr.DangerousIDBCreateCommandCreateCommand = DangerousIDBCreateCommandCreateCommand;
}

Expand Down Expand Up @@ -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<UnsafeNativeMethods.IDBCreateCommandCreateCommand>(method);
constr.DangerousIDBCreateCommandCreateCommand = CreateCommand;
}
// since this instance can be used to create multiple commands
Expand Down
Loading
Loading