in src/Elastic.CommonSchema/EcsDocument.DefaultService.cs [65:89]
private static string? DiscoverServiceVersion(Assembly? entryAssembly) =>
entryAssembly is not null && !IsMsOrElastic(entryAssembly.GetName().GetPublicKeyToken())
? entryAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion
: null;
private static Assembly? GetEntryAssembly()
{
var entryAssembly = Assembly.GetEntryAssembly();
var entryAssemblyName = entryAssembly?.GetName();
if (entryAssemblyName != null && !IsMsOrElastic(entryAssemblyName.GetPublicKeyToken()))
return entryAssembly;
var stackFrames = new StackTrace().GetFrames();
if (stackFrames == null) return null;
var assemblies =
from frame in stackFrames
let assembly = frame?.GetMethod()?.DeclaringType?.Assembly
where assembly != null
let bytes = assembly.GetName()?.GetPublicKeyToken()
where bytes != null && !IsMsOrElastic(bytes)
select assembly;
return assemblies.FirstOrDefault();
}