test(opcua): bind saturation artifacts to gateway 1.0 and module identities
v2-ci / unit-tests (pull_request) Has been cancelled
v2-ci / unit-tests (pull_request) Has been cancelled
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// Read-only managed metadata extraction; does not load or execute product assemblies.
|
||||
using System.Reflection.Metadata;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using System.Text.Json;
|
||||
var root = Path.GetFullPath(args[0]);
|
||||
var modules = new List<object>();
|
||||
foreach (var directory in args.Skip(1))
|
||||
{
|
||||
foreach (var path in Directory.EnumerateFiles(directory, "*.dll", SearchOption.AllDirectories).Order())
|
||||
{
|
||||
try
|
||||
{
|
||||
using var file = File.OpenRead(path);
|
||||
using var pe = new PEReader(file);
|
||||
if (!pe.HasMetadata) continue;
|
||||
var metadata = pe.GetMetadataReader();
|
||||
if (!metadata.IsAssembly) continue;
|
||||
var assembly = metadata.GetAssemblyDefinition();
|
||||
modules.Add(new { file = Path.GetRelativePath(root, path).Replace(Path.DirectorySeparatorChar, '/'),
|
||||
assembly = metadata.GetString(assembly.Name), version = assembly.Version.ToString(),
|
||||
mvid = metadata.GetGuid(metadata.GetModuleDefinition().Mvid).ToString("D") });
|
||||
}
|
||||
catch (BadImageFormatException) { /* Native DLLs have no CLR module identity. */ }
|
||||
}
|
||||
}
|
||||
Console.WriteLine(JsonSerializer.Serialize(modules));
|
||||
Reference in New Issue
Block a user