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

Fix trimming warnings in Microsoft.Data.Sqlite #30728

Merged
merged 1 commit into from
Apr 19, 2023
Merged

Conversation

ajcvickers
Copy link
Member

Fixes #29725

There were two types of issue:

  • In SqliteConnection, the linker was unable to determine the type returned by the GetType call. Fixed by explicitly specifying the type.
  • In SqliteDataReader, GetFieldType on the base has been annotated with DynamicallyAccessedMembers, which needed to be flowed through to called methods.

Tested with code from Nanorm

After fixes:

PS C:\local\code\TrimTest\TrimTest> dotnet publish -f net8.0 -r win10-x64 --self-contained -v m --nologo -o pub
  Determining projects to restore...
  Restored C:\local\code\TrimTest\TrimTest\TrimTest.csproj (in 283 ms).
  Restored C:\local\code\TrimTest\Nanorm.Sqlite\Nanorm.Sqlite.csproj (in 283 ms).
  Restored C:\local\code\TrimTest\Nanorm\Nanorm.csproj (in 283 ms).
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\local\code\TrimTest\TrimTest\TrimTest.csproj]
  Nanorm -> C:\local\code\TrimTest\Nanorm\bin\Release\net8.0\Nanorm.dll
  Nanorm.Sqlite -> C:\local\code\TrimTest\Nanorm.Sqlite\bin\Release\net8.0\Nanorm.Sqlite.dll
  TrimTest -> C:\local\code\TrimTest\TrimTest\bin\Release\net8.0\win10-x64\TrimTest.dll
  Generating native code
  TrimTest -> C:\local\code\TrimTest\TrimTest\pub\

Fixes #29725

There were two types of issue:

- In SqliteConnection, the linker was unable to determine the type returned by the `GetType` call. Fixed by explicitly specifying the type.
- In SqliteDataReader, `GetFieldType` on the base has been annotated with `DynamicallyAccessedMembers`, which needed to be flowed through to called methods.

Tested with code from [Nanorm](https://github.com/DamianEdwards/Nanorm/tree/main/samples/Nanorm.Samples.Console.Todos.Sqlite)

After fixes:

```
PS C:\local\code\TrimTest\TrimTest> dotnet publish -f net8.0 -r win10-x64 --self-contained -v m --nologo -o pub
  Determining projects to restore...
  Restored C:\local\code\TrimTest\TrimTest\TrimTest.csproj (in 283 ms).
  Restored C:\local\code\TrimTest\Nanorm.Sqlite\Nanorm.Sqlite.csproj (in 283 ms).
  Restored C:\local\code\TrimTest\Nanorm\Nanorm.csproj (in 283 ms).
C:\Program Files\dotnet\sdk\8.0.100-preview.3.23178.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(287,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\local\code\TrimTest\TrimTest\TrimTest.csproj]
  Nanorm -> C:\local\code\TrimTest\Nanorm\bin\Release\net8.0\Nanorm.dll
  Nanorm.Sqlite -> C:\local\code\TrimTest\Nanorm.Sqlite\bin\Release\net8.0\Nanorm.Sqlite.dll
  TrimTest -> C:\local\code\TrimTest\TrimTest\bin\Release\net8.0\win10-x64\TrimTest.dll
  Generating native code
  TrimTest -> C:\local\code\TrimTest\TrimTest\pub\
```
@ajcvickers ajcvickers requested review from bricelam and a team April 18, 2023 20:51
@ajcvickers ajcvickers merged commit d4599b1 into main Apr 19, 2023
@ajcvickers ajcvickers deleted the ModelBuilding0418 branch April 19, 2023 09:13
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.

NativeAOT/trimming compatibility for Microsoft.Data.Sqlite
2 participants