Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release/dev17.3' into firstFix
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Mar 1, 2022
2 parents 3e3e3fc + cd34435 commit 8f4c7f0
Show file tree
Hide file tree
Showing 29 changed files with 550 additions and 216 deletions.
1 change: 1 addition & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
<add key="dotnet7-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7-transport/nuget/v3/index.json" />
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
<add key="nuget-build" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/nuget-build/nuget/v3/index.json" />
<add key="vssdk" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json" />
Expand Down
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<Sha>7e80445ee82adbf9a8e6ae601ac5e239d982afaa</Sha>
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build" Version="0.1.0-alpha.1.21616.4">
<Uri>https://github.com/dotnet/source-build</Uri>
<Sha>90bdf447e1b97605f109b34243ab8c9f215308e9</Sha>
<SourceBuild RepoName="source-build" ManagedOnly="true" />
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="7.0.0-alpha.1.22114.1">
<Uri>https://github.com/dotnet/source-build-externals</Uri>
<Sha>a28332454bd70964205fb18bf3d0a1146a228b25</Sha>
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<MajorVersion>4</MajorVersion>
<MinorVersion>2</MinorVersion>
<PatchVersion>0</PatchVersion>
<PreReleaseVersionLabel>2</PreReleaseVersionLabel>
<PreReleaseVersionLabel>3</PreReleaseVersionLabel>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<!--
By default the assembly version in official builds is "$(MajorVersion).$(MinorVersion).0.0".
Expand Down
8 changes: 4 additions & 4 deletions eng/config/PublishData.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@
"version": "4.2.*",
"packageFeeds": "default",
"channels": [],
"vsBranch": "rel/d17.2",
"vsBranch": "main",
"vsMajorVersion": 17,
"insertionTitlePrefix": "[d17.2p1]"
"insertionTitlePrefix": "[d17.2p2]"
},
"main": {
"nugetKind": [
Expand All @@ -234,8 +234,8 @@
"channels": [],
"vsBranch": "main",
"vsMajorVersion": 17,
"insertionCreateDraftPR": false,
"insertionTitlePrefix": "[d17.2p2]"
"insertionCreateDraftPR": true,
"insertionTitlePrefix": "[d17.2p3]"
},
"features/NullableReferenceTypes": {
"nugetKind": "PerBuildPreRelease",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ public Task<bool> CanNavigateToLineAndOffsetAsync(Workspace workspace, DocumentI
public Task<bool> CanNavigateToPositionAsync(Workspace workspace, DocumentId documentId, int position, int virtualSpace, CancellationToken cancellationToken)
=> SpecializedTasks.False;

public async Task<bool> TryNavigateToSpanAsync(Workspace workspace, DocumentId documentId, TextSpan textSpan, NavigationOptions options, bool allowInvalidSpan, CancellationToken cancellationToken)
public async Task<INavigableLocation?> GetLocationForSpanAsync(Workspace workspace, DocumentId documentId, TextSpan textSpan, NavigationOptions options, bool allowInvalidSpan, CancellationToken cancellationToken)
{
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
if (workspace is not InteractiveWindowWorkspace interactiveWorkspace)
{
Debug.Fail("InteractiveDocumentNavigationService called with incorrect workspace!");
return false;
return null;
}

if (interactiveWorkspace.Window is null)
{
Debug.Fail("We are trying to navigate with a workspace that doesn't have a window!");
return false;
return null;
}

var textView = interactiveWorkspace.Window.TextView;
Expand All @@ -58,35 +58,40 @@ public async Task<bool> TryNavigateToSpanAsync(Workspace workspace, DocumentId d
var textSnapshot = document?.GetTextSynchronously(cancellationToken).FindCorrespondingEditorTextSnapshot();
if (textSnapshot == null)
{
return false;
return null;
}

var snapshotSpan = new SnapshotSpan(textSnapshot, textSpan.Start, textSpan.Length);
var virtualSnapshotSpan = new VirtualSnapshotSpan(snapshotSpan);

if (!textView.TryGetSurfaceBufferSpan(virtualSnapshotSpan, out var surfaceBufferSpan))
{
return false;
return null;
}

textView.Selection.Select(surfaceBufferSpan.Start, surfaceBufferSpan.End);
textView.ViewScroller.EnsureSpanVisible(surfaceBufferSpan.SnapshotSpan, EnsureSpanVisibleOptions.AlwaysCenter);
return new NavigableLocation(async cancellationToken =>
{
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
textView.Selection.Select(surfaceBufferSpan.Start, surfaceBufferSpan.End);
textView.ViewScroller.EnsureSpanVisible(surfaceBufferSpan.SnapshotSpan, EnsureSpanVisibleOptions.AlwaysCenter);
// Moving the caret must be the last operation involving surfaceBufferSpan because
// it might update the version number of textView.TextSnapshot (VB does line commit
// when the caret leaves a line which might cause pretty listing), which must be
// equal to surfaceBufferSpan.SnapshotSpan.Snapshot's version number.
textView.Caret.MoveTo(surfaceBufferSpan.Start);
// Moving the caret must be the last operation involving surfaceBufferSpan because
// it might update the version number of textView.TextSnapshot (VB does line commit
// when the caret leaves a line which might cause pretty listing), which must be
// equal to surfaceBufferSpan.SnapshotSpan.Snapshot's version number.
textView.Caret.MoveTo(surfaceBufferSpan.Start);
textView.VisualElement.Focus();
textView.VisualElement.Focus();
return true;
return true;
});
}

public Task<bool> TryNavigateToLineAndOffsetAsync(Workspace workspace, DocumentId documentId, int lineNumber, int offset, NavigationOptions options, CancellationToken cancellationToken)
public Task<INavigableLocation?> GetLocationForLineAndOffsetAsync(Workspace workspace, DocumentId documentId, int lineNumber, int offset, NavigationOptions options, CancellationToken cancellationToken)
=> throw new NotSupportedException();

public Task<bool> TryNavigateToPositionAsync(Workspace workspace, DocumentId documentId, int position, int virtualSpace, NavigationOptions options, CancellationToken cancellationToken)
public Task<INavigableLocation?> GetLocationForPositionAsync(Workspace workspace, DocumentId documentId, int position, int virtualSpace, NavigationOptions options, CancellationToken cancellationToken)
=> throw new NotSupportedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.CodeAnalysis.SolutionCrawler;

namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api
{
Expand All @@ -28,6 +30,22 @@ public bool BlockForCompletionItems
set => _globalOptions.SetGlobalOption(new OptionKey(CompletionViewOptions.BlockForCompletionItems, InternalLanguageNames.TypeScript), value);
}

#pragma warning disable CA1822 // Mark members as static - TODO: will set global options in future
public void SetBackgroundAnalysisScope(Workspace workspace, bool openFilesOnly)
#pragma warning restore
{
var solution = workspace.CurrentSolution;
workspace.TryApplyChanges(solution.WithOptions(solution.Options
.WithChangedOption(
SolutionCrawlerOptions.BackgroundAnalysisScopeOption,
InternalLanguageNames.TypeScript,
openFilesOnly ? BackgroundAnalysisScope.OpenFiles : BackgroundAnalysisScope.FullSolution)
.WithChangedOption(
ServiceFeatureOnOffOptions.RemoveDocumentDiagnosticsOnDocumentClose,
InternalLanguageNames.TypeScript,
openFilesOnly)));
}

internal IGlobalOptionService Service => _globalOptions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,117 @@ public void F()

await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, languageVersion: "Preview", metadataLanguageVersion: "Preview", expected: expected, signaturesOnly: signaturesOnly);
}

[Theory, CombinatorialData, Trait(Traits.Feature, Traits.Features.MetadataAsSource)]
[WorkItem(44566, "https://github.com/dotnet/roslyn/issues/44566")]
public async Task TestRecordType(bool signaturesOnly)
{
var metadataSource = "public record R;";
var symbolName = "R";

var expected = signaturesOnly switch
{
true => $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// {CodeAnalysisResources.InMemoryAssembly}
#endregion
#nullable enable
using System;
using System.Runtime.CompilerServices;
using System.Text;
public record [|R|] : IEquatable<R>
{{
public R();
[CompilerGenerated]
protected R(R original);
protected virtual Type EqualityContract {{ get; }}
[CompilerGenerated]
public virtual R <Clone>$();
[CompilerGenerated]
public override bool Equals(object? obj);
[CompilerGenerated]
public virtual bool Equals(R? other);
[CompilerGenerated]
public override int GetHashCode();
[CompilerGenerated]
public override string ToString();
[CompilerGenerated]
protected virtual bool PrintMembers(StringBuilder builder);
[CompilerGenerated]
public static bool operator ==(R? left, R? right);
[CompilerGenerated]
public static bool operator !=(R? left, R? right);
}}",
false => $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// {CodeAnalysisResources.InMemoryAssembly}
// Decompiled with ICSharpCode.Decompiler {ICSharpCodeDecompilerVersion}
#endregion
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
public record [|R|]
{{
[CompilerGenerated]
public override string ToString()
{{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(""R"");
stringBuilder.Append("" {{ "");
if (PrintMembers(stringBuilder))
{{
stringBuilder.Append(' ');
}}
stringBuilder.Append('}}');
return stringBuilder.ToString();
}}
[CompilerGenerated]
protected virtual bool PrintMembers(StringBuilder builder)
{{
return false;
}}
[CompilerGenerated]
public override int GetHashCode()
{{
return EqualityComparer<Type>.Default.GetHashCode(EqualityContract);
}}
[CompilerGenerated]
public virtual bool Equals(R? other)
{{
return (object)this == other || ((object)other != null && EqualityContract == other!.EqualityContract);
}}
[CompilerGenerated]
protected R(R original)
{{
}}
public R()
{{
}}
}}
#if false // {CSharpEditorResources.Decompilation_log}
{string.Format(CSharpEditorResources._0_items_in_cache, 6)}
------------------
{string.Format(CSharpEditorResources.Resolve_0, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")}
{string.Format(CSharpEditorResources.Found_single_assembly_0, "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")}
{string.Format(CSharpEditorResources.Load_from_0, "mscorlib.v4_6_1038_0.dll")}
#endif",
};

await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, expected: expected, signaturesOnly: signaturesOnly);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,33 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Utilities.GoToHelpers
Return If(_canNavigateToSpan, SpecializedTasks.True, SpecializedTasks.False)
End Function

Public Function TryNavigateToLineAndOffsetAsync(workspace As Workspace, documentId As DocumentId, lineNumber As Integer, offset As Integer, options As NavigationOptions, cancellationToken As CancellationToken) As Task(Of Boolean) Implements IDocumentNavigationService.TryNavigateToLineAndOffsetAsync
Public Function GetLocationForLineAndOffsetAsync(workspace As Workspace, documentId As DocumentId, lineNumber As Integer, offset As Integer, options As NavigationOptions, cancellationToken As CancellationToken) As Task(Of INavigableLocation) Implements IDocumentNavigationService.GetLocationForLineAndOffsetAsync
_triedNavigationToLineAndOffset = True
_documentId = documentId
_options = options
_line = lineNumber
_offset = offset

Return If(_canNavigateToLineAndOffset, SpecializedTasks.True, SpecializedTasks.False)
Return NavigableLocation.TestAccessor.Create(_canNavigateToLineAndOffset)
End Function

Public Function TryNavigateToPositionAsync(workspace As Workspace, documentId As DocumentId, position As Integer, virtualSpace As Integer, options As NavigationOptions, cancellationToken As CancellationToken) As Task(Of Boolean) Implements IDocumentNavigationService.TryNavigateToPositionAsync
Public Function GetLocationForPositionAsync(workspace As Workspace, documentId As DocumentId, position As Integer, virtualSpace As Integer, options As NavigationOptions, cancellationToken As CancellationToken) As Task(Of INavigableLocation) Implements IDocumentNavigationService.GetLocationForPositionAsync
_triedNavigationToPosition = True
_documentId = documentId
_options = options
_position = position
_positionVirtualSpace = virtualSpace

Return If(_canNavigateToPosition, SpecializedTasks.True, SpecializedTasks.False)
Return NavigableLocation.TestAccessor.Create(_canNavigateToPosition)
End Function

Public Function TryNavigateToSpanAsync(workspace As Workspace, documentId As DocumentId, textSpan As TextSpan, options As NavigationOptions, allowInvalidSpan As Boolean, cancellationToken As CancellationToken) As Task(Of Boolean) Implements IDocumentNavigationService.TryNavigateToSpanAsync
Public Function GetLocationForSpanAsync(workspace As Workspace, documentId As DocumentId, textSpan As TextSpan, options As NavigationOptions, allowInvalidSpan As Boolean, cancellationToken As CancellationToken) As Task(Of INavigableLocation) Implements IDocumentNavigationService.GetLocationForSpanAsync
_triedNavigationToSpan = True
_documentId = documentId
_options = options
_span = textSpan

Return If(_canNavigateToSpan, SpecializedTasks.True, SpecializedTasks.False)
Return NavigableLocation.TestAccessor.Create(_canNavigateToSpan)
End Function
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,30 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Utilities
Return If(CanNavigateToSpanReturnValue, SpecializedTasks.True, SpecializedTasks.False)
End Function

Public Function TryNavigateToLineAndOffsetAsync(workspace As Workspace, documentId As DocumentId, lineNumber As Integer, offset As Integer, options As NavigationOptions, cancellationToken As CancellationToken) As Task(Of Boolean) Implements IDocumentNavigationService.TryNavigateToLineAndOffsetAsync
Public Function GetLocationForLineAndOffsetAsync(workspace As Workspace, documentId As DocumentId, lineNumber As Integer, offset As Integer, options As NavigationOptions, cancellationToken As CancellationToken) As Task(Of INavigableLocation) Implements IDocumentNavigationService.GetLocationForLineAndOffsetAsync
Me.ProvidedDocumentId = documentId
Me.ProvidedLineNumber = lineNumber
Me.ProvidedOffset = offset
Me.ProvidedOptions = options

Return If(TryNavigateToLineAndOffsetReturnValue, SpecializedTasks.True, SpecializedTasks.False)
Return NavigableLocation.TestAccessor.Create(TryNavigateToLineAndOffsetReturnValue)
End Function

Public Function TryNavigateToPositionAsync(workspace As Workspace, documentId As DocumentId, position As Integer, virtualSpace As Integer, options As NavigationOptions, cancellationToken As CancellationToken) As Task(Of Boolean) Implements IDocumentNavigationService.TryNavigateToPositionAsync
Public Function GetLocationForPositionAsync(workspace As Workspace, documentId As DocumentId, position As Integer, virtualSpace As Integer, options As NavigationOptions, cancellationToken As CancellationToken) As Task(Of INavigableLocation) Implements IDocumentNavigationService.GetLocationForPositionAsync
Me.ProvidedDocumentId = documentId
Me.ProvidedPosition = position
Me.ProvidedVirtualSpace = virtualSpace
Me.ProvidedOptions = options

Return If(TryNavigateToPositionReturnValue, SpecializedTasks.True, SpecializedTasks.False)
Return NavigableLocation.TestAccessor.Create(TryNavigateToPositionReturnValue)
End Function

Public Function TryNavigateToSpanAsync(workspace As Workspace, documentId As DocumentId, textSpan As TextSpan, options As NavigationOptions, allowInvalidSpans As Boolean, cancellationToken As CancellationToken) As Task(Of Boolean) Implements IDocumentNavigationService.TryNavigateToSpanAsync
Public Function GetLocationForSpanAsync(workspace As Workspace, documentId As DocumentId, textSpan As TextSpan, options As NavigationOptions, allowInvalidSpans As Boolean, cancellationToken As CancellationToken) As Task(Of INavigableLocation) Implements IDocumentNavigationService.GetLocationForSpanAsync
Me.ProvidedDocumentId = documentId
Me.ProvidedTextSpan = textSpan
Me.ProvidedOptions = options

Return If(TryNavigateToSpanReturnValue, SpecializedTasks.True, SpecializedTasks.False)
Return NavigableLocation.TestAccessor.Create(TryNavigateToSpanReturnValue)
End Function
End Class
End Class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public bool TryNavigateToPosition(Workspace workspace, DocumentId documentId, in
return _threadingProvider.Service.Run(() => obj.TryNavigateToPositionAsync(workspace, documentId, position, virtualSpace, NavigationOptions.Default, cancellationToken));
}

/// <inheritdoc cref="IDocumentNavigationService.TryNavigateToPositionAsync"/>
public bool TryNavigateToPosition(Workspace workspace, DocumentId documentId, int position, int virtualSpace, CancellationToken cancellationToken)
{
var obj = _underlyingObject;
Expand Down
Loading

0 comments on commit 8f4c7f0

Please sign in to comment.