Skip to content

Conversation

agocke
Copy link
Member

@agocke agocke commented Aug 12, 2025

This specifically addresses IL3050 warnings (ones generated as part of AOT-compat). Contributes to #75480

This specifically addresses IL3050 warnings (ones generated as part of
AOT-compat). Contributes to dotnet#75480
@Copilot Copilot AI review requested due to automatic review settings August 12, 2025 05:07
Copy link
Contributor

@Copilot Copilot AI left a 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 generic Marshal.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

@agocke agocke requested a review from a team August 12, 2025 05:08
Copy link
Contributor

Tagging subscribers to this area: @roji, @SamMonoRT
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jtschuster jtschuster left a 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.

@SamMonoRT SamMonoRT requested a review from AndriySvyryd August 13, 2025 12:32
@agocke agocke merged commit 175917c into dotnet:main Aug 15, 2025
79 of 82 checks passed
@agocke agocke deleted the oledb branch August 15, 2025 02:51
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants