/// <summary> /// Adds a single manifest resource to the buffer. /// </summary> /// <param name="resource">The resource to add.</param> /// <returns>The new metadata token of the resource.</returns> public MetadataToken AddManifestResource(ManifestResource resource) { uint offset = resource.Offset; if (resource.IsEmbedded) { if (resource.EmbeddedDataSegment is {} segment) { using var stream = new MemoryStream(); segment.Write(new BinaryStreamWriter(stream)); offset = Resources.GetResourceDataOffset(stream.ToArray()); } else { ErrorListener.MetadataBuilder($"Embedded resource {resource.SafeToString()} does not have any contents."); offset = 0; } }