Skip to content

Comments

Add AOT compatibility.#18

Merged
prochnowc merged 15 commits intomainfrom
aot-compat
Jun 26, 2025
Merged

Add AOT compatibility.#18
prochnowc merged 15 commits intomainfrom
aot-compat

Conversation

@prochnowc
Copy link
Collaborator

No description provided.

@prochnowc prochnowc requested a review from Copilot May 22, 2025 18:34

This comment was marked as outdated.

@prochnowc prochnowc requested a review from Copilot June 3, 2025 20:16
Copy link

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

Adds ahead-of-time (AOT) compatibility support by annotating reflection-based builders and activators with trimming-safe attributes, introducing runtime guards for generic type and array instantiation under AOT, and simplifying facility extension code.

  • Annotate reflection-based AddResolver methods and activator APIs with [DynamicallyAccessedMembers]
  • Introduce VerifyAotCompatibility checks and throw when dynamic code or value‐type arrays are unavailable under AOT
  • Refactor facility/extension builders to use a non‐generic base interface and remove the wrapper helper

Reviewed Changes

Copilot reviewed 84 out of 84 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ServiceDescriptorReflectionBuilder.cs Added [DynamicallyAccessedMembers] to the generic AddResolver
ServiceCollectionServiceProvider.cs Reworked GetService/GetServices, added AOT guards and helpers
ReflectionServiceCollectionExtensions.cs Imported System.Diagnostics.CodeAnalysis
IServiceDescriptorReflectionBuilder.cs Annotated generic AddResolver with trimming-safe attribute
FacilityServiceCollectionExtensions.cs Annotated AddFacility overloads, simplified loop
IFacilityReflectionBuilder.cs Annotated generic AddResolver
IFacilityExtensionResolver.cs Changed Resolve to return non-generic IFacilityExtension
IFacilityExtensionReflectionBuilder.cs Annotated generic AddResolver and updated Resolve return type
IFacilityExtension.cs Introduced non-generic IFacilityExtension base interface
FacilityReflectionBuilder.cs Updated to consume non-generic IFacilityExtension
FacilityExtensionWrapper.cs Removed obsolete wrapper class
FacilityExtensionReflectionBuilder.cs Updated Resolve to return non-generic extensions
FacilityBuilder{T}.cs Refactored generic builder to no longer inherit base class
FacilityBuilder.cs Sealed, removed generic wrapper logic
AppCoreNet.Extensions.DependencyInjection.Abstractions.csproj Added <IsAotCompatible> for .NET 8 targeting
Activator/ServiceProviderActivator.cs Annotated CreateInstance parameter
Activator/IActivator.cs Annotated CreateInstance parameter
Activator/DefaultActivator.cs Annotated CreateInstance parameter
Activator/ActivatorExtensions.cs Annotated generic CreateInstance<T>
AppCoreNet.Extensions.sln Added renovate.json to solution items
Comments suppressed due to low confidence (4)

DependencyInjection/src/AppCoreNet.Extensions.DependencyInjection.Abstractions/ServiceCollectionServiceProvider.cs:93

  • Add unit tests covering the AOT exception path in MakeGenericType to ensure that attempting to build a generic type under AOT throws the expected error.
throw new InvalidOperationException(

DependencyInjection/src/AppCoreNet.Extensions.DependencyInjection.Abstractions/ServiceCollectionServiceProvider.cs:145

  • Add tests for the CreateArray AOT guard to verify that building arrays of value types under AOT correctly throws an exception.
if (VerifyAotCompatibility && elementType.IsValueType)

DependencyInjection/src/AppCoreNet.Extensions.DependencyInjection.Abstractions/IFacilityExtensionResolver.cs:19

  • This change from a generic IEnumerable<IFacilityExtension<IFacility>> to a non-generic return type is breaking; consider adding an obsolete overload or bumping the major version.
IEnumerable<IFacilityExtension> Resolve(Type facilityType);

DependencyInjection/src/AppCoreNet.Extensions.DependencyInjection.Abstractions/ServiceCollectionServiceProvider.cs:16

  • [nitpick] The partial keyword was removed; please confirm there are no other partial declarations for ServiceCollectionServiceProvider to prevent compilation errors.
internal sealed class ServiceCollectionServiceProvider : IServiceProvider, IServiceProviderIsService

@prochnowc prochnowc merged commit b2226f4 into main Jun 26, 2025
5 checks passed
@prochnowc prochnowc deleted the aot-compat branch June 26, 2025 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant