Skip to content

Commit

Permalink
Merge branch 'master' into lsp-code-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
filipw authored May 21, 2020
2 parents 2ca23a7 + ffafffb commit 66c3cb1
Show file tree
Hide file tree
Showing 33 changed files with 360 additions and 78 deletions.
4 changes: 2 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In order to build OmniSharp, the [.NET 4.6 targeting pack](http://go.microsoft.c

## macOS

**Mono 5.2.0** or greater is required. You can install this using the latest [.pkg](http://www.mono-project.com/download/#download-mac) or install it view [Homebrew](https://brew.sh/):
**Mono 6.4.0** or greater is required. You can install this using the latest [.pkg](http://www.mono-project.com/download/#download-mac) or install it view [Homebrew](https://brew.sh/):

```
brew update
Expand All @@ -18,7 +18,7 @@ brew install caskroom/cask/mono-mdk

Because OmniSharp uses the .NET Core SDK as part of the build, not all Linux distros are supported. A good rule of thumb is to check the list [here](https://docs.microsoft.com/dotnet/core/install/dependencies?pivots=os-linux) to see if your particular distro is supported.

**Mono 5.2.0** or greater is required. Each distro or derivative has its own set of instructions for installing Mono which you can find [here](http://www.mono-project.com/download/#download-lin). Be sure to install `msbuild` as well, which may be a separate package.
**Mono 6.4.0** or greater is required. Each distro or derivative has its own set of instructions for installing Mono which you can find [here](http://www.mono-project.com/download/#download-lin). Be sure to install `msbuild` as well, which may be a separate package.

# Usage

Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Changelog
All changes to the project will be documented in this file.

## [1.35.2] - not yet released
## [1.35.3] - not yet released
* Added LSP handler for `textDocument/codeAction` request. (PR: [#1795](https://github.com/OmniSharp/omnisharp-roslyn/pull/1795))
* Updated LSP libraries to 0.14.2 which fixes problems with document synchronisation. (PR: [#1791](https://github.com/OmniSharp/omnisharp-roslyn/pull/1791))

## [1.35.2] - 2020-05-20
* Added support for `WarningsAsErrors` in csproj files (PR: [#1779](https://github.com/OmniSharp/omnisharp-roslyn/pull/1779))
* Added support for `WarningsNotAsErrors` in csproj files ([#1681](https://github.com/OmniSharp/omnisharp-roslyn/issues/1681), PR: [#1784](https://github.com/OmniSharp/omnisharp-roslyn/pull/1784))
* Improved MSBuild scoring system ([#1783](https://github.com/OmniSharp/omnisharp-roslyn/issues/1783), PR: [#1797](https://github.com/OmniSharp/omnisharp-roslyn/pull/1797))
* Updated OmniSharp.Extensions.LanguageServer to `0.14.2` to fix synchronisation (PR: [#1791](https://github.com/OmniSharp/omnisharp-roslyn/pull/1791))
* Add test discovery and NoBuild option to test requests (PR: [#1719](https://github.com/OmniSharp/omnisharp-roslyn/pull/1719))
* Update to Roslyn `3.7.0-2.20269.10` (PR: [#1804](https://github.com/OmniSharp/omnisharp-roslyn/pull/1804))

## [1.35.1] - 2020-05-04
* Fixed not supported exception when trying to decompile a BCL assembly on Mono. For now we do not try to resolve implementation assembly from a ref assembly (PR: [#1767](https://github.com/OmniSharp/omnisharp-roslyn/pull/1767))
Expand Down
2 changes: 1 addition & 1 deletion build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<MSBuildPackageVersion>16.5.0</MSBuildPackageVersion>
<NuGetPackageVersion>5.2.0</NuGetPackageVersion>
<RoslynPackageVersion>3.6.0-4.20228.5</RoslynPackageVersion>
<RoslynPackageVersion>3.7.0-2.20269.10</RoslynPackageVersion>
<XunitPackageVersion>2.4.0</XunitPackageVersion>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/OmniSharp.Abstractions/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal static class Configuration
{
public static bool ZeroBasedIndices = false;

public const string RoslynVersion = "3.6.0.0";
public const string RoslynVersion = "3.7.0.0";
public const string RoslynPublicKeyToken = "31bf3856ad364e35";

public readonly static string RoslynFeatures = GetRoslynAssemblyFullName("Microsoft.CodeAnalysis.Features");
Expand Down
1 change: 1 addition & 0 deletions src/OmniSharp.Abstractions/OmniSharpEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public static class V2
public const string DebugTestsInContextGetStartInfo = "/v2/debugtestsincontext/getstartinfo";
public const string DebugTestStop = "/v2/debugtest/stop";
public const string DebugTestsInClassGetStartInfo = "/v2/debugtestsinclass/getstartinfo";
public const string DiscoverTests = "/v2/discovertests";
public const string RunTestsInContext = "/v2/runtestsincontext";

public const string BlockStructure = "/v2/blockstructure";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
using OmniSharp.Models;
using OmniSharp.Models;

namespace OmniSharp.DotNetTest.Models
{
public class BaseTestClassRequest : Request
public class BaseTestRequest : Request
{
public string[] MethodNames { get; set; }
public string RunSettings { get; set; }
public string TestFrameworkName { get; set; }

/// <summary>
/// e.g. .NETCoreApp, Version=2.0
/// </summary>
public string TargetFrameworkVersion { get; set; }
public bool NoBuild { get; set; } = false;
}

public class SingleTestRequest : BaseTestRequest
{
public string MethodName { get; set; }
}

public class MultiTestRequest : BaseTestRequest
{
public string[] MethodNames { get; set; }
}
}
2 changes: 2 additions & 0 deletions src/OmniSharp.DotNetTest/Models/BaseTestsInContextRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ public abstract class BaseTestsInContextRequest : Request
/// e.g. .NETCoreApp, Version=2.0
/// </summary>
public string? TargetFrameworkVersion { get; set; }

public bool NoBuild { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace OmniSharp.DotNetTest.Models
{
[OmniSharpEndpoint(OmniSharpEndpoints.V2.DebugTestsInClassGetStartInfo, typeof(DebugTestClassGetStartInfoRequest), typeof(DebugTestGetStartInfoResponse))]
public class DebugTestClassGetStartInfoRequest : BaseTestClassRequest
public class DebugTestClassGetStartInfoRequest : MultiTestRequest
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
namespace OmniSharp.DotNetTest.Models
{
[OmniSharpEndpoint(OmniSharpEndpoints.V2.DebugTestGetStartInfo, typeof(DebugTestGetStartInfoRequest), typeof(DebugTestGetStartInfoResponse))]
public class DebugTestGetStartInfoRequest : Request
public class DebugTestGetStartInfoRequest : SingleTestRequest
{
public string MethodName { get; set; }
public string RunSettings { get; set; }
public string TestFrameworkName { get; set; }
/// <summary>
/// e.g. .NETCoreApp, Version=2.0
/// </summary>
public string TargetFrameworkVersion { get; set; }
}
}
10 changes: 10 additions & 0 deletions src/OmniSharp.DotNetTest/Models/DiscoverTestsRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using OmniSharp.Mef;
using OmniSharp.Models;

namespace OmniSharp.DotNetTest.Models
{
[OmniSharpEndpoint(OmniSharpEndpoints.V2.DiscoverTests, typeof(DiscoverTestsRequest), typeof(DiscoverTestsResponse))]
public class DiscoverTestsRequest : BaseTestRequest
{
}
}
20 changes: 20 additions & 0 deletions src/OmniSharp.DotNetTest/Models/DiscoverTestsResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace OmniSharp.DotNetTest.Models
{
public class Test
{
public string FullyQualifiedName { get; set; }

public string DisplayName { get; set; }

public string Source { get; set; }

public string CodeFilePath { get; set; }

public int LineNumber { get; set; }
}

public class DiscoverTestsResponse
{
public Test[] Tests { get; set; }
}
}
9 changes: 1 addition & 8 deletions src/OmniSharp.DotNetTest/Models/GetTestStartInfoRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
namespace OmniSharp.DotNetTest.Models
{
[OmniSharpEndpoint(OmniSharpEndpoints.V2.GetTestStartInfo, typeof(GetTestStartInfoRequest), typeof(GetTestStartInfoResponse))]
public class GetTestStartInfoRequest : Request
public class GetTestStartInfoRequest : SingleTestRequest
{
public string MethodName { get; set; }
public string RunSettings { get; set; }
public string TestFrameworkName { get; set; }
/// <summary>
/// e.g. .NETCoreApp, Version=2.0
/// </summary>
public string TargetFrameworkVersion { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/OmniSharp.DotNetTest/Models/RunTestInClassRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace OmniSharp.DotNetTest.Models
{
[OmniSharpEndpoint(OmniSharpEndpoints.V2.RunAllTestsInClass, typeof(RunTestsInClassRequest), typeof(RunTestResponse))]
public class RunTestsInClassRequest : BaseTestClassRequest
public class RunTestsInClassRequest : MultiTestRequest
{
}
}
9 changes: 1 addition & 8 deletions src/OmniSharp.DotNetTest/Models/RunTestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
namespace OmniSharp.DotNetTest.Models
{
[OmniSharpEndpoint(OmniSharpEndpoints.V2.RunTest, typeof(RunTestRequest), typeof(RunTestResponse))]
public class RunTestRequest : Request
public class RunTestRequest : SingleTestRequest
{
public string MethodName { get; set; }
public string RunSettings { get; set; }
public string TestFrameworkName { get; set; }
/// <summary>
/// e.g. .NETCoreApp, Version=2.0
/// </summary>
public string TargetFrameworkVersion { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/OmniSharp.DotNetTest/Services/BaseTestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ protected BaseTestService(OmniSharpWorkspace workspace, IDotNetCliService dotNet
LoggerFactory = loggerFactory;
}

protected TestManager CreateTestManager(string fileName)
protected TestManager CreateTestManager(string fileName, bool noBuild)
{
var document = Workspace.GetDocument(fileName);

return TestManager.Start(document.Project, DotNetCli, EventEmitter, LoggerFactory);
return TestManager.Start(document.Project, DotNetCli, EventEmitter, LoggerFactory, noBuild);
}
}
}
9 changes: 6 additions & 3 deletions src/OmniSharp.DotNetTest/Services/BaseTestService`2.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Logging;
using OmniSharp.DotNetTest.Models;
using OmniSharp.Eventing;
using OmniSharp.Mef;
using OmniSharp.Models;
Expand All @@ -10,7 +11,7 @@ namespace OmniSharp.DotNetTest.Services
{
[OmniSharpHandler(OmniSharpEndpoints.V2.GetTestStartInfo, LanguageNames.CSharp)]
internal abstract class BaseTestService<TRequest, TResponse> : BaseTestService, IRequestHandler<TRequest, TResponse>
where TRequest: Request
where TRequest: BaseTestRequest
{
protected BaseTestService(OmniSharpWorkspace workspace, IDotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
: base(workspace, dotNetCli, eventEmitter, loggerFactory)
Expand All @@ -21,8 +22,10 @@ protected BaseTestService(OmniSharpWorkspace workspace, IDotNetCliService dotNet

public async Task<TResponse> Handle(TRequest request)
{
using var testManager = CreateTestManager(request.FileName);
return await HandleRequest(request, testManager);
using (var testManager = CreateTestManager(request.FileName, request.NoBuild))
{
return await HandleRequest(request, testManager);
}
}
}
}
2 changes: 1 addition & 1 deletion src/OmniSharp.DotNetTest/Services/DebugTestClassService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public DebugTestClassService(DebugSessionManager debugSessionManager, OmniSharpW

public async Task<DebugTestGetStartInfoResponse> Handle(DebugTestClassGetStartInfoRequest request)
{
var testManager = CreateTestManager(request.FileName);
var testManager = CreateTestManager(request.FileName, request.NoBuild);
_debugSessionManager.StartSession(testManager);

return await _debugSessionManager.DebugGetStartInfoAsync(request.MethodNames, request.RunSettings, request.TestFrameworkName, request.TargetFrameworkVersion, CancellationToken.None);
Expand Down
2 changes: 1 addition & 1 deletion src/OmniSharp.DotNetTest/Services/DebugTestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DebugTestService(DebugSessionManager debugSessionManager, OmniSharpWorksp

public Task<DebugTestGetStartInfoResponse> Handle(DebugTestGetStartInfoRequest request)
{
var testManager = CreateTestManager(request.FileName);
var testManager = CreateTestManager(request.FileName, request.NoBuild);
if (testManager.IsConnected)
{
//only if the test manager connected successfully, shall we proceed with the request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task<DebugTestGetStartInfoResponse> Handle(DebugTestsInContextGetSt
};
}

testManager.Connect();
testManager.Connect(request.NoBuild);

if (testManager.IsConnected)
{
Expand Down
33 changes: 33 additions & 0 deletions src/OmniSharp.DotNetTest/Services/DiscoverTestsService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Logging;
using OmniSharp.DotNetTest.Models;
using OmniSharp.Eventing;
using OmniSharp.Mef;
using OmniSharp.Services;

namespace OmniSharp.DotNetTest.Services
{
[OmniSharpHandler(OmniSharpEndpoints.V2.DiscoverTests, LanguageNames.CSharp)]
internal class DiscoverTestsService : BaseTestService<DiscoverTestsRequest, DiscoverTestsResponse>
{
[ImportingConstructor]
public DiscoverTestsService(OmniSharpWorkspace workspace, IDotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
: base(workspace, dotNetCli, eventEmitter, loggerFactory)
{
}

protected override async Task<DiscoverTestsResponse> HandleRequest(DiscoverTestsRequest request, TestManager testManager)
{
if (testManager.IsConnected)
{
return await testManager.DiscoverTestsAsync(request.RunSettings, request.TestFrameworkName, request.TargetFrameworkVersion, default(CancellationToken));
}

throw new InvalidOperationException("The debugger could not be started");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<RunTestResponse> Handle(RunTestsInContextRequest request)
};
}

testManager.Connect();
testManager.Connect(request.NoBuild);

if (testManager.IsConnected)
{
Expand Down
12 changes: 7 additions & 5 deletions src/OmniSharp.DotNetTest/TestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ protected TestManager(Project project, string workingDirectory, IDotNetCliServic
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public static TestManager Start(Project project, IDotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory)
public static TestManager Start(Project project, IDotNetCliService dotNetCli, IEventEmitter eventEmitter, ILoggerFactory loggerFactory, bool noBuild)
{
var manager = Create(project, dotNetCli, eventEmitter, loggerFactory);
manager.Connect();
manager.Connect(noBuild);
return manager;
}

Expand Down Expand Up @@ -82,6 +82,8 @@ public static TestManager Create(Project project, IDotNetCliService dotNetCli, I

public abstract Task<RunTestResponse> RunTestAsync(string[] methodNames, string runSettings, string testFrameworkName, string targetFrameworkVersion, CancellationToken cancellationToken);

public abstract Task<DiscoverTestsResponse> DiscoverTestsAsync(string runSettings, string testFrameworkName, string targetFrameworkVersion, CancellationToken cancellationToken);

public abstract Task<GetTestStartInfoResponse> GetTestStartInfoAsync(string methodName, string runSettings, string testFrameworkName, string targetFrameworkVersion, CancellationToken cancellationToken);

public abstract Task<DebugTestGetStartInfoResponse> DebugGetStartInfoAsync(string methodName, string runSettings, string testFrameworkName, string targetFrameworkVersion, CancellationToken cancellationToken);
Expand All @@ -90,20 +92,20 @@ public static TestManager Create(Project project, IDotNetCliService dotNetCli, I

public abstract Task DebugLaunchAsync(CancellationToken cancellationToken);

protected virtual bool PrepareToConnect()
protected virtual bool PrepareToConnect(bool noBuild)
{
// Descendents can override.
return true;
}

internal void Connect()
internal void Connect(bool noBuild)
{
if (_isConnected)
{
throw new InvalidOperationException("Already connected.");
}

if (!PrepareToConnect())
if (!PrepareToConnect(noBuild))
{
return;
}
Expand Down
Loading

0 comments on commit 66c3cb1

Please sign in to comment.