From bf87c46fcd97463ef6b296dd3ff18203fee3877b Mon Sep 17 00:00:00 2001 From: John Colvin Date: Tue, 7 Mar 2023 16:30:51 -0500 Subject: [PATCH] fix build: Remove inappropriate ThreadStatic attr This has likely been incorrect for a while. The problem surfaced after upgrading to net7.0, as the new framework emits a warning (CA2259) when the attribute is associated with a non-static field. --- .../spark/view/Converters/DictionaryLookupConverter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/spark/view/Converters/DictionaryLookupConverter.cs b/src/client/spark/view/Converters/DictionaryLookupConverter.cs index 4cbf384d1..149e9f8d0 100644 --- a/src/client/spark/view/Converters/DictionaryLookupConverter.cs +++ b/src/client/spark/view/Converters/DictionaryLookupConverter.cs @@ -3,13 +3,14 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Threading; using System.Windows.Data; namespace mbts.ui.converters { class DictionaryLookupConverter : IMultiValueConverter { - [ThreadStatic] Dictionary _type_impls_backing; - Dictionary _type_impls => _type_impls_backing ?? (_type_impls_backing = new Dictionary()); + Dictionary _type_impls => + Interlocked.CompareExchange(ref _type_impls_backing, new(), null); delegate bool Lookup(object source, object key, out object result);