Description
Similar to dotnet/runtime#36721, we should consider reducing code duplication for large chunks of code.
For example, the StackTrace
code is currently compiled into 3 assemblies. 2 of these are used by default in the dotnet new api
template. By combining this code into a single .dll, (see bed28aa), I was able to reduce the final app size by 30 KB.
before
9.66 MB (10,130,432 bytes)
after
9.63 MB (10,099,200 bytes)
From inspecting the mstat file, you can see that the Http.Extensions assembly got larger, but the Diagnostics and Hosting assemblies got smaller.
The drawback to this is we either need to:
- Make these APIs public
- Use InternalsVisibleTo
Using InternalsVisibleTo isn't that bad if the assemblies always ship together. If they ship in separate NuGet packages, which may version differently or get out-of-sync, this seems like a bad idea. For this instance though, the Diagnostics and Hosting assemblies only ship in the ASP.NET Core shared framework. So they version/update together.