Skip to content
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

Enable AOT compatibility for Yarp.Telemetry.Consumption #2146

Merged
merged 2 commits into from
May 24, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Diagnostics.CodeAnalysis;
using k8s;
using k8s.Models;
using Microsoft.Extensions.Configuration;
Expand Down Expand Up @@ -122,7 +123,7 @@ public static IServiceCollection RegisterResourceInformer<TResource, TService>(t
/// <param name="services">The services.</param>
/// <param name="fieldSelector">A field selector to constrain the resources the informer retrieves.</param>
/// <returns>IServiceCollection.</returns>
public static IServiceCollection RegisterResourceInformer<TResource, TService>(this IServiceCollection services, string fieldSelector)
public static IServiceCollection RegisterResourceInformer<TResource, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TService>(this IServiceCollection services, string fieldSelector)
where TResource : class, IKubernetesObject<V1ObjectMeta>, new()
where TService : IResourceInformer<TResource>
{
Expand Down
5 changes: 3 additions & 2 deletions src/TelemetryConsumption/TelemetryConsumptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Yarp.Telemetry.Consumption;

Expand Down Expand Up @@ -86,7 +87,7 @@ public static IServiceCollection AddTelemetryConsumer(this IServiceCollection se
/// <summary>
/// Registers a <typeparamref name="TConsumer"/> singleton for every I*TelemetryConsumer interface it implements.
/// </summary>
public static IServiceCollection AddTelemetryConsumer<TConsumer>(this IServiceCollection services)
public static IServiceCollection AddTelemetryConsumer<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TConsumer>(this IServiceCollection services)
where TConsumer : class
{
var implementsAny = false;
Expand Down Expand Up @@ -201,7 +202,7 @@ public static IServiceCollection AddMetricsConsumer(this IServiceCollection serv
/// <summary>
/// Registers a consumer singleton for every IMetricsConsumer interface it implements.
/// </summary>
public static IServiceCollection AddMetricsConsumer<TConsumer>(this IServiceCollection services)
public static IServiceCollection AddMetricsConsumer<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] TConsumer>(this IServiceCollection services)
where TConsumer : class
{
var implementsAny = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<OutputType>Library</OutputType>
<RootNamespace>Yarp.Telemetry.Consumption</RootNamespace>
<Nullable>enable</Nullable>
<IsAotCompatible>true</IsAotCompatible>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

Expand Down