未验证 提交 91faab29 编写于 作者: M msftbot[bot] 提交者: GitHub

Merge pull request #39760 from dotnet/merges/release/dev16.4-to-release/dev16.4-vs-deps

Merge release/dev16.4 to release/dev16.4-vs-deps
......@@ -1460,6 +1460,7 @@ public void TreesShareOptionsInstances()
new[] { "/a.cs", "/b.cs", "/c.cs" },
configs);
configs.Free();
Assert.Equal(KeyValuePair.Create("cs000", ReportDiagnostic.Warn), options[0].TreeOptions.Single());
Assert.Same(options[0].TreeOptions, options[1].TreeOptions);
Assert.Same(options[0].AnalyzerOptions, options[1].AnalyzerOptions);
......
......@@ -193,18 +193,34 @@ public AnalyzerConfigOptionsResult GetOptionsForSourcePath(string sourcePath)
treeOptionsBuilder.Count > 0 ? treeOptionsBuilder.ToImmutable() : SyntaxTree.EmptyDiagnosticOptions,
analyzerOptionsBuilder.Count > 0 ? analyzerOptionsBuilder.ToImmutable() : AnalyzerConfigOptions.EmptyDictionary,
diagnosticBuilder.ToImmutableAndFree());
_optionsCache.TryAdd(sectionKey, result);
if (_optionsCache.TryAdd(sectionKey, result))
{
// Release the pooled object to be used as a key
_sectionKeyPool.ForgetTrackedObject(sectionKey);
}
else
{
freeKey(sectionKey, _sectionKeyPool);
}
}
else
{
freeKey(sectionKey, _sectionKeyPool);
}
sectionKey.Clear();
treeOptionsBuilder.Clear();
analyzerOptionsBuilder.Clear();
_sectionKeyPool.Free(sectionKey);
_treeOptionsPool.Free(treeOptionsBuilder);
_analyzerOptionsPool.Free(analyzerOptionsBuilder);
return result;
static void freeKey(List<Section> sectionKey, ObjectPool<List<Section>> pool)
{
sectionKey.Clear();
pool.Free(sectionKey);
}
static void addOptions(
AnalyzerConfig.Section section,
TreeOptions.Builder treeBuilder,
......
......@@ -10,8 +10,13 @@ internal abstract class AbstractPackage : AsyncPackage
{
protected async Task LoadComponentsInUIContextOnceSolutionFullyLoadedAsync(CancellationToken cancellationToken)
{
await KnownUIContexts.SolutionExistsAndFullyLoadedContext;
await LoadComponentsAsync(cancellationToken).ConfigureAwait(false);
// UIContexts can be "zombied" if UIContexts aren't supported because we're in a command line build or in other scenarios.
// Trying to await them will throw.
if (!KnownUIContexts.SolutionExistsAndFullyLoadedContext.IsZombie)
{
await KnownUIContexts.SolutionExistsAndFullyLoadedContext;
await LoadComponentsAsync(cancellationToken).ConfigureAwait(false);
}
}
protected abstract Task LoadComponentsAsync(CancellationToken cancellationToken);
......
......@@ -1953,7 +1953,8 @@ internal void RefreshProjectExistsUIContextForLanguage(string language)
language,
l => Services.GetLanguageServices(l).GetService<IProjectExistsUIContextProviderLanguageService>()?.GetUIContext());
if (uiContext != null)
// UIContexts can be "zombied" if UIContexts aren't supported because we're in a command line build or in other scenarios.
if (uiContext != null && !uiContext.IsZombie)
{
uiContext.IsActive = CurrentSolution.Projects.Any(p => p.Language == language);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册