
This is a list of all System.AppContext base application compatibility switches present in WPF today, along with their defaults and related documentation.
From: https://github.com/vatsan-madhavan/WpfAppCompatQuirks
Thank you Vatsan Madhavan
The compatibility switches can be set by the runtimeconfig.json file in dotnet 5 or greater and it can be set by the App.config file in .NET Framework, and it can also be set programmatically by calling the AppContext.SetSwitch method. See .NET Runtime config options - .NET Microsoft Docs
For example, we can trun on the WM_Pointer support by add the content in the runtimeconfig.template.json file.
{
"configProperties":
{
"Switch.System.Windows.Input.Stylus.EnablePointerSupport": true
}
}You can find all the code in github: https://github.com/lindexi/lindexi_gd/tree/b3c6a4299c3d517a357cc05f045dd3a16ec261e2/WhajecichalLaykeljalha
tfm: target framework moniker, see https://docs.microsoft.com/en-us/dotnet/standard/frameworks
Full Name: MS.Internal.BaseAppContextSwitches.DoNotUseCulturePreservingDispatcherOperations
feature is on when tfm > net452
true if tfm <= net452
false otherwise
Starting .NET 4.6, ExecutionContext tracks Thread.CurrentCulture and Thread.CurrentUICulture, which would be restored to their respective previous values after a call to ExecutionContext.Run. This behavior is undesirable within the Dispatcher - various dispatcher operations can run user code that can in turn set Thread.CurrentCulture or Thread.CurrentUICulture, and we do not want those values to be overwritten with their respective previous values. To work around the new ExecutionContext behavior, we introduce CulturePreservingExecutionContext for use within Dispatcher and DispatcherOperation. WPF in .NET 4.6 & 4.6.1 shipped with buggy behavior - each DispatcherOperation ends with all modificaitons to culture infos being reverted.Though unlikely, if some applications targeting 4.6 or above might have taken a dependence on this bug, we provide this compatiblity switch that can be enabled by the application.
Full Name: MS.Internal.BaseAppContextSwitches.UseSha1AsDefaultHashAlgorithmForDigitalSignatures
feature is enabled when tfm > net47
true if tfm <= net47
false otherwise
PacakageDigitalSignatureManager.DefaultHashAlgorithm is now SHA256. Setting this flag will make it SHA1 as it is in legacy scenarios prior to .NET 4.7.1.
Full Name: MS.Internal.BaseAppContextSwitches.DoNotInvokeInWeakEventTableShutdownListener
feature is always enabled by default
false
Allowing developers to turn off the Invoke added by DDVSO:543980 as there are compat issues with timing during shutdown for some applications.
Full Name: MS.Internal.BaseAppContextSwitches.EnableWeakEventMemoryImprovements
feature is always enabled by default
false
Enable/disable various perf and memory improvements related to WeakEvents
Full Name: MS.Internal.BaseAppContextSwitches.EnableCleanupSchedulingImprovements
feature is always enabled by default
false
Enable/disable heuristic for scheduling cleanup of
Full Name: MS.Internal.BuildTasksAppContextSwitches.DoNotUseSha256ForMarkupCompilerChecksumAlgorithm
feature enabled when tfm > net471
true if tfm <= net471
false otherwise
The WPF MarkupCompiler provides compilation services for XAML markup files. In the .NET Framework 4.7.1 and earlier versions, the default hash algorithm used for checksums was SHA1. Due to recent security concerns with SHA1, this default has been changed to SHA256 starting with the .NET Framework 4.7.2. This change affects all checksum generation for markup files during compilation.
Full Name: MS.Internal.CoreAppContextSwitches.DoNotScaleForDpiChanges
feature is enabled when tfm > net461
true if tfm <= net461
false otherwise
Determines whether DPI changes occur on a per-system (a value of false) or per-monitor basis (a value of true).
Switch to enable WPF support for the WM_POINTER based stylus/touch stack
feature is enabled when tfm > net462
true if tfm <= net462
false otherwise
Switch to enable the correct exception being thrown in ImageSourceConverter.ConvertFrom instead of NullReferenceException
feature is always enabled by default
false
Switch to disable diagnostic features
feature is always enabled by default
false
Switch to allow changes during a VisualTreeChanged event
feature is always enabled by default
false
Switch to disable automatic touch keyboard invocation on focus of a control
Full Name: MS.Internal.CoreAppContextSwitches.UseNetFx47CompatibleAccessibilityFeatures
features are enabled when tfm > net47
true if tfm <= net47; false otherwise
Full Name: MS.Internal.CoreAppContextSwitches.UseNetFx471CompatibleAccessibilityFeatures
features are enabled when tfm > net471
true if tfm <= net471; false otherwise
Full Name: MS.Internal.CoreAppContextSwitches.UseNetFx472CompatibleAccessibilityFeatures
features are enabled when tfm > net472
true if tfm <= net472; false otherwise
Full Name: System.Windows.AccessibilitySwitches.UseLegacyToolTipDisplay
features are enabled when tfm > net472
true if tfm <= net472; false otherwise
Full Name: System.Windows.AccessibilitySwitches.ItemsControlDoesNotSupportAutomation
features are enabled when tfm > net472
true if tfm <= net472; false otherwise
See https://github.com/microsoft/dotnet/blob/master/releases/net472/dotnet472-changes.md
Full Name: MS.Internal.CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable
feature is always enabled by default
false
Desktop/Interactive Window Stations:
Rendering will be throttled back/stopped when no display devices are available. For e.g., when a TS session is in WTSDisconnected state, the OS may not provide any display devices in response to our enumeration. If an application would like to continue rendering in the absence of display devices (accepting that it can lead to a CPU spike), it can set to true. Service/Non-interactive Window Stations Rendering will continue by default, irrespective of the presence of display devices.Unless the WPF API’s being used are shortlived (like rendering to a bitmap), it can lead to a CPU spike. If an application running inside a service would like to receive the ‘default’ WPF behavior, i.e., no rendering in the absence of display devices, then it should set to true.
In pseudocode,
IsNonInteractiveWindowStation = !Environment.UserInteractive
IF DisplayDevicesNotFound() THEN
IF IsNonInteractiveWindowStation THEN
// We are inside a SCM service
// Default = True, AppContext switch can override it to False
ShouldRender = !CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation
ELSE
// Desktop/interactive mode, including WTSDisconnected scenarios
// Default = False, AppContext switch can override it to True
ShouldRender = CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable
END IF
END IFFull Name: MS.Internal.CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation
feature is always enabled by default
false
Desktop/Interactive Window Stations:
Rendering will be throttled back/stopped when no display devices are available. For e.g., when a TS session is in WTSDisconnected state, the OS may not provide any display devices in response to our enumeration. If an application would like to continue rendering in the absence of display devices (accepting that it can lead to a CPU spike), it can set to true. Service/Non-interactive Window Stations Rendering will continue by default, irrespective of the presence of display devices.Unless the WPF API’s being used are shortlived (like rendering to a bitmap), it can lead to a CPU spike. If an application running inside a service would like to receive the ‘default’ WPF behavior, i.e., no rendering in the absence of display devices, then it should set to true.
In pseudocode,
IsNonInteractiveWindowStation = !Environment.UserInteractive
IF DisplayDevicesNotFound() THEN
IF IsNonInteractiveWindowStation THEN
// We are inside a SCM service
// Default = True, AppContext switch can override it to False
ShouldRender = !CoreAppContextSwitches.ShouldNotRenderInNonInteractiveWindowStation
ELSE
// Desktop/interactive mode, including WTSDisconnected scenarios
// Default = False, AppContext switch can override it to True
ShouldRender = CoreAppContextSwitches.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable
END IF
END IFFull Name: MS.Internal.CoreAppContextSwitches.DoNotUsePresentationDpiCapabilityTier2OrGreater
feature is enabled when tfm > net472
true if tfm <= net472
false otherwise
When set to true, WPF will not enable the compatibility breaking bug fixes associated with features advertised by “Switch.System.Windows.PresentationDpiCapabilityTier2”
The following behavior would be turned off when this flag is set by the application:
The following fixes would remain unaffected:
Full Name: MS.Internal.CoreAppContextSwitches.DoNotUsePresentationDpiCapabilityTier3OrGreater
feature is always enabled by default
false
Reserved for future use
Full Name: MS.Internal.CoreAppContextSwitches.AllowExternalProcessToBlockAccessToTemporaryFiles
feature is always enabled by default
false
Full Name: MS.Internal.CoreAppContextSwitches.EnableLegacyDangerousClipboardDeserializationMode
feature is always enabled by default
false
Malicious managed objects could be placed in the clipboard lying about its format, to fix this OleConverter now restricts object deserialization in some cases. When this switch is enabled behavior falls back to deserializing without restriction.
Full Name: MS.Internal.FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness
feature is enabled when tfm > net452
true if tfm <= net452
false otherwise
Full Name: MS.Internal.FrameworkAppContextSwitches.GridStarDefinitionsCanExceedAvailableSpace
feature is enabled when tfm > net462
true if tfm <= net462
false otherwise
Full Name: MS.Internal.FrameworkAppContextSwitches.SelectionPropertiesCanLagBehindSelectionChangedEvent
feature is enabled when tfm > net47
true if tfm <= net47
false otherwise
Full Name: MS.Internal.FrameworkAppContextSwitches.DoNotUseFollowParentWhenBindingToADODataRelation
feature is enabled when tfm > net471
true if tfm <= net471
false otherwise
Full Name: MS.Internal.FrameworkAppContextSwitches.UseAdornerForTextboxSelectionRendering
feature is always off by default; this is an opt-in only feature
always true
Switch to enable non-adorner based rendering of TextSelection in TextBox and PasswordBox
Full Name: MS.Internal.FrameworkAppContextSwitches.AppendLocalAssemblyVersionForSourceUri
false
Switch to enable appending the local assembly version to the Uri being set for ResourceDictionary.Source via Baml2006ReaderInternal.
Full Name: MS.Internal.FrameworkAppContextSwitches.IListIndexerHidesCustomIndexer
feature is enabled when net4 > tfm > net472
true if net4 >= tfm <= net472
false otherwise
Switch to enable IList indexer hiding a custom indexer in a binding path
Full Name: MS.Internal.FrameworkAppContextSwitches.KeyboardNavigationFromHyperlinkInItemsControlIsNotRelativeToFocusedElement
false
Switch to enable keyboard navigation from a hyperlink to go to the wrong place
Full Name: MS.Internal.FrameworkAppContextSwitches.ItemAutomationPeerKeepsItsItemAlive
false
Switch to opt-out of the ItemAutomationPeer weak-reference. Setting this to true can avoid NRE crashes, but re-introduces some memory leaks
The problem is due to a limitation of D3D - the content it presents via dirty-rectangles can be out of sync with the rest of the content, if the timing of the presents and fills is unfortunate. WPF cannot fix this, but we can mitigate it by giving the app a way to disable the dirty-rectangle optimization. This impacts the graphics performance; by opting-in the app accepts the tradeoff of performance vs. fidelity.
See https://github.com/dotnet/wpf/pull/5837 https://github.com/dotnet/wpf/issues/5441
See Switch.System.Windows.Media.MediaContext.DisableDirtyRectangles
See https://github.com/dotnet/wpf/pull/5837 https://github.com/dotnet/wpf/issues/5441