namespace SourceGenerator; internal static class DictionaryExtensions { public static TValue GetOrCreate(this IDictionary @this, TKey key, Func factory) { if (@this.TryGetValue(key, out TValue? value)) { return value; } value = factory(key); @this[key] = value; return value; } }