diff options
Diffstat (limited to 'src/Common/src/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs')
-rw-r--r-- | src/Common/src/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Common/src/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs b/src/Common/src/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs index 4f186e219..a835b47d0 100644 --- a/src/Common/src/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs +++ b/src/Common/src/TypeSystem/IL/TypeSystemContext.DelegateInfo.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using Internal.IL; @@ -13,6 +12,10 @@ namespace Internal.TypeSystem { private class DelegateInfoHashtable : LockFreeReaderHashtable<TypeDesc, DelegateInfo> { + private enum CoreLibSupportLevel { Unknown, Supported, Unsupported } + + private CoreLibSupportLevel _supportLevel; + protected override int GetKeyHashCode(TypeDesc key) { return key.GetHashCode(); @@ -31,7 +34,18 @@ namespace Internal.TypeSystem } protected override DelegateInfo CreateValueFromKey(TypeDesc key) { - return new DelegateInfo(key); + if (_supportLevel == CoreLibSupportLevel.Unknown) + { + // Check if the core library supports dynamic invoke. + _supportLevel = DelegateInfo.SupportsDynamicInvoke(key.Context) ? + CoreLibSupportLevel.Supported : CoreLibSupportLevel.Unsupported; + } + + DelegateFeature supportedFeatures = _supportLevel == CoreLibSupportLevel.Supported ? + DelegateFeature.DynamicInvoke | DelegateFeature.ObjectArrayThunk : 0; + + + return new DelegateInfo(key, supportedFeatures); } } |