提交 fbaf5c84 编写于 作者: C Cyrus Najmabadi

Merge remote-tracking branch 'upstream/master' into remoteIndices

......@@ -3,9 +3,9 @@
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.20215.5">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.20230.5">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>36fd49bf87b14b78d722179b787e6518b5205518</Sha>
<Sha>5fd50687c9a9f39bd2ee8221165ea9c1b3f565d9</Sha>
</Dependency>
<Dependency Name="Microsoft.Net.Compilers.Toolset" Version="3.7.0-1.20210.7">
<Uri>https://github.com/dotnet/roslyn</Uri>
......
......@@ -410,6 +410,14 @@ function TestUsingOptimizedRunner() {
$dlls = $dlls | ?{ -not ($_.FullName -match ".*\\ref\\.*") }
$dlls = $dlls | ?{ -not ($_.FullName -match ".*/ref/.*") }
if ($configuration -eq 'Debug') {
$excludedConfiguration = 'Release'
} else {
$excludedConfiguration = 'Debug'
}
$dlls = $dlls | ?{ -not (($_.FullName -match ".*\\$excludedConfiguration\\.*") -or ($_.FullName -match ".*/$excludedConfiguration/.*")) }
if ($ci) {
$args += " -xml"
if ($testVsi) {
......
......@@ -365,4 +365,28 @@ stages:
channelId: 760
transportFeed: 'https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v3/index.json'
shippingFeed: 'https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v3/index.json'
symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-symbols/nuget/v3/index.json'
- template: \eng\common\templates\post-build\channels\generic-public-channel.yml
parameters:
artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }}
publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }}
symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }}
stageName: 'NETCore_SDK_314xx_Publishing'
channelName: '.NET Core SDK 3.1.4xx'
channelId: 921
transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1-transport/nuget/v3/index.json'
shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1/nuget/v3/index.json'
symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1-symbols/nuget/v3/index.json'
- template: \eng\common\templates\post-build\channels\generic-internal-channel.yml
parameters:
artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }}
publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }}
symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }}
stageName: 'NETCore_SDK_314xx_Internal_Publishing'
channelName: '.NET Core SDK 3.1.4xx Internal'
channelId: 922
transportFeed: 'https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v3/index.json'
shippingFeed: 'https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v3/index.json'
symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-symbols/nuget/v3/index.json'
\ No newline at end of file
......@@ -7,6 +7,6 @@
"xcopy-msbuild": "16.4.0-alpha"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.20215.5"
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.20230.5"
}
}
......@@ -128,6 +128,8 @@ private BoundExpression LowerSwitchExpression(BoundConvertedSwitchExpression nod
result.Add(_factory.Throw(thrownExpression));
}
if (GenerateInstrumentation)
result.Add(_factory.HiddenSequencePoint());
result.Add(_factory.Label(afterSwitchExpression));
if (produceDetailedSequencePoints)
result.Add(new BoundRestorePreviousSequencePoint(node.Syntax, restorePointForEnclosingStatement));
......
......@@ -37,8 +37,8 @@ private sealed class BoundSpillSequenceBuilder : BoundExpression
private ArrayBuilder<LocalSymbol> _locals;
private ArrayBuilder<BoundStatement> _statements;
public BoundSpillSequenceBuilder(BoundExpression value = null)
: base(SpillSequenceBuilderKind, null, value?.Type)
public BoundSpillSequenceBuilder(SyntaxNode syntax, BoundExpression value = null)
: base(SpillSequenceBuilderKind, syntax, value?.Type)
{
Debug.Assert(value?.Kind != SpillSequenceBuilderKind);
this.Value = value;
......@@ -77,7 +77,7 @@ public ImmutableArray<BoundStatement> GetStatements()
internal BoundSpillSequenceBuilder Update(BoundExpression value)
{
var result = new BoundSpillSequenceBuilder(value);
var result = new BoundSpillSequenceBuilder(this.Syntax, value);
result._locals = _locals;
result._statements = _statements;
return result;
......@@ -285,6 +285,8 @@ private BoundStatement UpdateStatement(BoundSpillSequenceBuilder builder, BoundS
bool sideEffectsOnly = false)
{
Debug.Assert(builder != null);
if (builder.Syntax != null)
_F.Syntax = builder.Syntax;
while (true)
{
......@@ -441,7 +443,7 @@ private BoundStatement UpdateStatement(BoundSpillSequenceBuilder builder, BoundS
if (builder == null)
{
builder = new BoundSpillSequenceBuilder();
builder = new BoundSpillSequenceBuilder(lastSpill < newList.Length ? (newList[lastSpill] as BoundSpillSequenceBuilder)?.Syntax : null);
}
var result = ArrayBuilder<BoundExpression>.GetInstance(newList.Length);
......@@ -545,7 +547,7 @@ public override BoundNode VisitAwaitExpression(BoundAwaitExpression node)
public override BoundNode VisitSpillSequence(BoundSpillSequence node)
{
var builder = new BoundSpillSequenceBuilder();
var builder = new BoundSpillSequenceBuilder(node.Syntax);
// Ensure later errors (e.g. in async rewriting) are associated with the correct node.
_F.Syntax = node.Syntax;
......@@ -583,7 +585,7 @@ public override BoundNode VisitArrayAccess(BoundArrayAccess node)
// spill the array if there were await expressions in the indices
if (builder == null)
{
builder = new BoundSpillSequenceBuilder();
builder = new BoundSpillSequenceBuilder(indicesBuilder.Syntax);
}
expression = Spill(builder, expression);
......@@ -611,7 +613,7 @@ public override BoundNode VisitArrayCreation(BoundArrayCreation node)
else
{
// spill bounds expressions if initializers contain await
var boundsBuilder = new BoundSpillSequenceBuilder();
var boundsBuilder = new BoundSpillSequenceBuilder(builder.Syntax);
bounds = VisitExpressionList(ref boundsBuilder, node.Bounds, forceSpill: true);
boundsBuilder.Include(builder);
builder = boundsBuilder;
......@@ -662,7 +664,7 @@ public override BoundNode VisitAssignmentOperator(BoundAssignmentOperator node)
else
{
// if the right-hand-side has await, spill the left
var leftBuilder = new BoundSpillSequenceBuilder();
var leftBuilder = new BoundSpillSequenceBuilder(builder.Syntax);
switch (left.Kind)
{
......@@ -779,7 +781,7 @@ public override BoundNode VisitBinaryOperator(BoundBinaryOperator node)
}
else
{
var leftBuilder = new BoundSpillSequenceBuilder();
var leftBuilder = new BoundSpillSequenceBuilder(builder.Syntax);
left = VisitExpression(ref leftBuilder, node.Left);
left = Spill(leftBuilder, left);
if (node.OperatorKind == BinaryOperatorKind.LogicalBoolOr || node.OperatorKind == BinaryOperatorKind.LogicalBoolAnd)
......@@ -817,7 +819,7 @@ public override BoundNode VisitCall(BoundCall node)
else if (node.Method.RequiresInstanceReceiver)
{
// spill the receiver if there were await expressions in the arguments
var receiverBuilder = new BoundSpillSequenceBuilder();
var receiverBuilder = new BoundSpillSequenceBuilder(builder.Syntax);
receiver = node.ReceiverOpt;
RefKind refKind = ReceiverSpillRefKind(receiver);
......@@ -857,9 +859,9 @@ public override BoundNode VisitConditionalOperator(BoundConditionalOperator node
return UpdateExpression(conditionBuilder, node.Update(node.IsRef, condition, consequence, alternative, node.ConstantValueOpt, node.Type));
}
if (conditionBuilder == null) conditionBuilder = new BoundSpillSequenceBuilder();
if (consequenceBuilder == null) consequenceBuilder = new BoundSpillSequenceBuilder();
if (alternativeBuilder == null) alternativeBuilder = new BoundSpillSequenceBuilder();
if (conditionBuilder == null) conditionBuilder = new BoundSpillSequenceBuilder((consequenceBuilder ?? alternativeBuilder).Syntax);
if (consequenceBuilder == null) consequenceBuilder = new BoundSpillSequenceBuilder(alternativeBuilder.Syntax);
if (alternativeBuilder == null) alternativeBuilder = new BoundSpillSequenceBuilder(consequenceBuilder.Syntax);
if (node.Type.IsVoidType())
{
......@@ -952,7 +954,7 @@ public override BoundNode VisitNullCoalescingOperator(BoundNullCoalescingOperato
}
else
{
var leftBuilder = new BoundSpillSequenceBuilder();
var leftBuilder = new BoundSpillSequenceBuilder(builder.Syntax);
left = VisitExpression(ref leftBuilder, node.LeftOperand);
left = Spill(leftBuilder, left);
......@@ -987,10 +989,9 @@ public override BoundNode VisitLoweredConditionalAccess(BoundLoweredConditionalA
return UpdateExpression(receiverBuilder, node.Update(receiver, node.HasValueMethodOpt, whenNotNull, whenNullOpt, node.Id, node.Type));
}
if (receiverBuilder == null) receiverBuilder = new BoundSpillSequenceBuilder();
if (whenNotNullBuilder == null) whenNotNullBuilder = new BoundSpillSequenceBuilder();
if (whenNullBuilder == null) whenNullBuilder = new BoundSpillSequenceBuilder();
if (receiverBuilder == null) receiverBuilder = new BoundSpillSequenceBuilder((whenNotNullBuilder ?? whenNullBuilder).Syntax);
if (whenNotNullBuilder == null) whenNotNullBuilder = new BoundSpillSequenceBuilder(whenNullBuilder.Syntax);
if (whenNullBuilder == null) whenNullBuilder = new BoundSpillSequenceBuilder(whenNotNullBuilder.Syntax);
BoundExpression condition;
if (receiver.Type.IsReferenceType || receiver.Type.IsValueType || receiverRefKind == RefKind.None)
......@@ -1144,7 +1145,7 @@ public override BoundNode VisitPointerElementAccess(BoundPointerElementAccess no
}
else
{
var expressionBuilder = new BoundSpillSequenceBuilder();
var expressionBuilder = new BoundSpillSequenceBuilder(builder.Syntax);
expression = VisitExpression(ref expressionBuilder, node.Expression);
expression = Spill(expressionBuilder, expression);
expressionBuilder.Include(builder);
......@@ -1177,7 +1178,7 @@ public override BoundNode VisitSequence(BoundSequence node)
if (builder == null)
{
builder = new BoundSpillSequenceBuilder();
builder = new BoundSpillSequenceBuilder(valueBuilder.Syntax);
}
PromoteAndAddLocals(builder, node.Locals);
......
......@@ -333,39 +333,39 @@ public async Task M(IDisposable disposable)
});
vd.VerifyPdb("C.M", @"
<symbols>
<files>
<file id=""1"" name="""" language=""C#"" />
</files>
<methods>
<method containingType=""C"" name=""M"" parameterNames=""disposable"">
<customDebugInfo>
<forwardIterator name=""&lt;M&gt;d__3"" />
<encLocalSlotMap>
<slot kind=""6"" offset=""11"" />
<slot kind=""8"" offset=""11"" />
<slot kind=""0"" offset=""11"" />
<slot kind=""4"" offset=""53"" />
<slot kind=""6"" offset=""98"" />
<slot kind=""8"" offset=""98"" />
<slot kind=""0"" offset=""98"" />
<slot kind=""4"" offset=""151"" />
<slot kind=""4"" offset=""220"" />
<slot kind=""28"" offset=""281"" />
<slot kind=""28"" offset=""281"" ordinal=""1"" />
<slot kind=""28"" offset=""261"" />
<slot kind=""28"" offset=""281"" ordinal=""2"" />
<slot kind=""28"" offset=""281"" ordinal=""3"" />
<slot kind=""28"" offset=""281"" ordinal=""4"" />
<slot kind=""4"" offset=""307"" />
<slot kind=""4"" offset=""376"" />
<slot kind=""3"" offset=""410"" />
<slot kind=""2"" offset=""410"" />
</encLocalSlotMap>
</customDebugInfo>
</method>
</methods>
</symbols>
<symbols>
<files>
<file id=""1"" name="""" language=""C#"" />
</files>
<methods>
<method containingType=""C"" name=""M"" parameterNames=""disposable"">
<customDebugInfo>
<forwardIterator name=""&lt;M&gt;d__3"" />
<encLocalSlotMap>
<slot kind=""6"" offset=""11"" />
<slot kind=""8"" offset=""11"" />
<slot kind=""0"" offset=""11"" />
<slot kind=""4"" offset=""53"" />
<slot kind=""6"" offset=""98"" />
<slot kind=""8"" offset=""98"" />
<slot kind=""0"" offset=""98"" />
<slot kind=""4"" offset=""151"" />
<slot kind=""4"" offset=""220"" />
<slot kind=""28"" offset=""261"" />
<slot kind=""28"" offset=""261"" ordinal=""1"" />
<slot kind=""28"" offset=""261"" ordinal=""2"" />
<slot kind=""28"" offset=""281"" />
<slot kind=""28"" offset=""281"" ordinal=""1"" />
<slot kind=""28"" offset=""281"" ordinal=""2"" />
<slot kind=""4"" offset=""307"" />
<slot kind=""4"" offset=""376"" />
<slot kind=""3"" offset=""410"" />
<slot kind=""2"" offset=""410"" />
</encLocalSlotMap>
</customDebugInfo>
</method>
</methods>
</symbols>
");
}
......
......@@ -3375,6 +3375,7 @@ .maxstack 2
IL_0022: newobj ""Program..ctor()""
IL_0027: stloc.2
IL_0028: br.s IL_002a
// sequence point: <hidden>
IL_002a: ldc.i4.1
IL_002b: brtrue.s IL_002e
// sequence point: var y = (i s ... }).Chain()
......
......@@ -4083,7 +4083,7 @@ .maxstack 1
-IL_0027: ldc.i4.0
IL_0028: stloc.s V_4
IL_002a: br.s IL_002c
IL_002c: ldc.i4.1
~IL_002c: ldc.i4.1
IL_002d: brtrue.s IL_0030
-IL_002f: nop
~IL_0030: ldloc.s V_4
......@@ -4165,7 +4165,7 @@ .maxstack 1
-IL_0026: ldc.i4.2
IL_0027: stloc.s V_5
IL_0029: br.s IL_002b
IL_002b: ldc.i4.1
~IL_002b: ldc.i4.1
IL_002c: brtrue.s IL_002f
-IL_002e: nop
-IL_002f: ldloc.s V_5
......@@ -4174,7 +4174,7 @@ .maxstack 1
-IL_0035: ldc.i4.3
IL_0036: stloc.s V_4
IL_0038: br.s IL_003a
IL_003a: ldc.i4.1
~IL_003a: ldc.i4.1
IL_003b: brtrue.s IL_003e
-IL_003d: nop
~IL_003e: ldloc.s V_4
......@@ -4380,7 +4380,7 @@ .maxstack 2
-IL_0023: ldc.i4.2
IL_0024: stloc.s V_7
IL_0026: br.s IL_0028
IL_0028: ldc.i4.1
~IL_0028: ldc.i4.1
IL_0029: brtrue.s IL_002c
-IL_002b: nop
-IL_002c: ldloc.s V_7
......@@ -4389,7 +4389,7 @@ .maxstack 2
-IL_0032: ldc.i4.1
IL_0033: stloc.s V_5
IL_0035: br.s IL_0037
IL_0037: ldc.i4.1
~IL_0037: ldc.i4.1
IL_0038: brtrue.s IL_003b
-IL_003a: nop
~IL_003b: ldloc.s V_5
......
......@@ -24,8 +24,8 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
Friend Class TestState
Inherits AbstractCommandHandlerTestState
Private Const timeoutMs = 10000
Private Const editorTimeoutMs = 20000
Private Const timeoutMs = 60000
Private Const editorTimeoutMs = 60000
Friend Const RoslynItem = "RoslynItem"
Friend ReadOnly EditorCompletionCommandHandler As ICommandHandler
Friend ReadOnly CompletionPresenterProvider As ICompletionPresenterProvider
......
......@@ -68,6 +68,8 @@ protected void SetUpEditor(string markupCode)
{
MarkupTestFile.GetPosition(markupCode, out string code, out int caretPosition);
VisualStudio.Editor.DismissCompletionSessions();
var originalValue = VisualStudio.Workspace.IsPrettyListingOn(LanguageName);
VisualStudio.Workspace.SetPrettyListing(LanguageName, false);
......
......@@ -487,6 +487,13 @@ public void DismissLightBulbSession()
broker.DismissSession(view);
});
public void DismissCompletionSessions()
=> ExecuteOnActiveView(view =>
{
var broker = GetComponentModel().GetService<ICompletionBroker>();
broker.DismissAllSessions(view);
});
protected abstract bool HasActiveTextView();
protected abstract IWpfTextView GetActiveTextView();
......
......@@ -14,6 +14,7 @@
using Microsoft.VisualStudio.IntegrationTest.Utilities.InProcess;
using Microsoft.VisualStudio.IntegrationTest.Utilities.Input;
using UIAutomationClient;
using Xunit;
namespace Microsoft.VisualStudio.IntegrationTest.Utilities.OutOfProcess
{
......@@ -233,7 +234,10 @@ public bool IsUseSuggestionModeOn()
=> _editorInProc.IsUseSuggestionModeOn();
public void SetUseSuggestionMode(bool value)
=> _editorInProc.SetUseSuggestionMode(value);
{
Assert.False(IsCompletionActive());
_editorInProc.SetUseSuggestionMode(value);
}
public void WaitForActiveView(string viewName)
=> _editorInProc.WaitForActiveView(viewName);
......
......@@ -77,6 +77,12 @@ public bool IsLightBulbSessionExpanded()
public void DismissLightBulbSession()
=> _textViewWindowInProc.DismissLightBulbSession();
public void DismissCompletionSessions()
{
WaitForCompletionSet();
_textViewWindowInProc.DismissCompletionSessions();
}
public string[] GetLightBulbActions()
=> _textViewWindowInProc.GetLightBulbActions();
......
......@@ -25,8 +25,10 @@ internal static partial class DependentTypeFinder
{
using (Logger.LogBlock(functionId, cancellationToken))
{
var project = solution.GetOriginatingProject(type);
var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);
if (client != null)
if (client != null &&
project != null)
{
var result = await client.TryRunRemoteAsync<ImmutableArray<SerializableSymbolAndProjectId>>(
WellKnownServiceHubServices.CodeAnalysisService,
......@@ -34,7 +36,7 @@ internal static partial class DependentTypeFinder
solution,
new object[]
{
SerializableSymbolAndProjectId.Dehydrate(solution, type, cancellationToken),
SerializableSymbolAndProjectId.Create(type, project, cancellationToken),
projects?.Select(p => p.Id).ToArray(),
transitive,
},
......
......@@ -21,9 +21,6 @@ public static partial class SymbolFinder
public static Task<IEnumerable<SymbolCallerInfo>> FindCallersAsync(
ISymbol symbol, Solution solution, CancellationToken cancellationToken = default)
{
if (solution.GetOriginatingProjectId(symbol) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(symbol));
return FindCallersAsync(symbol, solution, documents: null, cancellationToken: cancellationToken);
}
......@@ -33,9 +30,6 @@ public static partial class SymbolFinder
public static async Task<IEnumerable<SymbolCallerInfo>> FindCallersAsync(
ISymbol symbol, Solution solution, IImmutableSet<Document> documents, CancellationToken cancellationToken = default)
{
if (solution.GetOriginatingProjectId(symbol) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(symbol));
symbol = symbol.OriginalDefinition;
var foundSymbol = await FindSourceDefinitionAsync(symbol, solution, cancellationToken).ConfigureAwait(false);
symbol = foundSymbol ?? symbol;
......@@ -77,8 +71,6 @@ async Task AddReferencingSymbols(ReferencedSymbol reference, bool isDirect)
IImmutableSet<Document> documents,
CancellationToken cancellationToken = default)
{
Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
if (symbol != null)
{
if (symbol.Kind == SymbolKind.Event ||
......
......@@ -27,12 +27,12 @@ public static partial class SymbolFinder
FindReferencesSearchOptions options,
CancellationToken cancellationToken)
{
Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
using (Logger.LogBlock(FunctionId.FindReference, cancellationToken))
{
var project = solution.GetOriginatingProject(symbol);
var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);
if (client != null)
if (client != null &&
project != null)
{
// Create a callback that we can pass to the server process to hear about the
// results as it finds them. When we hear about results we'll forward them to
......@@ -45,7 +45,7 @@ public static partial class SymbolFinder
solution,
new object[]
{
SerializableSymbolAndProjectId.Dehydrate(solution, symbol, cancellationToken),
SerializableSymbolAndProjectId.Create(symbol, project, cancellationToken),
documents?.Select(d => d.Id).ToArray(),
SerializableFindReferencesSearchOptions.Dehydrate(options),
},
......
......@@ -29,9 +29,6 @@ public static partial class SymbolFinder
Solution solution,
CancellationToken cancellationToken = default)
{
if (solution.GetOriginatingProjectId(symbol) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(symbol));
return FindReferencesAsync(symbol, solution, FindReferencesSearchOptions.Default, cancellationToken);
}
......@@ -41,8 +38,6 @@ public static partial class SymbolFinder
FindReferencesSearchOptions options,
CancellationToken cancellationToken)
{
Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
var progressCollector = new StreamingProgressCollector();
await FindReferencesAsync(
symbol, solution, progressCollector,
......@@ -63,9 +58,6 @@ public static partial class SymbolFinder
IImmutableSet<Document> documents,
CancellationToken cancellationToken = default)
{
if (solution.GetOriginatingProjectId(symbol) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(symbol));
return FindReferencesAsync(symbol, solution, progress: null, documents: documents, cancellationToken: cancellationToken);
}
......@@ -85,9 +77,6 @@ public static partial class SymbolFinder
IImmutableSet<Document> documents,
CancellationToken cancellationToken = default)
{
if (solution.GetOriginatingProjectId(symbol) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(symbol));
return FindReferencesAsync(
symbol, solution, progress, documents,
FindReferencesSearchOptions.Default, cancellationToken);
......@@ -101,8 +90,6 @@ public static partial class SymbolFinder
FindReferencesSearchOptions options,
CancellationToken cancellationToken)
{
Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
progress ??= NoOpFindReferencesProgress.Instance;
var streamingProgress = new StreamingProgressCollector(
new StreamingFindReferencesProgressAdapter(progress));
......
......@@ -24,9 +24,6 @@ public static partial class SymbolFinder
public static async Task<IEnumerable<ISymbol>> FindOverridesAsync(
ISymbol symbol, Solution solution, IImmutableSet<Project> projects = null, CancellationToken cancellationToken = default)
{
if (solution.GetOriginatingProjectId(symbol) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(symbol));
return await FindOverridesArrayAsync(symbol, solution, projects, cancellationToken).ConfigureAwait(false);
}
......@@ -86,9 +83,6 @@ public static partial class SymbolFinder
public static async Task<IEnumerable<ISymbol>> FindImplementedInterfaceMembersAsync(
ISymbol symbol, Solution solution, IImmutableSet<Project> projects = null, CancellationToken cancellationToken = default)
{
if (solution.GetOriginatingProjectId(symbol) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(symbol));
return await FindImplementedInterfaceMembersArrayAsync(symbol, solution, projects, cancellationToken).ConfigureAwait(false);
}
......@@ -210,9 +204,6 @@ public static partial class SymbolFinder
if (solution == null)
throw new ArgumentNullException(nameof(solution));
if (solution.GetOriginatingProjectId(type) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(type));
return await FindDerivedClassesArrayAsync(type, solution, transitive, projects, cancellationToken).ConfigureAwait(false);
}
......@@ -263,9 +254,6 @@ public static partial class SymbolFinder
if (solution == null)
throw new ArgumentNullException(nameof(solution));
if (solution.GetOriginatingProjectId(type) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(type));
return await FindDerivedInterfacesArrayAsync(type, solution, transitive, projects, cancellationToken).ConfigureAwait(false);
}
......@@ -315,9 +303,6 @@ public static partial class SymbolFinder
if (solution == null)
throw new ArgumentNullException(nameof(solution));
if (solution.GetOriginatingProjectId(type) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(type));
return await FindImplementationsArrayAsync(type, solution, transitive, projects, cancellationToken).ConfigureAwait(false);
}
......
......@@ -53,16 +53,18 @@ internal class SerializableSymbolAndProjectId
public static SerializableSymbolAndProjectId Dehydrate(
Solution solution, ISymbol symbol, CancellationToken cancellationToken)
{
var symbolKey = symbol.GetSymbolKey(cancellationToken);
var projectId = solution.GetOriginatingProjectId(symbol);
Contract.ThrowIfNull(projectId, WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
var project = solution.GetOriginatingProject(symbol);
Contract.ThrowIfNull(project, WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
return new SerializableSymbolAndProjectId
return Create(symbol, project, cancellationToken);
}
public static SerializableSymbolAndProjectId Create(ISymbol symbol, Project project, CancellationToken cancellationToken)
=> new SerializableSymbolAndProjectId
{
SymbolKeyData = symbolKey.ToString(),
ProjectId = projectId,
SymbolKeyData = symbol.GetSymbolKey(cancellationToken).ToString(),
ProjectId = project.Id,
};
}
public async Task<ISymbol> TryRehydrateAsync(
Solution solution, CancellationToken cancellationToken)
......
......@@ -125,14 +125,15 @@ internal sealed partial class RenameLocations
{
Contract.ThrowIfNull(solution);
Contract.ThrowIfNull(symbol);
Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
cancellationToken.ThrowIfCancellationRequested();
using (Logger.LogBlock(FunctionId.Renamer_FindRenameLocationsAsync, cancellationToken))
{
var project = solution.GetOriginatingProject(symbol);
var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);
if (client != null)
if (client != null &&
project != null)
{
var result = await client.TryRunRemoteAsync<SerializableRenameLocations>(
WellKnownServiceHubServices.CodeAnalysisService,
......@@ -140,7 +141,7 @@ internal sealed partial class RenameLocations
solution,
new object[]
{
SerializableSymbolAndProjectId.Dehydrate(solution, symbol, cancellationToken),
SerializableSymbolAndProjectId.Create(symbol, project, cancellationToken),
SerializableRenameOptionSet.Dehydrate(optionSet),
},
callbackTarget: null,
......
......@@ -27,9 +27,6 @@ public static partial class Renamer
if (symbol == null)
throw new ArgumentNullException(nameof(symbol));
if (solution.GetOriginatingProjectId(symbol) == null)
throw new ArgumentException(WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution, nameof(symbol));
if (string.IsNullOrEmpty(newName))
throw new ArgumentException(nameof(newName));
......@@ -117,15 +114,16 @@ internal static Task<RenameLocations> FindRenameLocationsAsync(Solution solution
{
Contract.ThrowIfNull(solution);
Contract.ThrowIfNull(symbol);
Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
Contract.ThrowIfTrue(string.IsNullOrEmpty(newName));
cancellationToken.ThrowIfCancellationRequested();
using (Logger.LogBlock(FunctionId.Renamer_RenameSymbolAsync, cancellationToken))
{
var project = solution.GetOriginatingProject(symbol);
var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);
if (client != null)
if (project != null &&
client != null)
{
var result = await client.TryRunRemoteAsync<SerializableConflictResolution>(
WellKnownServiceHubServices.CodeAnalysisService,
......@@ -133,7 +131,7 @@ internal static Task<RenameLocations> FindRenameLocationsAsync(Solution solution
solution,
new object[]
{
SerializableSymbolAndProjectId.Dehydrate(solution, symbol, cancellationToken),
SerializableSymbolAndProjectId.Create(symbol, project, cancellationToken),
newName,
SerializableRenameOptionSet.Dehydrate(optionSet),
nonConflictSymbols?.Select(s => SerializableSymbolAndProjectId.Dehydrate(solution, s, cancellationToken)).ToArray(),
......@@ -163,7 +161,6 @@ internal static Task<RenameLocations> FindRenameLocationsAsync(Solution solution
{
Contract.ThrowIfNull(solution);
Contract.ThrowIfNull(symbol);
Contract.ThrowIfNull(solution.GetOriginatingProjectId(symbol), WorkspacesResources.Symbols_project_could_not_be_found_in_the_provided_solution);
Contract.ThrowIfTrue(string.IsNullOrEmpty(newName));
cancellationToken.ThrowIfCancellationRequested();
......
......@@ -37,7 +37,7 @@ internal partial class CodeAnalysisService : IRemoteDependentTypeFinder
var types = await func(namedType, solution, projects).ConfigureAwait(false);
return types.SelectAsArray(
(Func<INamedTypeSymbol, SerializableSymbolAndProjectId>)(t => SerializableSymbolAndProjectId.Dehydrate(solution, t, cancellationToken)));
t => SerializableSymbolAndProjectId.Dehydrate(solution, t, cancellationToken));
}
}, cancellationToken);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册