Add switch for trim out ConfigurationManager support#83023
Add switch for trim out ConfigurationManager support#83023kant2002 wants to merge 4 commits intodotnet:mainfrom
Conversation
With this change you can shave 900Kb out of 25.8Mb from sample SqlClient app from here dotnet/SqlClient#1941 (comment) Other example is that usage of `System.Runtime.Caching.MemoryCache` as shown in https://learn.microsoft.com/en-us/dotnet/api/system.runtime.caching.memorycache Applying configuration switch reduce app size by 5.2Mb (from 7.8Mb to 2.6Mb) Most likely modern applications which are first to use NativeAOT would not need this functionality because they use other means for configuration, so would be great to have this disabled. Low drop in size in SqlClient coming from fact that there other large dependencies which keep Xml related code around.
|
Tagging subscribers to this area: @dotnet/area-system-configuration Issue DetailsWith this change you can shave 900Kb out of 25.8Mb from sample SqlClient app from here dotnet/SqlClient#1941 (comment) Other example is that usage of Applying configuration switch reduce app size by 5.2Mb (from 7.8Mb to 2.6Mb) Most likely modern applications which are first to use NativeAOT would not need this functionality because they use other means for configuration, so would be great to have this disabled. Low drop in size in SqlClient coming from fact that there other large dependencies which keep Xml related code around. Discovered as part of dotnet/SqlClient#1942
|
|
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr Issue DetailsWith this change you can shave 900Kb out of 25.8Mb from sample SqlClient app from here dotnet/SqlClient#1941 (comment) Other example is that usage of Applying configuration switch reduce app size by 5.2Mb (from 7.8Mb to 2.6Mb) Most likely modern applications which are first to use NativeAOT would not need this functionality because they use other means for configuration, so would be great to have this disabled. Low drop in size in SqlClient coming from fact that there other large dependencies which keep Xml related code around. Discovered as part of dotnet/SqlClient#1942
|
|
I wonder if it would be better if we changed these "up stack" libraries to no longer use ConfigurationManager. Cutting it off inside ConfigurationManager is probably going to lead to "random" runtime errors when some untested path calls into ConfigurationManager, and it throws. |
|
Oops! I definitely go overboard with some changes. My idea was to always return null when call
Regarding your question. In specific case of SqlClient the libraries which require |
eerhardt
left a comment
There was a problem hiding this comment.
I think we should consider removing dependencies upstack on ConfigurationManager. It is a legacy component that we haven't been making investments in. See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Configuration.ConfigurationManager/README.md
This library exists only to support migrating existing .NET Framework code that uses System.Configuration.
| <PropertyGroup> | ||
| <IsPartialFacadeAssembly Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework'">true</IsPartialFacadeAssembly> | ||
| <!-- ILLinker settings --> | ||
| <ILLinkDirectory>$(MSBuildThisFileDirectory)ILLink\</ILLinkDirectory> |
There was a problem hiding this comment.
You shouldn't need this. It is already set in
Line 10 in 340d1f2
...s/System.Configuration.ConfigurationManager/src/System/Configuration/ConfigurationManager.cs
Outdated
Show resolved
Hide resolved
…stem/Configuration/ConfigurationManager.cs Co-authored-by: Eric Erhardt <[email protected]>
I would like to remove |
|
@kant2002 see my comment in the SqlClient repo. tl;dr I think SqlClient needs to have a "slim" entry point for size-sensitive users, rather than introduce feature switches around ConfigurationManager (and other components). |
|
@kant2002 thanks for the PR but closing based on feedback
|
With this change you can shave 900Kb out of 25.8Mb from sample SqlClient app from here dotnet/SqlClient#1941 (comment)
Other example is that usage of
System.Runtime.Caching.MemoryCacheas shown in https://learn.microsoft.com/en-us/dotnet/api/system.runtime.caching.memorycacheApplying configuration switch reduce app size by 5.2Mb (from 7.8Mb to 2.6Mb)
Most likely modern applications which are first to use NativeAOT would not need this functionality because they use other means for configuration, so would be great to have this disabled.
Low drop in size in SqlClient coming from fact that there other large dependencies which keep Xml related code around.
Discovered as part of dotnet/SqlClient#1942