Skip to content

Commit

Permalink
harden discovery of codeCompletionProvider. (#10858)
Browse files Browse the repository at this point in the history
* try catch

* review comments
  • Loading branch information
mjkkirschner authored Jul 7, 2020
1 parent a898bd0 commit 8cd74d2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Libraries/PythonNodeModelsWpf/SharedCompletionProvider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Reflection;
using Autodesk.DesignScript.Interfaces;
using Dynamo.Logging;
using ICSharpCode.AvalonEdit.CodeCompletion;
Expand Down Expand Up @@ -31,15 +32,22 @@ internal SharedCompletionProvider(PythonEngineVersion version ,string dynamoCore
}
}

internal static IExternalCodeCompletionProviderCore FindMatchingCodeCompletionCore
internal static IExternalCodeCompletionProviderCore FindMatchingCodeCompletionCore
(string versionName, ILogger logger = null)
{
try
{
var completionType = typeof(IExternalCodeCompletionProviderCore);
var loadedCodeCompletionTypes = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => completionType.IsAssignableFrom(p) && !p.IsInterface);
.SelectMany(s => {
try {
return s.GetTypes();
}
catch (ReflectionTypeLoadException)
{
return new Type[0];
}
}).Where(p => completionType.IsAssignableFrom(p) && !p.IsInterface).ToList();
//instantiate them - so we can check which is a match using their match method
foreach (var type in loadedCodeCompletionTypes)
{
Expand Down

0 comments on commit 8cd74d2

Please sign in to comment.