提交 e81aab7e 编写于 作者: S Santiago Fernandez Madero 提交者: GitHub

Update LocalAppContext DisableCaching and XmlSchemaSet Tests to fix failure (dotnet/corefx#14778)

* Update LocalAppContext DisableCaching and XmlSchemaSet Tests


Commit migrated from https://github.com/dotnet/corefx/commit/05ae65fd6b51f865750e8d400c60511fcdbbbfb5
上级 e756d10a
......@@ -8,14 +8,9 @@ namespace System
{
internal partial class LocalAppContext
{
static LocalAppContext()
{
bool isEnabled;
if (AppContext.TryGetSwitch(@"TestSwitch.LocalAppContext.DisableCaching", out isEnabled))
{
DisableCaching = isEnabled;
}
}
private static bool s_isDisableCachingInitialized;
private static bool s_disableCaching;
private static readonly object s_syncObject = new object();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool GetCachedSwitchValue(string switchName, ref int switchValue)
......@@ -40,6 +35,29 @@ private static bool GetCachedSwitchValueInternal(string switchName, ref int swit
return isSwitchEnabled;
}
private static bool DisableCaching { get; set; }
private static bool DisableCaching
{
get
{
if (!s_isDisableCachingInitialized)
{
lock (s_syncObject)
{
if (!s_isDisableCachingInitialized)
{
bool isEnabled;
if (AppContext.TryGetSwitch(@"TestSwitch.LocalAppContext.DisableCaching", out isEnabled))
{
s_disableCaching = isEnabled;
}
s_isDisableCachingInitialized = true;
}
}
}
return s_disableCaching;
}
}
}
}
......@@ -8,6 +8,11 @@ namespace System.Xml.Tests
{
public class TestData
{
static TestData()
{
AppContext.SetSwitch("TestSwitch.LocalAppContext.DisableCaching", true);
}
internal static string _Root = Path.Combine("TestFiles", "TestData");
internal static string StandardPath = Path.Combine("TestFiles", "StandardTests");
internal static string _FileXSD1 = Path.Combine(_Root, "schema1.xsd");
......
......@@ -16,9 +16,6 @@ public class TC_SchemaSet_XmlResolver
public TC_SchemaSet_XmlResolver(ITestOutputHelper output)
{
// Make sure that we don't cache the value of the switch to enable testing
AppContext.SetSwitch("TestSwitch.LocalAppContext.DisableCaching", true);
_output = output;
}
......@@ -97,7 +94,6 @@ public void v3()
}
//[Variation(Desc = "v4 - schema(Local)->schema(Local)", Priority = 1)]
[ActiveIssue(14064)]
[Fact]
public void v4()
{
......@@ -113,7 +109,6 @@ public void v4()
}
//[Variation(Desc = "v5 - schema(Local)->schema(Local)->schema(Local)", Priority = 1)]
[ActiveIssue(14064)]
[Fact]
public void v5()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册