Skip to content
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,11 @@ public unsafe Type GetOrLoadType()
[RequiresUnreferencedCode("Lazy TypeMap isn't supported for Trimmer scenarios")]
private sealed class LazyExternalTypeDictionary : LazyTypeLoadDictionary<string>
{
private static int ComputeHashCode(string key) => key.GetHashCode();

private readonly Dictionary<int, DelayedType> _lazyData = new();
private readonly Dictionary<string, DelayedType> _lazyData = new();

protected override bool TryGetOrLoadType(string key, [NotNullWhen(true)] out Type? type)
{
int hash = ComputeHashCode(key);
if (!_lazyData.TryGetValue(hash, out DelayedType? value))
if (!_lazyData.TryGetValue(key, out DelayedType? value))
{
type = null;
return false;
Expand All @@ -327,13 +324,12 @@ protected override bool TryGetOrLoadType(string key, [NotNullWhen(true)] out Typ

public void Add(string key, TypeNameUtf8 targetType, RuntimeAssembly fallbackAssembly)
{
int hash = ComputeHashCode(key);
if (_lazyData.ContainsKey(hash))
if (_lazyData.ContainsKey(key))
{
ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(key);
}

_lazyData.Add(hash, new DelayedType(targetType, fallbackAssembly));
_lazyData.Add(key, new DelayedType(targetType, fallbackAssembly));
}
}

Expand Down
Loading