Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bug
  • Loading branch information
agocke authored and github-actions committed Aug 20, 2021
commit 98337ff7533d4a1a23cf570c01172f8699c4fd7b
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Tracing;
using System.IO;
Expand Down Expand Up @@ -51,7 +52,6 @@ internal static void LogSwitchValues(RuntimeEventSource ev)
{
lock (s_dataStore)
{
var dataStore = s_dataStore;
if (s_switches is not null)
{
lock (s_switches)
Expand All @@ -66,10 +66,11 @@ internal static void LogSwitchValues(RuntimeEventSource ev)

void LogDataStore(Dictionary<string, bool>? switches)
{
foreach (var (k, v) in dataStore)
Debug.Assert(s_dataStore is not null);
foreach (var (k, v) in s_dataStore)
{
if (v is string s && bool.TryParse(s, out bool isEnabled) &&
switches?.ContainsKey(s) != true)
switches?.ContainsKey(k) != true)
{
ev.LogAppContextSwitch(k, isEnabled ? 1 : 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
AppDomain.CurrentDomain.SetData("appContextBoolData", true); // Not loggeed, bool key
AppDomain.CurrentDomain.SetData("appContextBoolAsStringData", "true");
AppDomain.CurrentDomain.SetData("appContextStringData", "myString"); // Not logged, string does not parse as bool
AppDomain.CurrentDomain.SetData("appContextSwitch", false); // should not override the SetSwitch above
AppDomain.CurrentDomain.SetData("appContextSwitch", "false"); // should not override the SetSwitch above

// Create an EventListener.
using (var myListener = new RuntimeEventListener())
Expand Down