-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add trim/AOT annotations to make code trim/AOT-safe #1222
base: master
Are you sure you want to change the base?
Add trim/AOT annotations to make code trim/AOT-safe #1222
Conversation
To reduce all these changes and the sheer number of I have been doing for Skia and MAUI: https://github.com/mono/SkiaSharp/blob/main/source/Common/NullableAttributes.generated.cs The attributes are ignored anyway on netstandard. |
@mattleibow I thought about that (in fact I was just going to use PolySharp), but I decided not to because from my understanding SQLite-net also supports source-only mode. In that case if you were to define local attributes you could also get into weird situations if consumers already have polyfills for those (which is not uncommon), and you could get anything from warnings to build errors due to amboguous type references. Thoughts? |
hmm, ok yeah, the source only mode will be more annoying. You could wrap the polyfills in a new So yeah, I see the better choice really is these |
@@ -752,7 +953,18 @@ public CreateTableResult CreateTable (Type ty, CreateFlags createFlags = CreateF | |||
/// <returns> | |||
/// Whether the table was created or migrated for each type. | |||
/// </returns> | |||
public CreateTablesResult CreateTables<T, T2> (CreateFlags createFlags = CreateFlags.None) | |||
#if NET8_0_OR_GREATER | |||
[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "This method preserves metata for all type arguments.")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor spelling mistake
#if NET8_0_OR_GREATER | ||
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] | ||
#endif | ||
T, | ||
#if NET8_0_OR_GREATER | ||
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] | ||
#endif | ||
T2, | ||
#if NET8_0_OR_GREATER | ||
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to have it all inside of a single #ifdef
?
Closes #1218
This PR adds all trimming and AOT annotations to the code to make the codebase trim/AOT-safe. There's no functional changes introduced in this PR, other than removing the fast column accessor for all value types on NAOT, as that would otherwise throw (and generally just be unsupported code due to the AOT warning we'd have to suppress otherwise). It should still work, just take the slower reflection-based fallback path in that case. In order to allow all annotations to correctly flow to consumers, all projects have also been switched to multi-targeting, with the .NET 8 TFM being added as well.