Description
Switching the ASP.NET Core's TodosApi benchmark app (a.k.a. "Stage 2") to use the Microsoft.Extensions.Options validation source generator causes the app to go from 18.1 MB
to 19.5 MB
on win-x64
.
Repro steps
- Clone https://github.com/aspnet/Benchmarks
- cd src\BenchmarksApps\TodosApi
- dotnet publish
- Checkout eerhardt/Benchmarks@c667d28
- dotnet publish
Expected result
The 2 publishes should result in roughly the same size app
Actual result
The 2nd app is almost 8% larger (18.1 => 19.5).
Logs
You can open the following in sizoscope to view the difference between the apps.
todos-before.zip
todos-after.zip
Doing an initial investigation, I believe what is happening is that including System.ComponentModel code into the graph causes ICustomTypeDescriptor
to be included, which since Npgsql's ConnectionStringBuilder (and our System.Data.Common ConnectionStringBuilder) implements ICustomTypeDescriptor. In order to make that usage trim-compatible, we added [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
to the base DbConnectionStringBuilder. That class is also an IDictionary, which means all interface methods on the collection types are being preserved - across every collection in the app.
Related: #97057