dapplo / Dapplo.Log

Simplified logging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

new LogSource() fails if mismatch between o/s calling code compiled on, and code executing on

mpritch599 opened this issue · comments

Affects constructor public LogSource([CallerFilePath] string sourceFilePath = null), which is the advocated constructor to use.

Internally, there is logic to determine the directorySeperatorChar. For .NET Standard 1.1, 1.3, 2.0, and .NET 4.5, this selects the character based upon the runtime.

The issue arises because CallerFilePath does not return a path based upon a runtime value, but rather a compile time value (https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callerfilepathattribute?view=netstandard-2.0).

When the calling code was compiled on a different o/s to the o/s the code is currently executing on, this means the subsequent constructor code is not able to split the path, causing this line to fail:

private static string GetFilename(IEnumerable<string> filePath)
{
   return filePath.Last();
}

Discovered when using Dapplo.Confluence from a Linux server, under .NET Core