Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to main-vs-deps #54405

Merged
28 commits merged into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1e33c08
Add new navigation pattern for Value Tracking
ryzngard Jun 17, 2021
87b57a5
Update src/VisualStudio/Core/Def/ValueTracking/TreeItemViewModel.cs
ryzngard Jun 17, 2021
57cdb28
Fix double click handler to preview. Move collection changed into own…
ryzngard Jun 17, 2021
897d2c4
Merge branch 'main' into feature/value_tracking_tree_navigation
ryzngard Jun 23, 2021
07601c1
PR feedback. Go back to more navigation for initial release
ryzngard Jun 24, 2021
53e848b
Merge branch 'feature/value_tracking_tree_navigation' of https://www.…
ryzngard Jun 24, 2021
72c771a
Correctness...
ryzngard Jun 24, 2021
4a453c7
Sure, why not
CyrusNajmabadi Jun 24, 2021
7cdaaad
Fast progression search.
CyrusNajmabadi Jun 25, 2021
cdbede7
Update tests
CyrusNajmabadi Jun 25, 2021
d105390
Fixup tests
CyrusNajmabadi Jun 25, 2021
65cefe1
Report as we get results
CyrusNajmabadi Jun 25, 2021
21dd1a3
Multple matches
CyrusNajmabadi Jun 25, 2021
987a5c3
Split tests
CyrusNajmabadi Jun 25, 2021
c93d06a
not roaming
CyrusNajmabadi Jun 25, 2021
380572b
vert
CyrusNajmabadi Jun 25, 2021
f684737
Simplify glyph computation
CyrusNajmabadi Jun 25, 2021
f6ff0f7
Remove unused property
CyrusNajmabadi Jun 25, 2021
c7a45ed
Cleanup
CyrusNajmabadi Jun 25, 2021
a8c3567
Finer grained cancellation
CyrusNajmabadi Jun 25, 2021
eb02555
Merge pull request #54382 from CyrusNajmabadi/progression
CyrusNajmabadi Jun 25, 2021
b3e26b0
Merge remote-tracking branch 'upstream/main' into progrssionCancellation
CyrusNajmabadi Jun 25, 2021
e60d86a
remove disable
CyrusNajmabadi Jun 25, 2021
ee996f2
Merge pull request #54163 from ryzngard/feature/value_tracking_tree_n…
ryzngard Jun 25, 2021
9212aee
pass tokens
CyrusNajmabadi Jun 25, 2021
39dd19d
pass tokens
CyrusNajmabadi Jun 25, 2021
2384855
Add IVT for UnitTestingHostReloadService (#54366)
vritant24 Jun 25, 2021
da30d23
Merge pull request #54402 from CyrusNajmabadi/progrssionCancellation
CyrusNajmabadi Jun 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@ private ReadOnlyCollection<DescriptionItem> CreateDescriptionItems()
}

var sourceText = document.GetTextSynchronously(CancellationToken.None);
var item = _searchResult.NavigableItem;
var spanStart = item.SourceSpan.Start;
if (item.IsStale && spanStart > sourceText.Length)
{
// in the case of a stale item, the span may be out of bounds of the document. Cap
// us to the end of the document as that's where we're going to navigate the user
// to.
spanStart = sourceText.Length;
}
var span = NavigateToUtilities.GetBoundedSpan(_searchResult.NavigableItem, sourceText);

var items = new List<DescriptionItem>
{
Expand All @@ -79,7 +71,7 @@ private ReadOnlyCollection<DescriptionItem> CreateDescriptionItems()
new ReadOnlyCollection<DescriptionRun>(
new[] { new DescriptionRun("Line:", bold: true) }),
new ReadOnlyCollection<DescriptionRun>(
new[] { new DescriptionRun((sourceText.Lines.IndexOf(spanStart) + 1).ToString()) }))
new[] { new DescriptionRun((sourceText.Lines.IndexOf(span.Start) + 1).ToString()) }))
};

var summary = _searchResult.Summary;
Expand Down
17 changes: 1 addition & 16 deletions src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,7 @@ public NavigateToItemProvider(
ISet<string> INavigateToItemProvider2.KindsProvided => KindsProvided;

public ImmutableHashSet<string> KindsProvided
{
get
{
var result = ImmutableHashSet.Create<string>(StringComparer.Ordinal);
foreach (var project in _workspace.CurrentSolution.Projects)
{
var navigateToSearchService = project.GetLanguageService<INavigateToSearchService>();
if (navigateToSearchService != null)
{
result = result.Union(navigateToSearchService.KindsProvided);
}
}

return result;
}
}
=> NavigateToUtilities.GetKindsProvided(_workspace.CurrentSolution);

public bool CanFilter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3682,7 +3682,7 @@ public async Task UnitTestingHotReloadServiceTest()

var hotReload = new UnitTestingHotReloadService(workspace.Services);

await hotReload.StartSessionAsync(solution, CancellationToken.None);
await hotReload.StartSessionAsync(solution, ImmutableArray.Create("Baseline", "AddDefinitionToExistingType", "NewTypeDefinition"), CancellationToken.None);

var sessionId = hotReload.GetTestAccessor().SessionId;
var session = encService.GetTestAccessor().GetDebuggingSession(sessionId);
Expand All @@ -3694,13 +3694,13 @@ public async Task UnitTestingHotReloadServiceTest()

solution = solution.WithDocumentText(documentIdA, SourceText.From(source2, Encoding.UTF8));

var result = await hotReload.EmitSolutionUpdateAsync(solution, CancellationToken.None);
var result = await hotReload.EmitSolutionUpdateAsync(solution, true, CancellationToken.None);
Assert.Empty(result.diagnostics);
Assert.Equal(1, result.updates.Length);

solution = solution.WithDocumentText(documentIdA, SourceText.From(source3, Encoding.UTF8));

result = await hotReload.EmitSolutionUpdateAsync(solution, CancellationToken.None);
result = await hotReload.EmitSolutionUpdateAsync(solution, true, CancellationToken.None);
AssertEx.Equal(
new[] { "ENC0020: " + string.Format(FeaturesResources.Renaming_0_will_prevent_the_debug_session_from_continuing, FeaturesResources.method) },
result.diagnostics.Select(d => $"{d.Id}: {d.GetMessage()}"));
Expand Down
2 changes: 1 addition & 1 deletion src/Features/Core/Portable/Common/GlyphExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private static Glyph GetGlyph(string tag, ImmutableArray<string> allTags)
return Glyph.None;
}

private static Accessibility GetAccessibility(ImmutableArray<string> tags)
public static Accessibility GetAccessibility(ImmutableArray<string> tags)
{
foreach (var tag in tags)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ internal sealed class UnitTestingHotReloadService
{
private sealed class DebuggerService : IManagedEditAndContinueDebuggerService
{
public static readonly DebuggerService Instance = new();
private readonly ImmutableArray<string> _capabilities;

public DebuggerService(ImmutableArray<string> capabilities)
{
_capabilities = capabilities;
}

public Task<ImmutableArray<ManagedActiveStatementDebugInfo>> GetActiveStatementsAsync(CancellationToken cancellationToken)
=> Task.FromResult(ImmutableArray<ManagedActiveStatementDebugInfo>.Empty);

public Task<ManagedEditAndContinueAvailability> GetAvailabilityAsync(Guid module, CancellationToken cancellationToken)
=> Task.FromResult(new ManagedEditAndContinueAvailability(ManagedEditAndContinueAvailabilityStatus.Available));

// TODO: get capabilities from the runtime
public Task<ImmutableArray<string>> GetCapabilitiesAsync(CancellationToken cancellationToken)
=> Task.FromResult(ImmutableArray.Create("Baseline", "AddDefinitionToExistingType", "NewTypeDefinition"));
=> Task.FromResult(_capabilities);

public Task PrepareModuleForUpdateAsync(Guid module, CancellationToken cancellationToken)
=> Task.CompletedTask;
Expand Down Expand Up @@ -64,24 +68,27 @@ public UnitTestingHotReloadService(HostWorkspaceServices services)
/// Starts the watcher.
/// </summary>
/// <param name="solution">Solution that represents sources that match the built binaries on disk.</param>
/// <param name="capabilities">Array of capabilities retrieved from the runtime to dictate supported rude edits.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public async Task StartSessionAsync(Solution solution, CancellationToken cancellationToken)
public async Task StartSessionAsync(Solution solution, ImmutableArray<string> capabilities, CancellationToken cancellationToken)
{
var newSessionId = await _encService.StartDebuggingSessionAsync(solution, DebuggerService.Instance, captureMatchingDocuments: true, reportDiagnostics: false, cancellationToken).ConfigureAwait(false);
var newSessionId = await _encService.StartDebuggingSessionAsync(solution, new DebuggerService(capabilities), captureMatchingDocuments: true, reportDiagnostics: false, cancellationToken).ConfigureAwait(false);
Contract.ThrowIfFalse(_sessionId == default, "Session already started");
_sessionId = newSessionId;
}

/// <summary>
/// Emits updates for all projects that differ between the given <paramref name="solution"/> snapshot and the one given to the previous successful call or
/// the one passed to <see cref="StartSessionAsync(Solution, CancellationToken)"/> for the first invocation.
/// Emits updates for all projects that differ between the given <paramref name="solution"/> snapshot and the one given to the previous successful call
/// where <paramref name="commitUpdates"/> was `true` or the one passed to <see cref="StartSessionAsync(Solution, ImmutableArray{string}, CancellationToken)"/>
/// for the first invocation.
/// </summary>
/// <param name="solution">Solution snapshot.</param>
/// <param name="commitUpdates">commits changes if true, discards if false</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// Updates (one for each changed project) and Rude Edit diagnostics. Does not include syntax or semantic diagnostics.
/// </returns>
public async Task<(ImmutableArray<Update> updates, ImmutableArray<Diagnostic> diagnostics)> EmitSolutionUpdateAsync(Solution solution, CancellationToken cancellationToken)
public async Task<(ImmutableArray<Update> updates, ImmutableArray<Diagnostic> diagnostics)> EmitSolutionUpdateAsync(Solution solution, bool commitUpdates, CancellationToken cancellationToken)
{
var sessionId = _sessionId;
Contract.ThrowIfFalse(sessionId != default, "Session has not started");
Expand All @@ -90,7 +97,14 @@ public async Task StartSessionAsync(Solution solution, CancellationToken cancell

if (results.ModuleUpdates.Status == ManagedModuleUpdateStatus.Ready)
{
_encService.CommitSolutionUpdate(sessionId, out _);
if (commitUpdates)
{
_encService.CommitSolutionUpdate(sessionId, out _);
}
else
{
_encService.DiscardSolutionUpdate(sessionId);
}
}

var updates = results.ModuleUpdates.Updates.SelectAsArray(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.LiveUnitTesting.Orchestrator" Partner="UnitTesting" Key="$(UnitTestingKey)" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery" Partner="UnitTesting" Key="$(UnitTestingKey)" />
<RestrictedInternalsVisibleTo Include="Microsoft.CodeAnalysis.UnitTesting.SourceBasedTestDiscovery.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" />
<RestrictedInternalsVisibleTo Include="Microsoft.VisualStudio.TestWindow.Core" Partner="UnitTesting" Key="$(UnitTestingKey)" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.EditorFeatures" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.VisualBasic.Features" />
<InternalsVisibleTo Include="Roslyn.Hosting.Diagnostics" />
Expand Down
45 changes: 45 additions & 0 deletions src/Features/Core/Portable/NavigateTo/NavigateToUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.NavigateTo
{
internal static class NavigateToUtilities
{
public static ImmutableHashSet<string> GetKindsProvided(Solution solution)
{
var result = ImmutableHashSet.CreateBuilder<string>(StringComparer.Ordinal);
foreach (var project in solution.Projects)
{
var navigateToSearchService = project.GetLanguageService<INavigateToSearchService>();
if (navigateToSearchService != null)
result.UnionWith(navigateToSearchService.KindsProvided);
}

return result.ToImmutable();
}

public static TextSpan GetBoundedSpan(INavigableItem item, SourceText sourceText)
{
var spanStart = item.SourceSpan.Start;
var spanEnd = item.SourceSpan.End;
if (item.IsStale)
{
// in the case of a stale item, the span may be out of bounds of the document. Cap
// us to the end of the document as that's where we're going to navigate the user
// to.
spanStart = spanStart > sourceText.Length ? sourceText.Length : spanStart;
spanEnd = spanEnd > sourceText.Length ? sourceText.Length : spanEnd;
}

return TextSpan.FromBounds(spanStart, spanEnd);
}
}
}
Loading