Skip to content

Commit

Permalink
Merge pull request #866 from filipw/bugfix/extensions-non-existing-path
Browse files Browse the repository at this point in the history
Error handling when loading assemblies from an external folder
  • Loading branch information
DustinCampbell authored May 25, 2017
2 parents 146f9a2 + 8ffc3c8 commit 81c790b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/OmniSharp.Host/Services/AssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,26 @@ public IReadOnlyList<Assembly> LoadAllFrom(string folderPath)
{
if (string.IsNullOrWhiteSpace(folderPath)) return Array.Empty<Assembly>();

var assemblies = new List<Assembly>();
foreach (var filePath in Directory.EnumerateFiles(folderPath, "*.dll"))
try
{
var assembly = LoadFromPath(filePath);
if (assembly != null)
var assemblies = new List<Assembly>();

foreach (var filePath in Directory.EnumerateFiles(folderPath, "*.dll"))
{
assemblies.Add(assembly);
var assembly = LoadFromPath(filePath);
if (assembly != null)
{
assemblies.Add(assembly);
}
}
}

return assemblies;
return assemblies;
}
catch (Exception ex)
{
_logger.LogError(ex, $"An error occurred when attempting to access '{folderPath}'.");
return Array.Empty<Assembly>();
}
}

private Assembly LoadFromPath(string assemblyPath)
Expand Down

0 comments on commit 81c790b

Please # to comment.