diff options
author | Tomas Rylek <trylek@microsoft.com> | 2016-05-31 23:43:29 +0300 |
---|---|---|
committer | Tomas Rylek <trylek@microsoft.com> | 2016-05-31 23:43:29 +0300 |
commit | e00fdd8e0cc141a4bf9d357440a1f74006ae0221 (patch) | |
tree | de265bf34a89eba22e39216a85fb1dd465f01d37 /src/ILCompiler.MetadataTransform | |
parent | 2f34dd2149efb66c65fef1119b35e393c17d1250 (diff) |
Fix custom attribute handling to properly cater for the legal case of arrays with null value.
[tfs-changeset: 1609323]
Diffstat (limited to 'src/ILCompiler.MetadataTransform')
-rw-r--r-- | src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.CustomAttribute.cs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.CustomAttribute.cs b/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.CustomAttribute.cs index 041d93806..6a55d4544 100644 --- a/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.CustomAttribute.cs +++ b/src/ILCompiler.MetadataTransform/src/ILCompiler/Metadata/Transform.CustomAttribute.cs @@ -115,6 +115,11 @@ namespace ILCompiler.Metadata return HandleString((string)value); } + if (value == null) + { + return new ConstantReferenceValue(); + } + if (type.IsSzArray) { return HandleCustomAttributeConstantArray( @@ -122,11 +127,6 @@ namespace ILCompiler.Metadata (ImmutableArray<Ecma.CustomAttributeTypedArgument<Cts.TypeDesc>>)value); } - if (value == null) - { - return new ConstantReferenceValue(); - } - Debug.Assert(value is Cts.TypeDesc); Debug.Assert(type is Cts.MetadataType && ((Cts.MetadataType)type).Name == "Type" @@ -217,6 +217,11 @@ namespace ILCompiler.Metadata private bool IsBlockedCustomAttributeConstantValue(Cts.TypeDesc type, object value) { + if (value == null) + { + return false; + } + if (type.IsSzArray) { var arrayType = (Cts.ArrayType)type; |