From 8a7ce313d23af17a85cde2efc9ae99bebd87ae94 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Tue, 21 Jun 2016 08:44:55 -0700 Subject: [PATCH] Fixes #1355 UWP package cannot find Microsoft.PythonTools.dll Stop autoloading the UWP package to avoid loading it before the PythonTools package. Also fix some null references that were preventing Python projects opening early in startup. --- Python/Product/Uwp/PythonUwpPackage.cs | 1 - .../MSBuildProjectInterpreterFactoryProvider.cs | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Python/Product/Uwp/PythonUwpPackage.cs b/Python/Product/Uwp/PythonUwpPackage.cs index 277102ec67..6bf312e34e 100644 --- a/Python/Product/Uwp/PythonUwpPackage.cs +++ b/Python/Product/Uwp/PythonUwpPackage.cs @@ -47,7 +47,6 @@ namespace Microsoft.PythonTools.Uwp { [ProvideObject(typeof(PythonUwpPropertyPage))] [ProvideObject(typeof(PythonUwpProject))] - [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionHasAppContainerProject_string)] [Description("Python Tools Uwp Interpreter")] [ProvideProjectFactory(typeof(PythonUwpProjectFactory), null, null, null, null, ".\\NullPath", LanguageVsTemplate = PythonConstants.LanguageName)] [ProvidePythonInterpreterFactoryProvider(PythonUwpInterpreterFactory.InterpreterGuidString, typeof(PythonUwpInterpreterFactoryProvider))] diff --git a/Python/Product/VSInterpreters/MSBuildProjectInterpreterFactoryProvider.cs b/Python/Product/VSInterpreters/MSBuildProjectInterpreterFactoryProvider.cs index db3b105d28..8fb0b10d8f 100644 --- a/Python/Product/VSInterpreters/MSBuildProjectInterpreterFactoryProvider.cs +++ b/Python/Product/VSInterpreters/MSBuildProjectInterpreterFactoryProvider.cs @@ -464,7 +464,7 @@ public void AddInterpreter(IPythonInterpreterFactory factory, bool disposeInterp throw new ArgumentNullException("factory"); } - if (_factories.ContainsKey(factory)) { + if (_factories != null && _factories.ContainsKey(factory)) { return; } @@ -515,6 +515,9 @@ public void AddInterpreter(IPythonInterpreterFactory factory, bool disposeInterp } lock (_factoriesLock) { + if (_factories == null) { + _factories = new Dictionary(); + } _factories[factory] = new FactoryInfo(item, disposeInterpreter); } OnInterpreterFactoriesChanged(); @@ -534,7 +537,7 @@ public void RemoveInterpreterFactory(IPythonInterpreterFactory factory) { throw new ArgumentNullException("factory"); } - if (!_factories.ContainsKey(factory)) { + if (_factories == null || !_factories.ContainsKey(factory)) { return; } @@ -611,7 +614,7 @@ public IEnumerable GetProjectSpecificInterpreterFacto public MSBuild.ProjectItem GetProjectItem(IPythonInterpreterFactory factory) { lock (_factoriesLock) { FactoryInfo info; - if (_factories.TryGetValue(factory, out info)) { + if (_factories != null && _factories.TryGetValue(factory, out info)) { return info.ProjectItem; } } @@ -629,7 +632,7 @@ public MSBuild.ProjectItem GetProjectItem(IPythonInterpreterFactory factory) { public bool IsProjectSpecific(IPythonInterpreterFactory factory) { lock (_factoriesLock) { FactoryInfo info; - if (_factories.TryGetValue(factory, out info)) { + if (_factories != null && _factories.TryGetValue(factory, out info)) { return info.ProjectItem.ItemType.Equals(InterpreterItem); } } @@ -662,7 +665,7 @@ public bool IsAvailable(IPythonInterpreterFactory factory) { /// public bool Contains(IPythonInterpreterFactory factory) { lock (_factoriesLock) { - return _factories.ContainsKey(factory); + return _factories != null && _factories.ContainsKey(factory); } }