Skip to content

Commit da09655

Browse files
committed
Do not throw exception when working directory cleanup fails
1 parent 4f31b5a commit da09655

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/AssemblyInfo.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal sealed partial class AssemblyInfo
3232

3333
/// <summary>
3434
/// The version number of the .NET Core framework that this assembly targets.
35-
///
35+
///
3636
/// This is extracted from the `TargetFrameworkAttribute` of the assembly, e.g.
3737
/// ```
3838
/// [assembly:TargetFramework(".NETCoreApp,Version=v7.0")]
@@ -165,6 +165,11 @@ public static AssemblyInfo ReadFromFile(string filename)
165165
unsafe
166166
{
167167
var reader = new MetadataReader(metadata.Pointer, metadata.Length);
168+
if (!reader.IsAssembly)
169+
{
170+
throw new AssemblyLoadException();
171+
}
172+
168173
var def = reader.GetAssemblyDefinition();
169174

170175
// This is how you compute the public key token from the full public key.

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,25 @@ private void AnalyseSolutions(IEnumerable<string> solutions)
644644

645645
public void Dispose()
646646
{
647-
packageDirectory?.Dispose();
647+
try
648+
{
649+
packageDirectory?.Dispose();
650+
}
651+
catch (Exception exc)
652+
{
653+
progressMonitor.LogInfo("Couldn't delete package directory: " + exc.Message);
654+
}
648655
if (cleanupTempWorkingDirectory)
649-
tempWorkingDirectory?.Dispose();
656+
{
657+
try
658+
{
659+
tempWorkingDirectory?.Dispose();
660+
}
661+
catch (Exception exc)
662+
{
663+
progressMonitor.LogInfo("Couldn't delete temporary working directory: " + exc.Message);
664+
}
665+
}
650666
}
651667
}
652668
}

0 commit comments

Comments
 (0)