Skip to content

Conversation

@NinoFloris
Copy link
Member

@NinoFloris NinoFloris commented Sep 20, 2023

Another draft based on #5123 so be sure to just look at the last commits.

These are the remaining missing annotations to be able to switch /src to IsAotCompatible:true

I've detailed the cases that need special mention below:

First off, all our GetSchema and descendants are marked as RUC RequiresUnreferencedCode, this is because the alternative is marking any Type accessible via GetFieldType (so basically any type we have a mapping for) as DynamicallyAccessedMembers.PublicFields | PublicProperties. That IMO is very excessive to enable just that crappy feature. I hope we might be able to find a more palatable alternative...

Secondly we now have RDC RequiresDynamicCode and RUC on our NpgsqlDataSourceBuilder, as we have plenty of reflection and codegen through its default set of resolvers. This builder is referenced by set_ConnectionString (via SetupDataSource) and get_DbProviderFactory (via DbProviderFactory.CreateDataSource). However the base type defining these properties doesn't have RDC and RUC annotations so the analyzer complains that we don't match the base signature. I don't see a better solution here than suppressing that warning. We don't want to mark the entirety of NpgsqlConnection as RDC/RUC, which would normally be the approach to these mismatches.

Finally we have some antique TypeConverter crap on NpgsqlRange, this entire Parse method should probably be redone based on spans and ISpanParsable. I've marked it as RUC for now.

Closes #4414, closes #4800

@NinoFloris NinoFloris force-pushed the aot-compatible branch 4 times, most recently from 6fe8b43 to 2f7fff7 Compare September 25, 2023 22:53
@NinoFloris NinoFloris marked this pull request as ready for review September 25, 2023 22:53
@NinoFloris NinoFloris force-pushed the aot-compatible branch 2 times, most recently from ba63dc2 to 9c3122c Compare September 25, 2023 23:32
# Conflicts:
#	src/Npgsql/TypeMapping/UserTypeMapper.cs
# Conflicts:
#	src/Npgsql/NpgsqlMultiHostDataSource.cs
@NinoFloris NinoFloris merged commit ee24545 into npgsql:main Sep 27, 2023
@NinoFloris NinoFloris deleted the aot-compatible branch September 27, 2023 18:34
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.

Remove trimming/AOT warnings Mark Npgsql as trimmable

2 participants