Skip to content

Add RequiresUnreferencedCode attribute for reflection code and add OverloadResolutionPriority attribute to prefer non-object methods#50

Merged
jeffijoe merged 3 commits intojeffijoe:masterfrom
Cheesebaron:feature/gh-49-overload-and-requiresunref-code-attrs
Mar 3, 2025
Merged

Add RequiresUnreferencedCode attribute for reflection code and add OverloadResolutionPriority attribute to prefer non-object methods#50
jeffijoe merged 3 commits intojeffijoe:masterfrom
Cheesebaron:feature/gh-49-overload-and-requiresunref-code-attrs

Conversation

@Cheesebaron
Copy link
Contributor

This PR adds RequiresUnreferencedCode attribute on methods that use reflection. This is primarily the convenience methods and extension methods that take an object like: new { hello = "world" } and turns it into a dictionary with key hello which will be equal to the string object "world".

Also added the IsTrimmable = true property on the project, which allows the compiler to trim the library.

For the extension methods that take the object as argument, I've also added the [OverloadResolutionPriority(-1)] attribute to make the compiler prefer the non object overloads.

Fixes #49

@jeffijoe jeffijoe merged commit 79da44e into jeffijoe:master Mar 3, 2025
1 check passed
@Cheesebaron Cheesebaron deleted the feature/gh-49-overload-and-requiresunref-code-attrs branch March 3, 2025 14:34
@jeffijoe
Copy link
Owner

jeffijoe commented Mar 3, 2025

Thanks! Released to NuGet as 7.1.3 👍


Unrelated, but I remember you from the Xamarin forums in the early days of Xamarin, back when I started learning C#, so it was funny to see @Cheesebaron aka Ostebaronen in my inbox again after all these years. 😄

@Cheesebaron
Copy link
Contributor Author

Thanks! Released to NuGet as 7.1.3 👍

Sweet! Thanks!

Unrelated, but I remember you from the Xamarin forums in the early days of Xamarin, back when I started learning C#, so it was funny to see @Cheesebaron aka Ostebaronen in my inbox again after all these years. 😄

Ah, that is cool! The world is small :)

@jeffijoe
Copy link
Owner

jeffijoe commented Mar 3, 2025

The world is small :)

Yeah, even more so because I'm also Danish 😄

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.

Add overload resolution priority

2 participants