Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8ae0670
Tell lsp client not to send us open/close notifications
dibarbet May 1, 2020
998c9eb
Improve performance of SyntaxTreeIndex checksum computation.
CyrusNajmabadi May 29, 2020
47ba106
Fix wrong reporting for removing parenthesis for stackalloc
Youssef1313 May 29, 2020
e6a8d54
Fix formatting
Youssef1313 May 29, 2020
0582200
Wait for callbacks to complete before returning
sharwell May 29, 2020
eda81b7
Update RemoveUnnecessaryExpressionParenthesesTests.cs
Youssef1313 May 29, 2020
358b99d
Update ParenthesizedExpressionSyntaxExtensions.cs
Youssef1313 May 29, 2020
c5c9f54
Expose helper
CyrusNajmabadi May 29, 2020
421d856
Merge branch 'master' into cleanup_logs
dibarbet May 29, 2020
52cdaaf
Add comment
Youssef1313 May 29, 2020
b68664f
Don't specify OpenClose, default value is false
dibarbet May 29, 2020
154e84f
Fix ConvertIfToSwitch on top-level statement (#44645)
jcouv May 29, 2020
c98f095
Update error code in ConvertIfToSwitch test
May 30, 2020
34b1501
Update ParenthesizedExpressionSyntaxExtensions.cs
Youssef1313 May 30, 2020
440c640
Merge pull request #43886 from dibarbet/cleanup_logs
dibarbet May 30, 2020
beef218
Merge pull request #44709 from jcouv/fix-build
jasonmalinowski May 30, 2020
3c1c0fc
Merge pull request #44673 from sharwell/ls-test
sharwell May 30, 2020
5b0f74b
Update ParenthesizedExpressionSyntaxExtensions.cs
Youssef1313 May 30, 2020
0ba8890
Update ParenthesizedExpressionSyntaxExtensions.cs
Youssef1313 May 30, 2020
0795643
Attempt to fix unit test
Youssef1313 May 30, 2020
c1e8715
Connection refactoring (#44512)
tmat May 30, 2020
f74d449
Merge pull request #44661 from Youssef1313/patch-2
CyrusNajmabadi May 30, 2020
3fc72c9
Merge pull request #44654 from CyrusNajmabadi/checksumPerf
May 31, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ void M()
}", new TestParameters(options: RequireArithmeticBinaryParenthesesForClarity));
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnnecessaryParentheses)]
[WorkItem(44629, "https://github.com/dotnet/roslyn/issues/44629")]
public async Task TestStackAlloc()
{
await TestMissingAsync(
@"class C
{
void M()
{
var span = $$(stackalloc byte[8]);
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsRemoveUnnecessaryParentheses)]
public async Task TestArithmeticRequiredForClarity2()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
Expand Down Expand Up @@ -2539,5 +2540,59 @@ void M(int i)
CodeActionValidationMode = CodeActionValidationMode.None,
}.RunAsync();
}

[WorkItem(44278, "https://github.com/dotnet/roslyn/issues/44278")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsConvertIfToSwitch)]
public async Task TestTopLevelStatement()
{
var source = @"
var e = new ET1();

[||]if (e == ET1.A)
{
}
else if (e == ET1.C)
{
}

enum ET1
{
A,
B,
C,
}";

var fixedSource = @"
var e = new ET1();

switch (e)
{
case ET1.A:
break;
case ET1.C:
break;
}

enum ET1
{
A,
B,
C,
}";

var test = new VerifyCS.Test
{
TestCode = source,
FixedCode = fixedSource,
LanguageVersion = LanguageVersionExtensions.CSharp9,
CodeActionValidationMode = CodeActionValidationMode.None,
};

test.ExpectedDiagnostics.Add(
// error CS8805: Program using top-level statements must be an executable.
DiagnosticResult.CompilerError("CS8805"));

await test.RunAsync();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ public static async Task<ISymbolSearchUpdateEngine> CreateEngineAsync(
if (client != null)
{
var callbackObject = new CallbackObject(logService, progressService);
var session = await client.TryCreateKeepAliveSessionAsync(WellKnownServiceHubService.RemoteSymbolSearchUpdateEngine, callbackObject, cancellationToken).ConfigureAwait(false);
if (session != null)
{
return new RemoteUpdateEngine(workspace, session);
}
var session = await client.CreateConnectionAsync(WellKnownServiceHubService.RemoteSymbolSearchUpdateEngine, callbackObject, cancellationToken).ConfigureAwait(false);
return new RemoteUpdateEngine(workspace, session);
}

// Couldn't go out of proc. Just do everything inside the current process.
Expand All @@ -47,11 +44,11 @@ private sealed partial class RemoteUpdateEngine : ISymbolSearchUpdateEngine
private readonly SemaphoreSlim _gate = new SemaphoreSlim(initialCount: 1);

private readonly Workspace _workspace;
private readonly KeepAliveSession _session;
private readonly RemoteServiceConnection _session;

public RemoteUpdateEngine(
Workspace workspace,
KeepAliveSession session)
RemoteServiceConnection session)
{
_workspace = workspace;
_session = session;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static async Task FindImplementationsAsync(
// the 'progress' parameter which will then update the UI.
var serverCallback = new FindUsagesServerCallback(solution, context);

var success = await client.TryRunRemoteAsync(
await client.RunRemoteAsync(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteFindUsagesService.FindImplementationsAsync),
solution,
Expand All @@ -62,14 +62,13 @@ public static async Task FindImplementationsAsync(
},
serverCallback,
cancellationToken).ConfigureAwait(false);

if (success)
return;
}

// Couldn't effectively search in OOP. Perform the search in-process.
await FindImplementationsInCurrentProcessAsync(
symbol, project, context).ConfigureAwait(false);
else
{
// Couldn't effectively search in OOP. Perform the search in-process.
await FindImplementationsInCurrentProcessAsync(
symbol, project, context).ConfigureAwait(false);
}
}

private static async Task FindImplementationsInCurrentProcessAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static async Task FindReferencesAsync(
// the 'progress' parameter which will then update the UI.
var serverCallback = new FindUsagesServerCallback(solution, context);

var success = await client.TryRunRemoteAsync(
await client.RunRemoteAsync(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteFindUsagesService.FindReferencesAsync),
solution,
Expand All @@ -160,14 +160,13 @@ public static async Task FindReferencesAsync(
},
serverCallback,
cancellationToken).ConfigureAwait(false);

if (success)
return;
}

// Couldn't effectively search in OOP. Perform the search in-process.
await FindReferencesInCurrentProcessAsync(
context, symbol, project, options).ConfigureAwait(false);
else
{
// Couldn't effectively search in OOP. Perform the search in-process.
await FindReferencesInCurrentProcessAsync(
context, symbol, project, options).ConfigureAwait(false);
}
}

private static Task FindReferencesInCurrentProcessAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Roslyn.Test.Utilities.Remote
{
internal sealed class InProcRemoteHostClient : RemoteHostClient, IRemoteHostServiceCallback
{
private readonly HostWorkspaceServices _services;
private readonly InProcRemoteServices _inprocServices;
private readonly RemoteEndPoint _endPoint;

Expand All @@ -34,7 +35,7 @@ public static async Task<RemoteHostClient> CreateAsync(HostWorkspaceServices ser

var remoteHostStream = await inprocServices.RequestServiceAsync(WellKnownServiceHubService.RemoteHost).ConfigureAwait(false);

var clientId = CreateClientId(Process.GetCurrentProcess().Id.ToString());
var clientId = $"InProc ({Guid.NewGuid()})";
var instance = new InProcRemoteHostClient(clientId, services, inprocServices, remoteHostStream);

// make sure connection is done right
Expand All @@ -58,9 +59,9 @@ private InProcRemoteHostClient(
HostWorkspaceServices services,
InProcRemoteServices inprocServices,
Stream stream)
: base(services)
{
ClientId = clientId;
_services = services;

_inprocServices = inprocServices;

Expand All @@ -76,14 +77,15 @@ public Task GetAssetsAsync(int scopeId, Checksum[] checksums, string pipeName, C
=> RemoteEndPoint.WriteDataToNamedPipeAsync(
pipeName,
(scopeId, checksums),
(writer, data, cancellationToken) => RemoteHostAssetSerialization.WriteDataAsync(writer, RemotableDataService, data.scopeId, data.checksums, cancellationToken),
(writer, data, cancellationToken) => RemoteHostAssetSerialization.WriteDataAsync(
writer, _services.GetRequiredService<IRemotableDataService>(), data.scopeId, data.checksums, cancellationToken),
cancellationToken);

/// <summary>
/// Remote API.
/// </summary>
public Task<bool> IsExperimentEnabledAsync(string experimentName, CancellationToken cancellationToken)
=> Task.FromResult(Services.GetRequiredService<IExperimentationService>().IsExperimentEnabled(experimentName));
=> Task.FromResult(_services.GetRequiredService<IExperimentationService>().IsExperimentEnabled(experimentName));

public AssetStorage AssetStorage => _inprocServices.AssetStorage;

Expand All @@ -95,14 +97,13 @@ public Task<Stream> RequestServiceAsync(RemoteServiceName serviceName)

public override string ClientId { get; }

protected override async Task<Connection?> TryCreateConnectionAsync(
RemoteServiceName serviceName, object? callbackTarget, CancellationToken cancellationToken)
public override async Task<RemoteServiceConnection> CreateConnectionAsync(RemoteServiceName serviceName, object? callbackTarget, CancellationToken cancellationToken)
{
// get stream from service hub to communicate service specific information
// this is what consumer actually use to communicate information
var serviceStream = await _inprocServices.RequestServiceAsync(serviceName).ConfigureAwait(false);

return new JsonRpcConnection(Services, _inprocServices.Logger, callbackTarget, serviceStream);
return new JsonRpcConnection(_services, _inprocServices.Logger, callbackTarget, serviceStream, poolReclamation: null);
}

public override void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<Compile Include="..\..\VisualStudio\Core\Def\Implementation\Remote\JsonRpcConnection.cs">
<Link>Remote\JsonRpcConnection.cs</Link>
</Compile>
<Compile Include="..\..\VisualStudio\Core\Def\Implementation\Remote\IPooledConnectionReclamation.cs">
<Link>Remote\IPooledConnectionReclamation.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<ImmutableArray<AddImportFixData>> GetFixesAsync(
{
var callbackTarget = new RemoteSymbolSearchService(symbolSearchService);

var result = await client.TryRunRemoteAsync<IList<AddImportFixData>>(
var result = await client.RunRemoteAsync<IList<AddImportFixData>>(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteAddImportFeatureService.GetFixesAsync),
document.Project.Solution,
Expand All @@ -76,10 +76,7 @@ public async Task<ImmutableArray<AddImportFixData>> GetFixesAsync(
callbackTarget,
cancellationToken).ConfigureAwait(false);

if (result.HasValue)
{
return result.Value.ToImmutableArray();
}
return result.ToImmutableArray();
}

return await GetFixesInCurrentProcessAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,15 @@ public static async Task<ImmutableArray<SerializableImportCompletionItem>> GetUn
var client = await RemoteHostClient.TryGetClientAsync(project, cancellationToken).ConfigureAwait(false);
if (client != null)
{
var result = await client.TryRunRemoteAsync<(IList<SerializableImportCompletionItem> items, StatisticCounter counter)>(
var result = await client.RunRemoteAsync<(IList<SerializableImportCompletionItem> items, StatisticCounter counter)>(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteExtensionMethodImportCompletionService.GetUnimportedExtensionMethodsAsync),
project.Solution,
new object[] { document.Id, position, SymbolKey.CreateString(receiverTypeSymbol), namespaceInScope.ToArray(), forceIndexCreation },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);

if (result.HasValue)
{
return (result.Value.items.ToImmutableArray(), result.Value.counter);
}
return (result.items.ToImmutableArray(), result.counter);
}

return await GetUnimportedExtensionMethodsInCurrentProcessAsync(document, position, receiverTypeSymbol, namespaceInScope, forceIndexCreation, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private async Task<Document> UpdateDocumentAsync(

var nodesToRemove = sections.Skip(1).Select(s => s.SyntaxToRemove).Where(s => s.Parent == ifStatement.Parent);
root = root.RemoveNodes(nodesToRemove, SyntaxRemoveOptions.KeepNoTrivia);
root = root.ReplaceNode(root.FindNode(ifSpan), @switch);
root = root.ReplaceNode(root.FindNode(ifSpan, getInnermostNodeForTie: true), @switch);
return document.WithSyntaxRoot(root);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public async Task<Solution> ConvertToStructAsync(
var client = await RemoteHostClient.TryGetClientAsync(solution.Workspace, cancellationToken).ConfigureAwait(false);
if (client != null)
{
var resultOpt = await client.TryRunRemoteAsync<SerializableConvertTupleToStructResult>(
var result = await client.RunRemoteAsync<SerializableConvertTupleToStructResult>(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteConvertTupleToStructCodeRefactoringProvider.ConvertToStructAsync),
solution,
Expand All @@ -180,14 +180,11 @@ public async Task<Solution> ConvertToStructAsync(
callbackTarget: null,
cancellationToken).ConfigureAwait(false);

if (resultOpt.HasValue)
{
var result = resultOpt.Value;
var resultSolution = await RemoteUtilities.UpdateSolutionAsync(
solution, result.DocumentTextChanges, cancellationToken).ConfigureAwait(false);
return await AddRenameTokenAsync(
resultSolution, result.RenamedToken, cancellationToken).ConfigureAwait(false);
}
var resultSolution = await RemoteUtilities.UpdateSolutionAsync(
solution, result.DocumentTextChanges, cancellationToken).ConfigureAwait(false);

return await AddRenameTokenAsync(
resultSolution, result.RenamedToken, cancellationToken).ConfigureAwait(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private async Task FireAndForgetReportAnalyzerPerformanceAsync(Project project,

try
{
_ = await client.TryRunRemoteAsync(
await client.RunRemoteAsync(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteDiagnosticAnalyzerService.ReportAnalyzerPerformance),
solution: null,
Expand Down Expand Up @@ -128,16 +128,14 @@ private static async Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, Diagno
forcedAnalysis, analyzerDriver.AnalysisOptions.ReportSuppressedDiagnostics, analyzerDriver.AnalysisOptions.LogAnalyzerExecutionTime,
project.Id, analyzerMap.Keys.ToArray());

var result = await client.TryRunRemoteAsync(
return await client.RunRemoteAsync(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteDiagnosticAnalyzerService.CalculateDiagnosticsAsync),
solution,
new object[] { argument },
callbackTarget: null,
(s, c) => ReadCompilerAnalysisResultAsync(s, analyzerMap, project, c),
cancellationToken).ConfigureAwait(false);

return result.HasValue ? result.Value : DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisResult>.Empty;
}

private static async Task<DiagnosticAnalysisResultMap<DiagnosticAnalyzer, DiagnosticAnalysisResult>> ReadCompilerAnalysisResultAsync(Stream stream, Dictionary<string, DiagnosticAnalyzer> analyzerMap, Project project, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ private async Task ReportAnalyzerPerformanceAsync(Document document, Compilation
return;
}

_ = await client.TryRunRemoteAsync(
await client.RunRemoteAsync(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteDiagnosticAnalyzerService.ReportAnalyzerPerformance),
solution: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<ImmutableArray<DocumentHighlights>> GetDocumentHighlightsAsync
var client = await RemoteHostClient.TryGetClientAsync(document.Project, cancellationToken).ConfigureAwait(false);
if (client != null)
{
var result = await client.TryRunRemoteAsync<IList<SerializableDocumentHighlights>>(
var result = await client.RunRemoteAsync<IList<SerializableDocumentHighlights>>(
WellKnownServiceHubService.CodeAnalysis,
nameof(IRemoteDocumentHighlights.GetDocumentHighlightsAsync),
solution,
Expand All @@ -43,10 +43,7 @@ public async Task<ImmutableArray<DocumentHighlights>> GetDocumentHighlightsAsync
callbackTarget: null,
cancellationToken).ConfigureAwait(false);

if (result.HasValue)
{
return result.Value.SelectAsArray(h => h.Rehydrate(solution));
}
return result.SelectAsArray(h => h.Rehydrate(solution));
}

return await GetDocumentHighlightsInCurrentProcessAsync(
Expand Down
Loading