[metadata] Size 0 Blob heap is ok when resolving assembly refs (#18313)
* [metadata] Size 0 Blob heap is ok when resolving assembly refs
Sometimes ILasm can produce images with a Blob heap of size 0. In cases where
we're loading assembly references from such an image, the hash (which is
optional) can be at index = 0 and the Blob heap size is also 0.
Also: add the hash value to the output of `monodis --assemblyref`
* [metadata] Add a separate assertion for the index == size == 0 case
And a comment explaining how it is likely to be triggered. If the assembly is
reasonable the caller of mono_metadata_blob_heap should be updated to use
mono_metadata_blob_heap_null_ok instead
* [bcl] Allow Mono's ILASM to produce a size 0 Blob heap
ECMA 335 II.24.2.4 says that the user string and blob heaps should have an
entry at index 0 consisting of the single byte 0. However .NET Framework (and
.NET Core) ilasm will entirely omit the Blob heap (that is, create a blob heap
entry of size 0) if it is not needed. This PR changes Mono's ILASM to emit the
initial byte on demand only if one of the MetaDataStream.Add() methods is
called. Otherwise we will also emit a stream of size 0.
This is needed to compile some test cases.
* [tests] Add regression test for loading assemblies with size 0 Blob heap
Depends on ILASM that can emit a size 0 Blob heap