Skip to content

Commit

Permalink
Merge pull request #63356 from dotnet/merges/release/dev17.4-vs-deps-…
Browse files Browse the repository at this point in the history
…to-release/dev17.4

Merge release/dev17.4-vs-deps to release/dev17.4
  • Loading branch information
JoeRobich authored Aug 12, 2022
2 parents ed797d3 + 5da6e67 commit e445d36
Show file tree
Hide file tree
Showing 21 changed files with 415 additions and 74 deletions.
12 changes: 6 additions & 6 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
<MicrosoftVisualStudioExtensibilityTestingVersion>0.1.132-beta</MicrosoftVisualStudioExtensibilityTestingVersion>
<!-- CodeStyleAnalyzerVersion should we updated together with version of dotnet-format in dotnet-tools.json -->
<CodeStyleAnalyzerVersion>4.3.0-1.final</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>17.3.37-preview</VisualStudioEditorPackagesVersion>
<VisualStudioEditorPackagesVersion>17.3.133-preview</VisualStudioEditorPackagesVersion>
<!-- This should generally be set to $(VisualStudioEditorPackagesVersion),
but sometimes EditorFeatures.Cocoa specifically requires a newer editor build. -->
<VisualStudioMacEditorPackagesVersion>17.3.68-preview</VisualStudioMacEditorPackagesVersion>
<VisualStudioMacEditorPackagesVersion>$(VisualStudioEditorPackagesVersion)</VisualStudioMacEditorPackagesVersion>
<ILAsmPackageVersion>5.0.0-alpha1.19409.1</ILAsmPackageVersion>
<ILDAsmPackageVersion>5.0.0-preview.1.20112.8</ILDAsmPackageVersion>
<MicrosoftVisualStudioLanguageServerClientPackagesVersion>17.3.2062-preview</MicrosoftVisualStudioLanguageServerClientPackagesVersion>
<MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>17.3.2017</MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>
<MicrosoftVisualStudioShellPackagesVersion>17.2.32505.113</MicrosoftVisualStudioShellPackagesVersion>
<MicrosoftVisualStudioShellPackagesVersion>17.3.0-preview-1-32407-044</MicrosoftVisualStudioShellPackagesVersion>
<RefOnlyMicrosoftBuildPackagesVersion>16.5.0</RefOnlyMicrosoftBuildPackagesVersion>
<!-- The version of Roslyn we build Source Generators against that are built in this
repository. This must be lower than MicrosoftNetCompilersToolsetVersion,
but not higher than our minimum dogfoodable Visual Studio version, or else
the generators we build would load on the command line but not load in IDEs. -->
<SourceGeneratorMicrosoftCodeAnalysisVersion>4.1.0</SourceGeneratorMicrosoftCodeAnalysisVersion>
<MicrosoftILVerificationVersion>7.0.0-alpha.1.22060.1</MicrosoftILVerificationVersion>
<MicrosoftServiceHubVersion>3.1.4097</MicrosoftServiceHubVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.2.32</MicrosoftVisualStudioThreadingPackagesVersion>
<MicrosoftServiceHubVersion>4.0.117</MicrosoftServiceHubVersion>
<MicrosoftVisualStudioThreadingPackagesVersion>17.3.1-alpha</MicrosoftVisualStudioThreadingPackagesVersion>
</PropertyGroup>
<!--
Dependency versions
Expand Down Expand Up @@ -278,7 +278,7 @@
create a test insertion in Visual Studio to validate.
-->
<NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion>
<StreamJsonRpcVersion>2.11.35</StreamJsonRpcVersion>
<StreamJsonRpcVersion>2.12.7-alpha</StreamJsonRpcVersion>
<!--
When updating the S.C.I or S.R.M version please let the MSBuild team know in advance so they
can update to the same version. Version changes require a VS test insertion for validation.
Expand Down
4 changes: 2 additions & 2 deletions eng/targets/GenerateServiceHubConfigurationFiles.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ServiceHubServiceJsonFile Include="$(IntermediateOutputPath)%(_ServicesWithBitness.Identity)%(_ServicesWithBitness.FileSuffix).servicehub.service.json" Runtime="%(_ServicesWithBitness.Runtime)" Condition="'%(_ServicesWithBitness.Runtime)' == 'desktop'" >
<Content>
<![CDATA[{
"host": "desktopClr",
"host": "netfx.anycpu",
"hostId": "RoslynCodeAnalysisService%(_ServicesWithBitness.HostIdSuffix)",
"hostGroupAllowed": true,
"serviceOverride": true,
Expand All @@ -37,7 +37,7 @@
<ServiceHubServiceJsonFile Include="$(IntermediateOutputPath)%(_ServicesWithBitness.Identity)%(_ServicesWithBitness.FileSuffix).servicehub.service.json" Runtime="%(_ServicesWithBitness.Runtime)" Condition="'%(_ServicesWithBitness.Runtime)' == 'core'" >
<Content>
<![CDATA[{
"host": "coreClr",
"host": "dotnet",
"hostId": "RoslynCodeAnalysisService%(_ServicesWithBitness.HostIdSuffix)",
"hostGroupAllowed": true,
"serviceOverride": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.UnitTests.SpellCheck;
using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.SpellCheck
{
[UseExportProvider]
public class SpellCheckFixerProviderTests : AbstractSpellCheckFixerProviderTests
{
protected override TestWorkspace CreateWorkspace(string content)
=> TestWorkspace.CreateCSharp(content);

[WpfFact]
public async Task TestRenameClassName()
{
await TestSuccessAsync(
"""
class {|CorrectlySpelled:CrrectlySpelled|}
{
public CrrectlySpelled() { }
}
""",
"""
class CorrectlySpelled
{
public CorrectlySpelled() { }
}
""");
}

[WpfFact]
public async Task TestBogusLocation()
{
// Should not be called inside a string. But we should still apply the change.
await TestFailureAsync(
"""
class C
{
void M()
{
var v1 = "{|word:wrd|}";
var v2 = "wrd";
}
}
""",
"""
class C
{
void M()
{
var v1 = "word";
var v2 = "wrd";
}
}
""");
}

[WpfFact]
public async Task TestReplacementThatLanguageDoesNotSupport()
{
// Should not be called inside a string. But we should still apply the change.
await TestFailureAsync(
"""
class {|Bo()gus:Orginal|}
{
public Orginal() { }
}
""",
"""
class Bo()gus
{
public Orginal() { }
}
""");
}

[WpfFact]
public async Task TestReplacementSpanLargerThanToken()
{
// Replacement span is larger than the lang token to rename.
await TestFailureAsync(
"""
class {|Replacement:Class |}
{
public Class() { }
}
""",
"""
class Replacement
{
public Class() { }
}
""");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal sealed class CompletionSessionData

public SnapshotPoint? ExpandedItemTriggerLocation { get; set; }
public TextSpan? CompletionListSpan { get; set; }
public ImmutableArray<CompletionItem>? CombinedSortedList { get; set; }
public CompletionList<CompletionItem>? CombinedSortedList { get; set; }
public Task<(CompletionContext, RoslynCompletionList)>? ExpandedItemsTask { get; set; }

private CompletionSessionData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
if (!options.ShouldShowItemsFromUnimportedNamespaces())
{
// No need to trigger expanded providers at all if the feature is disabled, just trigger core providers and return;
var (context, list) = await GetCompletionContextWorkerAsync(document, trigger, triggerLocation,
var (context, list) = await GetCompletionContextWorkerAsync(session, document, trigger, triggerLocation,
options with { ExpandedCompletionBehavior = ExpandedCompletionMode.NonExpandedItemsOnly }, cancellationToken).ConfigureAwait(false);

UpdateSessionData(session, sessionData, list, triggerLocation);
Expand All @@ -284,7 +284,7 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
{
// We tie the behavior of delaying expand items to editor's "responsive completion" option.
// i.e. "responsive completion" disabled == always wait for all items to be calculated.
var (context, list) = await GetCompletionContextWorkerAsync(document, trigger, triggerLocation,
var (context, list) = await GetCompletionContextWorkerAsync(session, document, trigger, triggerLocation,
options with { ExpandedCompletionBehavior = ExpandedCompletionMode.AllItems }, cancellationToken).ConfigureAwait(false);

UpdateSessionData(session, sessionData, list, triggerLocation);
Expand All @@ -298,7 +298,7 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
Stopwatch stopwatch = new();
var expandedItemsTask = Task.Run(async () =>
{
var result = await GetCompletionContextWorkerAsync(document, trigger, triggerLocation,
var result = await GetCompletionContextWorkerAsync(session, document, trigger, triggerLocation,
options with { ExpandedCompletionBehavior = ExpandedCompletionMode.ExpandedItemsOnly }, cancellationToken).ConfigureAwait(false);
// Record how long it takes for the background task to complete *after* core providers returned.
Expand All @@ -313,7 +313,7 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
}, cancellationToken);

// Now trigger and wait for core providers to return;
var (nonExpandedContext, nonExpandedCompletionList) = await GetCompletionContextWorkerAsync(document, trigger, triggerLocation,
var (nonExpandedContext, nonExpandedCompletionList) = await GetCompletionContextWorkerAsync(session, document, trigger, triggerLocation,
options with { ExpandedCompletionBehavior = ExpandedCompletionMode.NonExpandedItemsOnly }, cancellationToken).ConfigureAwait(false);
UpdateSessionData(session, sessionData, nonExpandedCompletionList, triggerLocation);

Expand All @@ -324,7 +324,7 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
UpdateSessionData(session, sessionData, expandedCompletionList, triggerLocation);
AsyncCompletionLogger.LogImportCompletionGetContext(isBlocking: false, delayed: false);

return CombineCompletionContext(nonExpandedContext, expandedContext);
return CombineCompletionContext(session, nonExpandedContext, expandedContext);
}
else
{
Expand All @@ -345,24 +345,21 @@ public async Task<VSCompletionContext> GetCompletionContextAsync(
AsyncCompletionLogger.LogSourceGetContextTicksDataPoint(totalStopWatch.Elapsed, isCanceled: cancellationToken.IsCancellationRequested);
}

static VSCompletionContext CombineCompletionContext(VSCompletionContext context1, VSCompletionContext context2)
static VSCompletionContext CombineCompletionContext(IAsyncCompletionSession session, VSCompletionContext context1, VSCompletionContext context2)
{
if (context1.Items.IsEmpty && context1.SuggestionItemOptions is null)
if (context1.ItemList.IsEmpty && context1.SuggestionItemOptions is null)
return context2;

if (context2.Items.IsEmpty && context2.SuggestionItemOptions is null)
if (context2.ItemList.IsEmpty && context2.SuggestionItemOptions is null)
return context1;

using var _ = ArrayBuilder<VSCompletionItem>.GetInstance(context1.Items.Length + context2.Items.Length, out var itemsBuilder);
itemsBuilder.AddRange(context1.Items);
itemsBuilder.AddRange(context2.Items);

var completionList = session.CreateCompletionList(context1.ItemList.Concat(context2.ItemList));
var filterStates = FilterSet.CombineFilterStates(context1.Filters, context2.Filters);

var suggestionItem = context1.SuggestionItemOptions ?? context2.SuggestionItemOptions;
var hint = suggestionItem == null ? AsyncCompletionData.InitialSelectionHint.RegularSelection : AsyncCompletionData.InitialSelectionHint.SoftSelection;

return new VSCompletionContext(itemsBuilder.ToImmutableAndClear(), suggestionItem, hint, filterStates);
return new VSCompletionContext(completionList, suggestionItem, hint, filterStates, isIncomplete: false, properties: null);
}
}

Expand Down Expand Up @@ -408,7 +405,7 @@ public async Task<VSCompletionContext> GetExpandedCompletionContextAsync(
ExpandedCompletionBehavior = ExpandedCompletionMode.ExpandedItemsOnly
};

var (context, completionList) = await GetCompletionContextWorkerAsync(document, intialTrigger, initialTriggerLocation, options, cancellationToken).ConfigureAwait(false);
var (context, completionList) = await GetCompletionContextWorkerAsync(session, document, intialTrigger, initialTriggerLocation, options, cancellationToken).ConfigureAwait(false);
UpdateSessionData(session, sessionData, completionList, initialTriggerLocation);

return context;
Expand All @@ -419,6 +416,7 @@ public async Task<VSCompletionContext> GetExpandedCompletionContextAsync(
}

private async Task<(VSCompletionContext, CompletionList)> GetCompletionContextWorkerAsync(
IAsyncCompletionSession session,
Document document,
AsyncCompletionData.CompletionTrigger trigger,
SnapshotPoint triggerLocation,
Expand All @@ -443,26 +441,19 @@ public async Task<VSCompletionContext> GetExpandedCompletionContextAsync(
document, triggerLocation, options, document.Project.Solution.Options, roslynTrigger, _roles, cancellationToken).ConfigureAwait(false);

var filterSet = new FilterSet();
using var _ = ArrayBuilder<VSCompletionItem>.GetInstance(completionList.ItemsList.Count, out var itemsBuilder);

foreach (var roslynItem in completionList.ItemsList)
{
cancellationToken.ThrowIfCancellationRequested();
var item = Convert(document, roslynItem, filterSet, triggerLocation);
itemsBuilder.Add(item);
}
var completionItemList = session.CreateCompletionList(
completionList.ItemsList.Select(i => Convert(document, i, filterSet, triggerLocation, cancellationToken)));

var filters = filterSet.GetFilterStatesInSet();
var items = itemsBuilder.ToImmutable();

if (completionList.SuggestionModeItem is null)
return (new(items, suggestionItemOptions: null, selectionHint: AsyncCompletionData.InitialSelectionHint.RegularSelection, filters), completionList);
return (new(completionItemList, suggestionItemOptions: null, selectionHint: AsyncCompletionData.InitialSelectionHint.RegularSelection, filters, isIncomplete: false, null), completionList);

var suggestionItemOptions = new AsyncCompletionData.SuggestionItemOptions(
completionList.SuggestionModeItem.DisplayText,
completionList.SuggestionModeItem.Properties.TryGetValue(CommonCompletionItem.DescriptionProperty, out var description) ? description : string.Empty);

return (new(items, suggestionItemOptions, selectionHint: AsyncCompletionData.InitialSelectionHint.SoftSelection, filters), completionList);
return (new(completionItemList, suggestionItemOptions, selectionHint: AsyncCompletionData.InitialSelectionHint.SoftSelection, filters, isIncomplete: false, null), completionList);
}

private static void UpdateSessionData(IAsyncCompletionSession session, CompletionSessionData sessionData, CompletionList completionList, SnapshotPoint triggerLocation)
Expand Down Expand Up @@ -557,10 +548,12 @@ private VSCompletionItem Convert(
Document document,
RoslynCompletionItem roslynItem,
FilterSet filterSet,
SnapshotPoint initialTriggerLocation)
SnapshotPoint initialTriggerLocation,
CancellationToken cancellationToken)
{
VSCompletionItemData itemData;
cancellationToken.ThrowIfCancellationRequested();

VSCompletionItemData itemData;
if (roslynItem.Flags.IsCached() && s_roslynItemToVsItemData.TryGetValue(roslynItem, out var boxedItemData))
{
itemData = boxedItemData.Value;
Expand Down
Loading

0 comments on commit e445d36

Please sign in to comment.