-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix RequiresDynamicCode warnings in OleDb #118624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This specifically addresses IL3050 warnings (ones generated as part of AOT-compat). Contributes to dotnet#75480
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes RequiresDynamicCode warnings (IL3050) in the OleDb library to improve AOT compatibility. The changes primarily involve adding RequiresDynamicCode
attributes to classes and methods that use dynamic code generation features like Marshal.GetDelegateForFunctionPointer
and other reflection-based operations.
Key changes include:
- Adding
RequiresDynamicCode
attributes to various OleDb classes and methods - Converting
Marshal.SizeOf(typeof(T))
calls to genericMarshal.SizeOf<T>()
versions - Updating
Marshal.StructureToPtr
and similar methods to use generic overloads - Enabling AOT compatibility by setting
IsAotCompatible
to true in the project file
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
System.Data.OleDb.csproj | Enables AOT compatibility by setting IsAotCompatible to true |
DbMetaDataFactory.cs | Adds RequiresDynamicCode attribute to constructor |
DbConnectionHelper.cs | Adds RequiresDynamicCode attribute to ConnectionFactory getter |
DbBuffer.cs | Converts StructureToPtr method to use generics for AOT compatibility |
OleDb_Util.cs | Updates Marshal.SizeOf calls to use generic versions |
OleDbWrapper.cs | Converts Marshal.GetDelegateForFunctionPointer calls to generic versions and adds class-level attribute |
OleDbTransaction.cs | Adds RequiresDynamicCode attributes to class and methods |
OleDbMetaDataFactory.cs | Adds RequiresDynamicCode attributes to class and constructor |
OleDbFactory.cs | Adds RequiresDynamicCode attribute to class |
OleDbEnumerator.cs | Adds conditional RequiresDynamicCode attributes to methods |
OleDbDataReader.cs | Adds RequiresDynamicCode attributes to class and methods |
OleDbDataAdapter.cs | Adds RequiresDynamicCode attribute to class |
OleDbConnectionStringBuilder.cs | Adds conditional RequiresDynamicCode attributes to class and methods |
OleDbConnectionInternal.cs | Adds conditional RequiresDynamicCode attributes throughout and updates Marshal.PtrToStructure calls |
OleDbConnectionFactory.cs | Adds RequiresDynamicCode attribute and suppression for metadata factory |
OleDbConnection.cs | Adds RequiresDynamicCode attribute to class and defines trim warning constant |
OleDbCommand.cs | Adds RequiresDynamicCode attribute to class |
CompatibilitySuppressions.xml | Adds suppressions for compatibility differences in reference assemblies |
System.Data.OleDb.cs | Updates reference assembly with conditional RequiresDynamicCode attributes |
src/libraries/System.Data.OleDb/src/System/Data/ProviderBase/DbBuffer.cs
Outdated
Show resolved
Hide resolved
Tagging subscribers to this area: @roji, @SamMonoRT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the types with Requires on the type definition, IIRC they shouldn't also need annotations on their instance or static methods.
This specifically addresses IL3050 warnings (ones generated as part of AOT-compat). Contributes to #75480