Skip to content

Commit

Permalink
Static init of StackTraceHelper.typesToBeExcluded
Browse files Browse the repository at this point in the history
Address thread-safety issue microsoft#1053 by initializing the static field StackTraceHelper.typesToBeExcluded statically instead of on demand.
  • Loading branch information
krijohan committed Mar 17, 2022
1 parent 38f50b5 commit edfb165
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/Adapter/MSTest.CoreAdapter/Execution/StackTraceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal static class StackTraceHelper
/// <summary>
/// Type that need to be excluded.
/// </summary>
private static List<string> typesToBeExcluded;
private static List<string> typesToBeExcluded = new List<string>() { typeof(Microsoft.VisualStudio.TestTools.UnitTesting.Assert).Namespace, typeof(MSTestExecutor).Namespace };

/// <summary>
/// Gets the types whose methods should be ignored in the reported call stacks.
Expand All @@ -30,13 +30,6 @@ private static List<string> TypeToBeExcluded
{
get
{
if (typesToBeExcluded == null)
{
typesToBeExcluded = new List<string>();
typesToBeExcluded.Add(typeof(Microsoft.VisualStudio.TestTools.UnitTesting.Assert).Namespace);
typesToBeExcluded.Add(typeof(MSTestExecutor).Namespace);
}

return typesToBeExcluded;
}
}
Expand Down

0 comments on commit edfb165

Please # to comment.