Skip to content

Commit

Permalink
Fix logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Oct 17, 2023
1 parent 74932df commit f488481
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/IKVM.MSBuild.Tasks.Tests/IkvmFileIdentityUtilTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task CanSaveState()

var f = Path.GetTempFileName();
File.WriteAllText(f, "TEST");
var i = await u.GetIdentityForFileAsync(f, CancellationToken.None);
var i = await u.GetIdentityForFileAsync(f, null, CancellationToken.None);

var x = new XElement("Test");
await u.SaveStateXmlAsync(x);
Expand Down
6 changes: 3 additions & 3 deletions src/IKVM.MSBuild.Tasks/IkvmAssemblyInfoUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,21 @@ public async System.Threading.Tasks.Task SaveStateXmlAsync(XElement root)

try
{
log.LogMessage(MessageImportance.Low, "Loading assembly info from '{0}'.", path);
log?.LogMessage(MessageImportance.Low, "Loading assembly info from '{0}'.", path);
using var fsstm = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
using var perdr = new PEReader(fsstm);
var mrdr = perdr.GetMetadataReader();
return (lastWriteTimeUtc, new AssemblyInfo(mrdr.GetString(mrdr.GetAssemblyDefinition().Name), mrdr.GetGuid(mrdr.GetModuleDefinition().Mvid), mrdr.AssemblyReferences.Select(i => mrdr.GetString(mrdr.GetAssemblyReference(i).Name)).ToList()));
}
catch (Exception e)
{
log.LogWarning("Exception loading assembly info from '{0}': {1}", path, e.Message);
log?.LogWarning("Exception loading assembly info from '{0}': {1}", path, e.Message);
return (lastWriteTimeUtc, null);
}
}
catch (Exception e)
{
log.LogWarning("Exception loading assembly info from '{0}': {1}", path, e.Message);
log?.LogWarning("Exception loading assembly info from '{0}': {1}", path, e.Message);
return (default, null);
}
});
Expand Down
2 changes: 0 additions & 2 deletions src/IKVM.MSBuild.Tasks/IkvmFileIdentityUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ public async Task<string> GetIdentityForFileAsync(string path, TaskLoggingHelper
{
if (string.IsNullOrWhiteSpace(path))
throw new ArgumentException($"'{nameof(path)}' cannot be null or whitespace.", nameof(path));
if (log is null)
throw new ArgumentNullException(nameof(log));

return (await cache.GetOrAdd(path, path => CreateIdentityForFileAsync(path, log, cancellationToken))).Identity;
}
Expand Down

0 comments on commit f488481

Please sign in to comment.