/// <summary> /// Creates a new analyzer that is ready for use. /// </summary> public static async Task <PythonAnalyzer> CreateAsync(IPythonInterpreterFactory factory, CancellationToken token = default) { var analyzer = new PythonAnalyzer(factory); try { await analyzer.ReloadModulesAsync(token).ConfigureAwait(false); } catch (Exception) { analyzer.Dispose(); throw; } return(analyzer); }
// Test helper method internal static PythonAnalyzer CreateSynchronously( IPythonInterpreterFactory factory, IPythonInterpreter interpreter = null ) { var res = new PythonAnalyzer(factory, interpreter); try { res.ReloadModulesAsync(CancellationToken.None).WaitAndUnwrapExceptions(); var r = res; res = null; return(r); } finally { if (res != null) { res.Dispose(); } } }
/// <summary> /// Creates a new analyzer that is ready for use. /// </summary> public static async Task <PythonAnalyzer> CreateAsync( IPythonInterpreterFactory factory, IPythonInterpreter interpreter = null ) { var res = new PythonAnalyzer(factory, interpreter, null); try { await res.ReloadModulesAsync().ConfigureAwait(false); var r = res; res = null; return(r); } finally { if (res != null) { res.Dispose(); } } }