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

Make the assembly trimmable #2460

Open
kerams opened this issue Apr 20, 2022 · 1 comment
Open

Make the assembly trimmable #2460

kerams opened this issue Apr 20, 2022 · 1 comment

Comments

@kerams
Copy link

kerams commented Apr 20, 2022

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

@pakrym-stripe
Copy link
Contributor

Hi, @kerams. I think it's a very good idea. Unfortunately it involves a large amount of non-trivial work so it might take use a while to get to it.

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

No branches or pull requests

2 participants