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

[Bug]: exception with TrimMode full: "URL /path/{id} has parameter id, but no method parameter matches" #1655

Open
entdark opened this issue Feb 14, 2024 · 1 comment
Labels

Comments

@entdark
Copy link

entdark commented Feb 14, 2024

Describe the bug 🐞

Trying to use TrimMode with value full in an iOS .NET8 project in Release configuration.
The app crashes on startup when we are creating an API service with Refit with exception:
Terminating app due to uncaught exception 'System.ArgumentException', reason: 'URL /path/{id} has parameter id, but no method parameter matches (System.ArgumentException)

Step to reproduce

  1. Add <TrimMode>full</TrimMode> to any Refit-based .NET8 iOS project into Release configuration
  2. Compile and deploy to a device or simulator
  3. Start the app
  4. Expect a crash on the moment of API services creation
  5. Check Console app for the logs with the exception above

Reproduction repository

No response

Expected behavior

A trimmed app starts without crashes and all API services get registered without exception.

Screenshots 🖼️

No response

IDE

Visual Studio for Mac

Operating system

macOS

Version

Sonoma 14.0

Device

iPhone 12 mini

Refit Version

7.0.0

Additional information ℹ️

It works fine in Debug or without TrimMode in Release.
There is also a workaround to add [AliasAs("id")] to each API method.

[Get("/path")]
Task<Response> GetPathAsync(int id, CancellationToken ct); // CRASH

[Get("/path")]
Task<Response> GetPathAsync([AliasAs("id")] int id, CancellationToken ct); // WORKS

But there are of lot of methods so it's better to be some global fix.

@entdark entdark added the bug label Feb 14, 2024
@hansmbakker
Copy link
Contributor

This seems to be related to #1389

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

No branches or pull requests

2 participants