Skip to content

Make the assembly trimmable #2460

Open
Open
@kerams

Description

Is your feature request related to a problem? Please describe.

Stripe.net's assembly size is around 1.2MB with the version I am referencing. Since I only use a small portion of the API (checkout creation, webhook events, ....), I enabled trimming on the assembly with <TrimmableAssembly Include="Stripe.net" />. With this I get an assembly of just 56KB, but with runtime exceptions when creating a checkout sesssion:

System.AggregateException: One or more errors occurred. (Property Get method was not found.)
 ---> System.ArgumentException: Property Get method was not found.
   at object System.Reflection.RuntimePropertyInfo.GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) x 2
   at List<KeyValuePair<string, object>> Stripe.Infrastructure.FormEncoding.FormEncoder.FlattenParamsOptions(INestedOptions, string)
   at List<KeyValuePair<string, object>> Stripe.Infrastructure.FormEncoding.FormEncoder.FlattenParamsValue(object, string)
   at HttpContent Stripe.Infrastructure.FormEncoding.FormEncoder.CreateHttpContent(BaseOptions)
   at HttpRequestMessage Stripe.SystemNetHttpClient.BuildRequestMessage(StripeRequest)
   at async Task<(HttpResponseMessage responseMessage, int retries)> Stripe.SystemNetHttpClient.SendHttpRequest(StripeRequest, CancellationToken)
   at async Task<StripeResponse> Stripe.SystemNetHttpClient.MakeRequestAsync(StripeRequest, CancellationToken)
   at async Task<T> Stripe.StripeClient.RequestAsync<T>(HttpMethod, string, BaseOptions, RequestOptions, CancellationToken)
   at async Task<T> Stripe.Service<TEntityReturned>.RequestAsync<T>(HttpMethod, string, BaseOptions, RequestOptions, CancellationToken)

The linker obviously removes things that are vital but only accessed via reflection.

Describe the solution you'd like

Make Stripe.net linker-friendly. This will probably require DynamicallyAccessedMembers annotations in a bunch of places.

Describe alternatives you've considered

No response

Additional context

Stripe.net 39.95.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions