Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovsky <michals@microsoft.com>2017-03-15 20:26:26 +0300
committerMichal Strehovsky <michals@microsoft.com>2017-03-15 20:26:26 +0300
commitb5b11ab9fd71022377bbfeadc0cf6ae4178ef757 (patch)
treec6ffb9d0a00cfaffdcddbbf2923efbd2a8d052c7 /src/ILCompiler.MetadataWriter
parent9e71c55c9fb52fc40649ba67d9f07e32cdf581cd (diff)
Allow nulls in string[] custom attribute data
The existing schema didn't allow it and we were crashing the compiler. Turns out this is popular in xUnit tests in the CoreFX tree. Includes: * Schema update that makes string[] more like object[] than arrays of primitive types * Updates to both of our emitters * Update to the reflection reader * Unit test [tfs-changeset: 1650932]
Diffstat (limited to 'src/ILCompiler.MetadataWriter')
-rw-r--r--src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs14
-rw-r--r--src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs13
2 files changed, 5 insertions, 22 deletions
diff --git a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs
index e49f28b49..344b478ec 100644
--- a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs
+++ b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs
@@ -46,20 +46,6 @@ namespace Internal.Metadata.NativeFormat.Writer
}
} // Write
- public static void Write(this NativeWriter writer, string[] values)
- {
- if (values == null)
- {
- writer.WriteUnsigned(0);
- return;
- }
- writer.WriteUnsigned((uint)values.Length);
- foreach (string value in values)
- {
- writer.Write(value);
- }
- } // Write
-
public static void Write(this NativeWriter writer, byte[] values)
{
if (values == null)
diff --git a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs
index b18563205..25f9a44cb 100644
--- a/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs
+++ b/src/ILCompiler.MetadataWriter/src/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs
@@ -1583,6 +1583,7 @@ namespace Internal.Metadata.NativeFormat.Writer
internal override void Visit(IRecordVisitor visitor)
{
+ Value = visitor.Visit(this, Value);
} // Visit
public override sealed bool Equals(Object obj)
@@ -1600,13 +1601,6 @@ namespace Internal.Metadata.NativeFormat.Writer
return _hash;
EnterGetHashCode();
int hash = -229915937;
- if (Value != null)
- {
- for (int i = 0; i < Value.Length; i++)
- {
- hash = ((hash << 13) - (hash >> 19)) ^ Value[i].GetHashCode();
- }
- }
LeaveGetHashCode();
_hash = hash;
return _hash;
@@ -1614,6 +1608,9 @@ namespace Internal.Metadata.NativeFormat.Writer
internal override void Save(NativeWriter writer)
{
+ Debug.Assert(Value.TrueForAll(handle => handle == null ||
+ handle.HandleType == HandleType.ConstantStringValue ||
+ handle.HandleType == HandleType.ConstantReferenceValue));
writer.Write(Value);
} // Save
@@ -1637,7 +1634,7 @@ namespace Internal.Metadata.NativeFormat.Writer
}
} // Handle
- public String[] Value;
+ public List<MetadataRecord> Value = new List<MetadataRecord>();
} // ConstantStringArray
public partial class ConstantStringValue : MetadataRecord