dotnet / SqlClient

Microsoft.Data.SqlClient provides database connectivity to SQL Server for .NET applications.
MIT License
839 stars 280 forks source link

NativeAOT support: get to zero warnings #1947

Open roji opened 1 year ago

roji commented 1 year ago

Right now, when publishing a NativeAOT app using SqlClient, many warnings are emitted. To properly support NativeAOT, SqlClient will need to get to a place where no warnings are emitted, so the user can be 100% confident that the application will function correctly.

Note that this is related, but not the same as #1942, which is about reducing the binary size. However, the same technique can be used for both: if an entry point (e.g. slim data source builder) is introduced, which by default doesn't include functionality that is large and/or unsafe for NativeAOT, then programs not explicitly bringing in that functionality won't get warnings etc.

kant2002 commented 1 year ago

I add project settings to be enable trimming analysis here https://github.com/dotnet/SqlClient/pull/1943 , That allow bookkeeping warnings which should be fixed.

lozn00 commented 1 year ago

This error did not appear before, is it a compatibility issue with different 7.0 versions of aot? I plan to downgrade, but uninstalling directly is difficult to downgrade @jkotas

lozn00 commented 1 year ago

I tried uninstalling the application using aspnetcore-runtime-7.0.5-win-x64 dotnet-sdk-7.0.302-win-x64 (1) or after the window->installed application was uninstalled, I still see 7.0.5 when using dotnet --info, this 7.0.5 is buggy, bug A type initializer threw an exception home computer uses 7.0.4 to test sql The client library is normal.

So, I directly used dotnet --infoto get the 7.0.5 folder, and directly brute-deleted it, but got other headaches fatal error LNK1123: 转换到 COFF 期间失败

I also upgraded to net 8.0 but also got some bugs that frustrated me very much System.MissingMethodException

Before I reinstalled the computer, my source code worked, I reinstalled the computer, the version of the computer was .net 7.0.5 Therefore, I think that I was able to work properly because I used an old version of .NET 7.0