Cleanup | Centralise AppContext switches #3492
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We try to centralise all access to SqlClient's AppContext switches via the
LocalAppContextSwitches
class. There are currently a few cases where we don't do this though:The first port of call is to relocate all of these to the existing LocalAppContextSwitches class. This slightly helps in the merge of SqlConnection.
I've also added an
ILLink.Substitutions.xml
resource to the output. This is a trimming improvement, and is documented here. It allows referencing applications to specify aRuntimeHostConfigurationOption
to set an AppContext switch, which the IL trimmer will reference and remove the entire managed or native SNI. There's a little more work to come on this once trimming is ready.For comparison purposes, this is modelled in part on CsWinRT:
RuntimeHostConfigurationOption
I've used sizoscope to verify that I can use RuntimeHostConfigurationOption, publish an application and see the corresponding SNI's types are removed from the output.
Issues
Partially relates to #1261 and #1942.
Testing
Unit tests pass locally.