diff --git a/src/Microsoft.DotNet.Wpf/src/Common/src/System/AppContextDefaultValues.cs b/src/Microsoft.DotNet.Wpf/src/Common/src/System/AppContextDefaultValues.cs
index 8ed032a1242..10aa2add8d6 100644
--- a/src/Microsoft.DotNet.Wpf/src/Common/src/System/AppContextDefaultValues.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Common/src/System/AppContextDefaultValues.cs
@@ -2,17 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-// There are cases where we have multiple assemblies that are going to import this file and
-// if they are going to also have InternalsVisibleTo between them, there will be a compiler warning
-// that the type is found both in the source and in a referenced assembly. The compiler will prefer
-// the version of the type defined in the source
-//
-// In order to disable the warning for this type we are disabling this warning for this entire file.
-#pragma warning disable 436
-
-using System;
-using System.Collections.Generic;
-
namespace System
{
internal static partial class AppContextDefaultValues
@@ -182,15 +171,11 @@ private static bool TryParseFrameworkName(String frameworkName, out String ident
return true;
}
#endif
- // This is a partial method. Platforms (such as Desktop) can provide an implementation of it that will read override value
- // from whatever mechanism is available on that platform. If no implementation is provided, the compiler is going to remove the calls
- // to it from the code
- static partial void TryGetSwitchOverridePartial(string switchName, ref bool overrideFound, ref bool overrideValue);
+ ///
/// This is a partial method. This method is responsible for populating the default values based on a TFM.
/// It is partial because each library should define this method in their code to contain their defaults.
+ ///
static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int targetFrameworkVersion);
}
}
-
-#pragma warning restore 436
diff --git a/src/Microsoft.DotNet.Wpf/src/Common/src/System/LocalAppContext.cs b/src/Microsoft.DotNet.Wpf/src/Common/src/System/LocalAppContext.cs
index ed154c89f21..2b7534d4c30 100644
--- a/src/Microsoft.DotNet.Wpf/src/Common/src/System/LocalAppContext.cs
+++ b/src/Microsoft.DotNet.Wpf/src/Common/src/System/LocalAppContext.cs
@@ -3,39 +3,50 @@
// See the LICENSE file in the project root for more information.
using System.Runtime.CompilerServices;
-using System.Threading;
using System.Collections.Generic;
+using System.Threading;
namespace System
{
-// error CS0436: When building PresentationFramework, the type 'LocalAppContext'
-// conflicts with the imported type 'LocalAppContext' in 'PresentationCore
-#pragma warning disable 436
- internal partial class LocalAppContext
+ internal static class LocalAppContext
{
- private static Dictionary s_switchMap = new Dictionary();
- private static readonly object s_syncLock = new object();
+ ///
+ /// Holds the switch names and their values. In case it is modified outside ,
+ /// proper thread synchronization is required as the switch state can be queried from any thread.
+ ///
+ private static readonly Dictionary s_switchMap = new();
+#if !NETFX
+ private static readonly Lock s_syncLock = new();
+#else
+ private static readonly object s_syncLock = new();
+#endif
private static bool DisableCaching { get; set; }
static LocalAppContext()
{
+ // When building PresentationFramework, 'LocalAppContext' from WindowsBase.dll conflicts
+ // with 'LocalAppContext' from PresentationCore.dll since there is InternalsVisibleTo set
+#pragma warning disable CS0436 // Type conflicts with imported type
+
// Populate the default values of the local app context
AppContextDefaultValues.PopulateDefaultValues();
+#pragma warning restore CS0436 // Type conflicts with imported type
+
// Cache the value of the switch that help with testing
DisableCaching = IsSwitchEnabled(@"TestSwitch.LocalAppContext.DisableCaching");
}
public static bool IsSwitchEnabled(string switchName)
{
- if (System.AppContext.TryGetSwitch(switchName, out var isEnabledCentrally))
+ if (AppContext.TryGetSwitch(switchName, out bool isEnabledCentrally))
{
// we found the switch, so return whatever value it has
return isEnabledCentrally;
}
- // if we could not get the value from the central authority, try the local storage.
+ // if we could not get the value from the central authority, try the local storage.
return IsSwitchEnabledLocal(switchName);
}
@@ -43,7 +54,7 @@ private static bool IsSwitchEnabledLocal(string switchName)
{
// read the value from the set of local defaults
bool isEnabled, isPresent;
- lock (s_switchMap)
+ lock (s_syncLock)
{
isPresent = s_switchMap.TryGetValue(switchName, out isEnabled);
}
@@ -62,20 +73,22 @@ private static bool IsSwitchEnabledLocal(string switchName)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool GetCachedSwitchValue(string switchName, ref int switchValue)
{
- if (switchValue < 0) return false;
- if (switchValue > 0) return true;
+ if (switchValue < 0)
+ return false;
+ if (switchValue > 0)
+ return true;
return GetCachedSwitchValueInternal(switchName, ref switchValue);
}
private static bool GetCachedSwitchValueInternal(string switchName, ref int switchValue)
{
- if (LocalAppContext.DisableCaching)
+ if (DisableCaching)
{
- return LocalAppContext.IsSwitchEnabled(switchName);
+ return IsSwitchEnabled(switchName);
}
- bool isEnabled = LocalAppContext.IsSwitchEnabled(switchName);
+ bool isEnabled = IsSwitchEnabled(switchName);
switchValue = isEnabled ? 1 /*true*/ : -1 /*false*/;
return isEnabled;
}
@@ -90,5 +103,4 @@ internal static void DefineSwitchDefault(string switchName, bool initialValue)
s_switchMap[switchName] = initialValue;
}
}
-#pragma warning restore 436
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/BuildTasksAppContextSwitches.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/BuildTasksAppContextSwitches.cs
index eeec2fdd0d4..c9a7ad055fe 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/BuildTasksAppContextSwitches.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/BuildTasksAppContextSwitches.cs
@@ -7,11 +7,6 @@
namespace MS.Internal
{
- // WPF's builds are seeing warnings as a result of using LocalAppContext in mutliple assemblies.
- // that have internalsVisibleTo attribute set between them - which results in the warning.
- // We don't have a way of suppressing this warning effectively until the shared copies of LocalAppContext and
- // AppContextDefaultValues have pragmas added to suppress warning 436
-#pragma warning disable 436
internal static class BuildTasksAppContextSwitches
{
#region DoNotUseSha256ForMarkupCompilerChecksumAlgorithm
@@ -30,5 +25,4 @@ public static bool DoNotUseSha256ForMarkupCompilerChecksumAlgorithm
#endregion
}
-#pragma warning restore 436
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/System/AppContextDefaultValues.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/System/AppContextDefaultValues.cs
index 084bd120be9..2fc2999b28b 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/System/AppContextDefaultValues.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/System/AppContextDefaultValues.cs
@@ -2,45 +2,31 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
-using System.Windows;
using MS.Internal;
namespace System
{
- // WPF's builds are seeing warnings as a result of using LocalAppContext in mutliple assemblies.
- // that have internalsVisibleTo attribute set between them - which results in the warning.
- // We don't have a way of suppressing this warning effectively until the shared copies of LocalAppContext and
- // AppContextDefaultValues have pragmas added to suppress warning 436
-#pragma warning disable 436
internal static partial class AppContextDefaultValues
{
+ ///
+ /// This is a partial method. This method is responsible for populating the default values based on a TFM.
+ /// It is partial because each library should define this method in their code to contain their defaults.
+ ///
static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int targetFrameworkVersion)
{
switch (platformIdentifier)
{
case ".NETFramework":
+ if (targetFrameworkVersion <= 40701)
{
- if (targetFrameworkVersion <= 40701)
- {
- LocalAppContext.DefineSwitchDefault(BuildTasksAppContextSwitches.DoNotUseSha256ForMarkupCompilerChecksumAlgorithmSwitchName, true);
- }
-
- break;
+ LocalAppContext.DefineSwitchDefault(BuildTasksAppContextSwitches.DoNotUseSha256ForMarkupCompilerChecksumAlgorithmSwitchName, true);
}
+ break;
case ".NETCoreApp":
- {
- InitializeNetFxSwitchDefaultsForNetCoreRuntime();
- }
+ LocalAppContext.DefineSwitchDefault(BuildTasksAppContextSwitches.DoNotUseSha256ForMarkupCompilerChecksumAlgorithmSwitchName, false);
break;
}
}
-
- private static void InitializeNetFxSwitchDefaultsForNetCoreRuntime()
- {
- LocalAppContext.DefineSwitchDefault(BuildTasksAppContextSwitches.DoNotUseSha256ForMarkupCompilerChecksumAlgorithmSwitchName, false);
- }
}
-#pragma warning restore 436
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/CoreAppContextSwitches.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/CoreAppContextSwitches.cs
index 30371548762..c2fb7aa88e8 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/CoreAppContextSwitches.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/CoreAppContextSwitches.cs
@@ -2,20 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-
using System;
using System.Runtime.CompilerServices;
using System.Windows;
namespace MS.Internal
{
- // WPF's builds are seeing new warnings as as result of using LocalAppContext in PresentationFramework, PresentationCore and WindowsBase.
- // These binaries have internalsVisibleTo attribute set between them - which results in the warning.
- // We don't have a way of suppressing this warning effectively until the shared copies of LocalAppContext and
- // AppContextDefaultValues have pragmas added to suppress warning 436
-#pragma warning disable 436
internal static class CoreAppContextSwitches
{
#region DoNotScaleForDpiChanges
@@ -411,5 +403,4 @@ public static bool DisableSpecialCharacterLigature
#endregion
}
-#pragma warning restore 436
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/AppContextDefaultValues.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/AppContextDefaultValues.cs
index 1f527dd44f2..4555d60ca3d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/AppContextDefaultValues.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/AppContextDefaultValues.cs
@@ -2,50 +2,17 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System.Windows;
using MS.Internal;
namespace System
{
- // WPF's builds are seeing new warnings as as result of using LocalAppContext in PresentationFramework, PresentationCore and WindowsBase.
- // These binaries have internalsVisibleTo attribute set between them - which results in the warning.
- // We don't have a way of suppressing this warning effectively until the shared copies of LocalAppContext and
- // AppContextDefaultValues have pragmas added to suppress warning 436
-#pragma warning disable 436
internal static partial class AppContextDefaultValues
{
+ ///
+ /// This is a partial method. This method is responsible for populating the default values based on a TFM.
+ /// It is partial because each library should define this method in their code to contain their defaults.
+ ///
static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int targetFrameworkVersion)
- {
- switch (platformIdentifier)
- {
- case ".NETFramework":
- {
- if (targetFrameworkVersion <= 40601)
- {
- LocalAppContext.DefineSwitchDefault(CoreAppContextSwitches.DoNotScaleForDpiChangesSwitchName, true);
- }
-
- if (targetFrameworkVersion <= 40602)
- {
- LocalAppContext.DefineSwitchDefault(CoreAppContextSwitches.OverrideExceptionWithNullReferenceExceptionName, true);
- }
-
- if (targetFrameworkVersion <= 40702)
- {
- LocalAppContext.DefineSwitchDefault(CoreAppContextSwitches.DoNotUsePresentationDpiCapabilityTier2OrGreaterSwitchName, true);
- }
-
- break;
- }
- case ".NETCoreApp":
- {
- InitializeNetFxSwitchDefaultsForNetCoreRuntime();
- }
- break;
- }
- }
-
- private static void InitializeNetFxSwitchDefaultsForNetCoreRuntime()
{
LocalAppContext.DefineSwitchDefault(CoreAppContextSwitches.DoNotScaleForDpiChangesSwitchName, false);
LocalAppContext.DefineSwitchDefault(CoreAppContextSwitches.OverrideExceptionWithNullReferenceExceptionName, false);
@@ -64,5 +31,4 @@ private static void InitializeNetFxSwitchDefaultsForNetCoreRuntime()
LocalAppContext.DefineSwitchDefault(CoreAppContextSwitches.DisableSpecialCharacterLigatureSwitchName, false);
}
}
-#pragma warning restore 436
}
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/FrameworkAppContextSwitches.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/FrameworkAppContextSwitches.cs
index 44cf187d67c..b1efd65fb5d 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/FrameworkAppContextSwitches.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/FrameworkAppContextSwitches.cs
@@ -2,22 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
-using MS.Internal.PresentationFramework.Interop;
-using System;
using System.Runtime.CompilerServices;
-using System.Windows;
+using System;
+
+// When building PresentationFramework, 'LocalAppContext' from WindowsBase.dll conflicts
+// with 'LocalAppContext' from PresentationCore.dll since there is InternalsVisibleTo set
+#pragma warning disable CS0436 // Type conflicts with imported type
namespace MS.Internal
{
- // There are cases where we have multiple assemblies that are going to import this file and
- // if they are going to also have InternalsVisibleTo between them, there will be a compiler warning
- // that the type is found both in the source and in a referenced assembly. The compiler will prefer
- // the version of the type defined in the source
- //
- // In order to disable the warning for this type we are disabling this warning for this entire file.
- #pragma warning disable 436
-
internal static class FrameworkAppContextSwitches
{
internal const string DoNotApplyLayoutRoundingToMarginsAndBorderThicknessSwitchName = "Switch.MS.Internal.DoNotApplyLayoutRoundingToMarginsAndBorderThickness";
@@ -156,6 +149,6 @@ public static bool DisableDynamicResourceOptimization
}
}
}
-
-#pragma warning restore 436
}
+
+#pragma warning restore CS0436 // Type conflicts with imported type
diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/AppContextDefaultValues.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/AppContextDefaultValues.cs
index c36d4c6ea5b..edcd561aebc 100644
--- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/AppContextDefaultValues.cs
+++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/AppContextDefaultValues.cs
@@ -6,64 +6,22 @@
namespace System
{
- // There are cases where we have multiple assemblies that are going to import this file and
- // if they are going to also have InternalsVisibleTo between them, there will be a compiler warning
- // that the type is found both in the source and in a referenced assembly. The compiler will prefer
- // the version of the type defined in the source
- //
- // In order to disable the warning for this type we are disabling this warning for this entire file.
- #pragma warning disable 436
-
internal static partial class AppContextDefaultValues
{
+ ///
+ /// This is a partial method. This method is responsible for populating the default values based on a TFM.
+ /// It is partial because each library should define this method in their code to contain their defaults.
+ ///
static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int targetFrameworkVersion)
{
- // The AppContext analyzer expects an if statement here, we should have named the switch 'DoNotUseAdorner' and not included this line at all - by default, switches get set to 'false'
- // Because this was realized after we shipped, we are going to disable the warning for this switch.
-#pragma warning disable BCL0012
+ // When building PresentationFramework, 'LocalAppContext' from WindowsBase.dll conflicts
+ // with 'LocalAppContext' from PresentationCore.dll since there is InternalsVisibleTo set
+#pragma warning disable CS0436 // Type conflicts with imported type
// The standard behavior is to draw Text/PasswordBox selections via the Adorner.
// We want this to always be the case unless it is explicitly changed, regardless of .NET target version.
LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.UseAdornerForTextboxSelectionRenderingSwitchName, true);
-#pragma warning restore BCL0012
-
- switch (platformIdentifier)
- {
- case ".NETFramework":
- {
- if (targetFrameworkVersion <= 40502)
- {
- LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThicknessSwitchName, true);
- }
- if (targetFrameworkVersion <= 40602)
- {
- LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.GridStarDefinitionsCanExceedAvailableSpaceSwitchName, true);
- }
- if (targetFrameworkVersion <= 40700)
- {
- LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.SelectionPropertiesCanLagBehindSelectionChangedEventSwitchName, true);
- }
- if (targetFrameworkVersion <= 40701)
- {
- LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.DoNotUseFollowParentWhenBindingToADODataRelationSwitchName, true);
- }
- if (40000 <= targetFrameworkVersion && targetFrameworkVersion <= 40702)
- {
- LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.IListIndexerHidesCustomIndexerSwitchName, true);
- }
- }
- break;
-
- case ".NETCoreApp":
- {
- InitializeNetFxSwitchDefaultsForNetCoreRuntime();
- }
- break;
- }
- }
- private static void InitializeNetFxSwitchDefaultsForNetCoreRuntime()
- {
LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThicknessSwitchName, false);
LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.GridStarDefinitionsCanExceedAvailableSpaceSwitchName, false);
LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.SelectionPropertiesCanLagBehindSelectionChangedEventSwitchName, false);
@@ -75,11 +33,7 @@ private static void InitializeNetFxSwitchDefaultsForNetCoreRuntime()
LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.ItemAutomationPeerKeepsItsItemAliveSwitchName, false);
LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.DisableFluentThemeWindowBackdropSwitchName, false);
- // UseAdornerForTextboxSelectionRenderingSwitchName is always true, i.e., disabled by default.
- // Do not initialized this again - this was initialized earlier in PopulateDefaultValuesPartial unconditionally.
- // LocalAppContext.DefineSwitchDefault(FrameworkAppContextSwitches.UseAdornerForTextboxSelectionRenderingSwitchName, true);
+#pragma warning restore CS0436 // Type conflicts with imported type
}
}
-
- #pragma warning restore 436
}
diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/BaseAppContextSwitches.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/BaseAppContextSwitches.cs
index 6bfd5f7753e..55d517b71d0 100644
--- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/BaseAppContextSwitches.cs
+++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/BaseAppContextSwitches.cs
@@ -2,22 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-//
-
using System;
using System.Runtime.CompilerServices;
namespace MS.Internal
{
- // There are cases where we have multiple assemblies that are going to import this file and
- // if they are going to also have InternalsVisibleTo between them, there will be a compiler warning
- // that the type is found both in the source and in a referenced assembly. The compiler will prefer
- // the version of the type defined in the source
- //
- // In order to disable the warning for this type we are disabling this warning for this entire file.
- #pragma warning disable 436
-
///
/// Appcompat switches used by WindowsBase. See comments at the start of each switch.
/// Also see AppContextDefaultValues which initializes default values for each of
@@ -132,6 +121,4 @@ public static bool EnableCleanupSchedulingImprovements
#endregion
}
-
-#pragma warning restore 436
}
diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/AppContextDefaultValues.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/AppContextDefaultValues.cs
index 93c462f47d3..b9a680790a3 100644
--- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/AppContextDefaultValues.cs
+++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/AppContextDefaultValues.cs
@@ -7,54 +7,21 @@
namespace System
{
- // There are cases where we have multiple assemblies that are going to import this file and
- // if they are going to also have InternalsVisibleTo between them, there will be a compiler warning
- // that the type is found both in the source and in a referenced assembly. The compiler will prefer
- // the version of the type defined in the source
- //
- // In order to disable the warning for this type we are disabling this warning for this entire file.
- #pragma warning disable 436
-
///
/// Default values for app-compat quirks used within WindowsBase.
/// Also see BaseAppContextSwitches
///
internal static partial class AppContextDefaultValues
{
- static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int targetFrameworkVersion)
- {
- switch (platformIdentifier)
- {
- case ".NETFramework":
- {
- if (targetFrameworkVersion <= 40502)
- {
- LocalAppContext.DefineSwitchDefault(BaseAppContextSwitches.SwitchDoNotUseCulturePreservingDispatcherOperations, true);
- }
-
- if (targetFrameworkVersion <= 40700)
- {
- LocalAppContext.DefineSwitchDefault(BaseAppContextSwitches.SwitchUseSha1AsDefaultHashAlgorithmForDigitalSignatures, true);
- }
- }
- break;
-
- case ".NETCoreApp":
- {
- InitializeNetFxSwitchDefaultsForNetCoreRuntime();
- }
- break;
- }
-
- // Ensure we set all the accessibility switch defaults
- AccessibilitySwitches.SetSwitchDefaults(platformIdentifier, targetFrameworkVersion);
- }
-
///
- /// This is the full set of .NET Framework in . These are being initialized
- /// to false to ensure that the corresponding functionality will be treated as if it is enabled by default on .NET Core.
+ /// This is a partial method. This method is responsible for populating the default values based on a TFM.
+ /// It is partial because each library should define this method in their code to contain their defaults.
///
- private static void InitializeNetFxSwitchDefaultsForNetCoreRuntime()
+ ///
+ /// This is the full set of .NET Framework in . These are being initialized
+ /// to to ensure that the corresponding functionality will be treated as if it is enabled by default on .NET Core.
+ ///
+ static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int targetFrameworkVersion)
{
LocalAppContext.DefineSwitchDefault(BaseAppContextSwitches.SwitchDoNotUseCulturePreservingDispatcherOperations, false);
LocalAppContext.DefineSwitchDefault(BaseAppContextSwitches.SwitchUseSha1AsDefaultHashAlgorithmForDigitalSignatures, false);
@@ -62,8 +29,9 @@ private static void InitializeNetFxSwitchDefaultsForNetCoreRuntime()
LocalAppContext.DefineSwitchDefault(BaseAppContextSwitches.SwitchDoNotInvokeInWeakEventTableShutdownListener, false);
LocalAppContext.DefineSwitchDefault(BaseAppContextSwitches.SwitchEnableCleanupSchedulingImprovements, false);
LocalAppContext.DefineSwitchDefault(BaseAppContextSwitches.SwitchEnableWeakEventMemoryImprovements, false);
+
+ // Ensure we set all the accessibility switch defaults
+ AccessibilitySwitches.SetSwitchDefaults(platformIdentifier, targetFrameworkVersion);
}
}
-
- #pragma warning restore 436
}
diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/AccessibilitySwitches.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/AccessibilitySwitches.cs
index 3cbb8ac30a2..e39a24d242d 100644
--- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/AccessibilitySwitches.cs
+++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/AccessibilitySwitches.cs
@@ -28,22 +28,17 @@ internal static class AccessibilitySwitches
///
/// This id is used by .NET to report a fatal error.
///
- const int EventId = 1023;
+ private const int EventId = 1023;
///
/// This source is used by .NET to report events.
///
- const string EventSource = ".NET Runtime";
+ private const string EventSource = ".NET Runtime";
#endregion
#region Fields
- ///
- /// Guards against multiple definitions of default switch values.
- ///
- static int s_DefaultsSet = 0;
-
///
/// Guards against multiple verifications of the switch values.
///
@@ -172,41 +167,11 @@ public static bool ItemsControlDoesNotSupportAutomation
///
internal static void SetSwitchDefaults(string platformIdentifier, int targetFrameworkVersion)
{
- switch (platformIdentifier)
- {
-
- case ".NETFramework":
- if (Interlocked.CompareExchange(ref s_DefaultsSet, 1, 0) == 0)
- {
- if (targetFrameworkVersion <= 40700)
- {
- LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeaturesSwitchName, true);
- }
-
- if (targetFrameworkVersion <= 40701)
- {
- LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeatures2SwitchName, true);
- }
-
- if (targetFrameworkVersion <= 40702)
- {
- LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeatures3SwitchName, true);
- LocalAppContext.DefineSwitchDefault(UseLegacyToolTipDisplaySwitchName, true);
- LocalAppContext.DefineSwitchDefault(ItemsControlDoesNotSupportAutomationSwitchName, true);
- }
- }
- break;
-
- case ".NETCoreApp":
- {
- LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeaturesSwitchName, false);
- LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeatures2SwitchName, false);
- LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeatures3SwitchName, false);
- LocalAppContext.DefineSwitchDefault(UseLegacyToolTipDisplaySwitchName, false);
- LocalAppContext.DefineSwitchDefault(ItemsControlDoesNotSupportAutomationSwitchName, false);
- }
- break;
- }
+ LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeaturesSwitchName, false);
+ LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeatures2SwitchName, false);
+ LocalAppContext.DefineSwitchDefault(UseLegacyAccessibilityFeatures3SwitchName, false);
+ LocalAppContext.DefineSwitchDefault(UseLegacyToolTipDisplaySwitchName, false);
+ LocalAppContext.DefineSwitchDefault(ItemsControlDoesNotSupportAutomationSwitchName, false);
}
///