diff options
Diffstat (limited to 'src/Common/src/TypeSystem/Ecma/EcmaType.cs')
-rw-r--r-- | src/Common/src/TypeSystem/Ecma/EcmaType.cs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/Common/src/TypeSystem/Ecma/EcmaType.cs b/src/Common/src/TypeSystem/Ecma/EcmaType.cs index e2e840f8a..de9f467c9 100644 --- a/src/Common/src/TypeSystem/Ecma/EcmaType.cs +++ b/src/Common/src/TypeSystem/Ecma/EcmaType.cs @@ -242,12 +242,28 @@ namespace Internal.TypeSystem.Ecma flags |= TypeFlags.HasFinalizer; } - if ((mask & TypeFlags.IsByRefLikeComputed) != 0) + if ((mask & TypeFlags.AttributeCacheComputed) != 0) { - flags |= TypeFlags.IsByRefLikeComputed; + MetadataReader reader = MetadataReader; + MetadataStringComparer stringComparer = reader.StringComparer; + bool isValueType = IsValueType; - if (IsValueType && HasCustomAttribute("System.Runtime.CompilerServices", "IsByRefLikeAttribute")) - flags |= TypeFlags.IsByRefLike; + flags |= TypeFlags.AttributeCacheComputed; + + foreach (CustomAttributeHandle attributeHandle in _typeDefinition.GetCustomAttributes()) + { + if (MetadataReader.GetAttributeNamespaceAndName(attributeHandle, out StringHandle namespaceHandle, out StringHandle nameHandle)) + { + if (isValueType && + stringComparer.Equals(nameHandle, "IsByRefLikeAttribute") && + stringComparer.Equals(namespaceHandle, "System.Runtime.CompilerServices")) + flags |= TypeFlags.IsByRefLike; + + if (stringComparer.Equals(nameHandle, "IntrinsicAttribute") && + stringComparer.Equals(namespaceHandle, "System.Runtime.CompilerServices")) + flags |= TypeFlags.IsIntrinsic; + } + } } return flags; |