KEMBAR78
Fix trimming warnings in Microsoft.Data.Sqlite by ajcvickers · Pull Request #30728 · dotnet/efcore · GitHub
Skip to content

Conversation

@ajcvickers
Copy link
Contributor

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 a team and bricelam 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