Skip to content

Odd locking strategy in AreInternalsVisibleToDynamicProxy #377

@TimLovellSmith

Description

@TimLovellSmith

I can't figure out
a) why it tests internalsVisibleToDynamicProxy.ContainsKey() again after Upgrading the lock.
b) why it doesn't do the first codepath with a non-upgradeable read lock, similar to BaseProxyGenerator, although maybe a reasonable answer could be they have different expectations on how likely they are to need to upgrade the lock...

internal static bool AreInternalsVisibleToDynamicProxy(Assembly asm)
		{
			using (var locker = internalsVisibleToDynamicProxyLock.ForReadingUpgradeable())
			{
				if (internalsVisibleToDynamicProxy.ContainsKey(asm))
				{
					return internalsVisibleToDynamicProxy[asm];
				}

				locker.Upgrade();

				if (internalsVisibleToDynamicProxy.ContainsKey(asm))
				{
					return internalsVisibleToDynamicProxy[asm];
				}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions