Skip to content

Commit eeb4310

Browse files
authored
Throw if resourceStream is null (guarding resourceStream) (#2007)
1 parent f2da083 commit eeb4310

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/coverlet.core/Instrumentation/Instrumenter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,12 @@ private static Stream GetTrackerTemplateAssemblyStream()
589589
}
590590

591591
using Stream resourceStream = coreAssembly.GetManifestResourceStream(resourceName);
592+
if (resourceStream is null)
593+
{
594+
throw new InvalidOperationException(
595+
$"Embedded tracker template stream '{resourceName}' was not found in '{coreAssembly.FullName}'. " +
596+
"This assembly is required to inject .NET Framework-safe coverage tracking code.");
597+
}
592598
// Cecil needs a seekable stream that stays readable for the duration of the copy; use memory.
593599
var templateStream = new MemoryStream();
594600
resourceStream.CopyTo(templateStream);

0 commit comments

Comments
 (0)