Skip to content

Commit 57e7334

Browse files
GeertvanHorriktom-englert
authored andcommitted
Log weaver name and version
1 parent f404466 commit 57e7334

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

FodyIsolated/AssemblyExtensions.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Linq;
3+
using System.Reflection;
4+
5+
static class AssemblyExtensions
6+
{
7+
public static string GetVersion(this Assembly assembly)
8+
{
9+
var informationalVersion = GetAssemblyAttribute<AssemblyInformationalVersionAttribute>(assembly);
10+
if (informationalVersion != null)
11+
{
12+
return informationalVersion.InformationalVersion;
13+
}
14+
15+
var version = assembly.GetName().Version;
16+
if (version != null)
17+
{
18+
return version.ToString();
19+
}
20+
21+
return "unknown";
22+
}
23+
24+
private static TAttibute? GetAssemblyAttribute<TAttibute>(Assembly assembly)
25+
where TAttibute : Attribute
26+
{
27+
var attibutes = assembly.GetCustomAttributes(typeof(TAttibute))?.ToArray() ?? Array.Empty<Attribute>();
28+
return attibutes.Length > 0 ? attibutes[0] as TAttibute : null;
29+
}
30+
}

FodyIsolated/InnerWeaver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ void ExecuteWeavers()
195195

196196
Logger.SetCurrentWeaverName(weaver.Config.ElementName);
197197
var startNew = Stopwatch.StartNew();
198-
Logger.LogInfo("Executing weaver");
198+
var assembly = weaver.Instance.GetType().Assembly;
199+
Logger.LogInfo($"Executing weaver {weaver.Config.ElementName} v{assembly.GetVersion()}");
199200
Logger.LogDebug($"Configuration source: {weaver.Config.ConfigurationSource}");
200201
try
201202
{

0 commit comments

Comments
 (0)