Skip to content

Commit

Permalink
Merge pull request #1194 from DustinCampbell/project-systems-enabled-…
Browse files Browse the repository at this point in the history
…by-default

Disable DotNetProjectSystem by default
  • Loading branch information
filipw authored Jun 5, 2018
2 parents 1616142 + ea3d151 commit 5129ba5
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 52 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ All changes to the project will be documented in this file.

## [1.32.0] - _Not Yet Released_
* Added new `/codestructure` endpoint which serves a replacement for the `/currentfilemembersastree` endpoint. The new endpoint has a cleaner design, properly supports all C# types and members, and supports more information, such as accessibility, static vs. instance, etc. (PR: [#1211](https://github.com/OmniSharp/omnisharp-roslyn/pull/1211))
* The legacy project.json support is now disabled by default, allowing OmniSharp to start up a bit faster for common scenarios. If you wish to enable project.json support, add the following setting to your `omnisharp.json` file. (PR: [#1194](https://github.com/OmniSharp/omnisharp-roslyn/pull/1194))

```JSON
{
"dotnet": {
"enabled": false
}
}
```

## [1.31.1] - 2018-05-28
* Fixed bug where diagnostics from loaded `.cake` files was shown in the current file. (PR: [#1201](https://github.com/OmniSharp/omnisharp-roslyn/pull/1201))
Expand Down
1 change: 1 addition & 0 deletions src/OmniSharp.Abstractions/Services/IProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IProjectSystem
string Key { get; }
string Language { get; }
IEnumerable<string> Extensions { get; }
bool EnabledByDefault { get; }

/// <summary>
/// Initialize the project system.
Expand Down
7 changes: 4 additions & 3 deletions src/OmniSharp.Cake/CakeProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ public class CakeProjectSystem : IProjectSystem

private CakeOptions _options;

public string Key => "Cake";
public string Language => Constants.LanguageNames.Cake;
public IEnumerable<string> Extensions => new[] { ".cake" };
public string Key { get; } = "Cake";
public string Language { get; } = Constants.LanguageNames.Cake;
public IEnumerable<string> Extensions { get; } = new[] { ".cake" };
public bool EnabledByDefault { get; } = true;

[ImportingConstructor]
public CakeProjectSystem(
Expand Down
7 changes: 3 additions & 4 deletions src/OmniSharp.DotNet/DotNetProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ public DotNetProjectSystem(
_projectStates = new ProjectStatesCache(loggerFactory, _eventEmitter);
}

public string Key { get; } = "DotNet";
public string Language { get; } = LanguageNames.CSharp;
public IEnumerable<string> Extensions { get; } = new string[] { ".cs" };

public string Key => "DotNet";

public string Language => LanguageNames.CSharp;
public bool EnabledByDefault { get; } = false;

Task<object> IProjectSystem.GetWorkspaceModelAsync(WorkspaceInformationRequest request)
{
Expand Down
2 changes: 1 addition & 1 deletion src/OmniSharp.Host/WorkspaceInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void Initialize(
try
{
var projectConfiguration = configuration.GetSection(projectSystem.Key);
var enabledProjectFlag = projectConfiguration.GetValue<bool>("enabled", defaultValue: true);
var enabledProjectFlag = projectConfiguration.GetValue("enabled", defaultValue: projectSystem.EnabledByDefault);
if (enabledProjectFlag)
{
projectSystem.Initalize(projectConfiguration);
Expand Down
1 change: 1 addition & 0 deletions src/OmniSharp.MSBuild/ProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class ProjectSystem : IProjectSystem
public string Key { get; } = "MsBuild";
public string Language { get; } = LanguageNames.CSharp;
public IEnumerable<string> Extensions { get; } = new[] { ".cs" };
public bool EnabledByDefault { get; } = true;

[ImportingConstructor]
public ProjectSystem(
Expand Down
4 changes: 1 addition & 3 deletions src/OmniSharp.Plugins/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using OmniSharp.Eventing;
using OmniSharp.Models.WorkspaceInformation;
using OmniSharp.Services;
using OmniSharp.Stdio.Protocol;
using OmniSharp.Stdio.Services;

namespace OmniSharp.Plugins
{
Expand All @@ -37,6 +34,7 @@ public Plugin(ILogger<Plugin> logger, PluginConfig config)
public string Key { get; }
public string Language { get; }
public IEnumerable<string> Extensions { get; }
public bool EnabledByDefault { get; } = true;

public Task<TResponse> Handle<TRequest, TResponse>(string endpoint, TRequest request)
{
Expand Down
5 changes: 3 additions & 2 deletions src/OmniSharp.Script/ScriptProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ public ScriptProjectSystem(OmniSharpWorkspace workspace, IOmniSharpEnvironment e
});
}

public string Key => "Script";
public string Language => LanguageNames.CSharp;
public string Key { get; } = "Script";
public string Language { get; } = LanguageNames.CSharp;
public IEnumerable<string> Extensions { get; } = new[] { CsxExtension };
public bool EnabledByDefault { get; } = true;

public void Initalize(IConfiguration configuration)
{
Expand Down
16 changes: 11 additions & 5 deletions tests/OmniSharp.DotNet.Tests/WorkspaceInformationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OmniSharp.DotNet.Models;
using OmniSharp.Models.WorkspaceInformation;
Expand All @@ -10,6 +11,11 @@ namespace OmniSharp.DotNet.Tests
{
public class WorkspaceInformationTests : AbstractTestFixture
{
private static readonly Dictionary<string, string> s_configurationData = new Dictionary<string, string>
{
["DotNet:Enabled"] = "true"
};

public WorkspaceInformationTests(ITestOutputHelper output)
: base(output)
{
Expand All @@ -19,7 +25,7 @@ public WorkspaceInformationTests(ITestOutputHelper output)
public async Task TestSimpleProject()
{
using (var testProject = await TestAssets.Instance.GetTestProjectAsync("LegacyProjectJsonApp", legacyProject: true))
using (var host = CreateOmniSharpHost(testProject.Directory))
using (var host = CreateOmniSharpHost(testProject.Directory, s_configurationData))
{
var workspaceInfo = await GetWorkspaceInfoAsync(host);

Expand All @@ -43,7 +49,7 @@ public async Task TestSimpleProject()
public async Task TestMSTestProject()
{
using (var testProject = await TestAssets.Instance.GetTestProjectAsync("LegacyMSTestProject", legacyProject: true))
using (var host = CreateOmniSharpHost(testProject.Directory))
using (var host = CreateOmniSharpHost(testProject.Directory, s_configurationData))
{
var workspaceInfo = await GetWorkspaceInfoAsync(host);

Expand All @@ -66,7 +72,7 @@ public async Task TestMSTestProject()
public async Task TestNUnitProject()
{
using (var testProject = await TestAssets.Instance.GetTestProjectAsync("LegacyNUnitTestProject", legacyProject: true))
using (var host = CreateOmniSharpHost(testProject.Directory))
using (var host = CreateOmniSharpHost(testProject.Directory, s_configurationData))
{
var workspaceInfo = await GetWorkspaceInfoAsync(host);

Expand All @@ -89,7 +95,7 @@ public async Task TestNUnitProject()
public async Task TestXunitProject()
{
using (var testProject = await TestAssets.Instance.GetTestProjectAsync("LegacyXunitTestProject", legacyProject: true))
using (var host = CreateOmniSharpHost(testProject.Directory))
using (var host = CreateOmniSharpHost(testProject.Directory, s_configurationData))
{
var workspaceInfo = await GetWorkspaceInfoAsync(host);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ namespace OmniSharp.DotNetTest.Tests
{
public abstract class AbstractGetTestStartInfoFacts : AbstractTestFixture
{
protected const string LegacyXunitTestProject = "LegacyXunitTestProject";
protected const string LegacyNunitTestProject = "LegacyNUnitTestProject";
protected const string LegacyMSTestProject = "LegacyMSTestProject";
protected const string XunitTestProject = "XunitTestProject";
protected const string NunitTestProject = "NUnitTestProject";
protected const string MSTestProject = "MSTestProject";

protected AbstractGetTestStartInfoFacts(ITestOutputHelper output)
: base(output)
{
Expand All @@ -28,14 +21,12 @@ internal GetTestStartInfoService GetRequestHandler(OmniSharpTestHost host)
return host.GetRequestHandler<GetTestStartInfoService>(OmniSharpEndpoints.V2.GetTestStartInfo);
}

public abstract DotNetCliVersion DotNetCliVersion { get; }

protected async Task GetDotNetTestStartInfoAsync(string projectName, string methodName, string testFramework)
{
var isLegacy = DotNetCliVersion == DotNetCliVersion.Legacy;

using (var testProject = await TestAssets.Instance.GetTestProjectAsync(projectName, legacyProject: isLegacy))
using (var host = CreateOmniSharpHost(testProject.Directory, dotNetCliVersion: DotNetCliVersion))
using (var host = CreateOmniSharpHost(testProject.Directory, ConfigurationData, DotNetCliVersion))
{
var service = GetRequestHandler(host);

Expand Down
11 changes: 1 addition & 10 deletions tests/OmniSharp.DotNetTest.Tests/AbstractRunTestFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ namespace OmniSharp.DotNetTest.Tests
{
public abstract class AbstractRunTestFacts : AbstractTestFixture
{
protected const string LegacyXunitTestProject = "LegacyXunitTestProject";
protected const string LegacyNunitTestProject = "LegacyNUnitTestProject";
protected const string LegacyMSTestProject = "LegacyMSTestProject";
protected const string XunitTestProject = "XunitTestProject";
protected const string NUnitTestProject = "NUnitTestProject";
protected const string MSTestProject = "MSTestProject";

public AbstractRunTestFacts(ITestOutputHelper testOutput)
: base(testOutput)
{
Expand All @@ -27,14 +20,12 @@ internal RunTestService GetRequestHandler(OmniSharpTestHost host)
return host.GetRequestHandler<RunTestService>(OmniSharpEndpoints.V2.RunTest);
}

public abstract DotNetCliVersion DotNetCliVersion { get; }

protected async Task<RunTestResponse> RunDotNetTestAsync(string projectName, string methodName, string testFramework, bool shouldPass, bool expectResults = true)
{
var isLegacy = DotNetCliVersion == DotNetCliVersion.Legacy;

using (var testProject = await TestAssets.Instance.GetTestProjectAsync(projectName, legacyProject: isLegacy))
using (var host = CreateOmniSharpHost(testProject.Directory, dotNetCliVersion: DotNetCliVersion))
using (var host = CreateOmniSharpHost(testProject.Directory, ConfigurationData, DotNetCliVersion))
{
var service = GetRequestHandler(host);

Expand Down
28 changes: 28 additions & 0 deletions tests/OmniSharp.DotNetTest.Tests/AbstractTestFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using TestUtility;
using Xunit.Abstractions;

namespace OmniSharp.DotNetTest.Tests
{
public abstract class AbstractTestFixture : TestUtility.AbstractTestFixture
{
protected static readonly Dictionary<string, string> ConfigurationData = new Dictionary<string, string>
{
["DotNet:Enabled"] = "true"
};

protected const string LegacyXunitTestProject = nameof(LegacyXunitTestProject);
protected const string LegacyNUnitTestProject = nameof(LegacyNUnitTestProject);
protected const string LegacyMSTestProject = nameof(LegacyMSTestProject);
protected const string XunitTestProject = nameof(XunitTestProject);
protected const string NUnitTestProject = nameof(NUnitTestProject);
protected const string MSTestProject = nameof(MSTestProject);

protected AbstractTestFixture(ITestOutputHelper output)
: base(output)
{
}

public abstract DotNetCliVersion DotNetCliVersion { get; }
}
}
2 changes: 1 addition & 1 deletion tests/OmniSharp.DotNetTest.Tests/GetTestStartInfoFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ await GetDotNetTestStartInfoAsync(
public async Task RunNunitTest()
{
await GetDotNetTestStartInfoAsync(
NunitTestProject,
NUnitTestProject,
methodName: "Main.Test.MainTest.Test",
testFramework: "nunit");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ await GetDotNetTestStartInfoAsync(
public async Task RunNunitTest()
{
await GetDotNetTestStartInfoAsync(
LegacyNunitTestProject,
LegacyNUnitTestProject,
methodName: "Main.Test.MainTest.Test",
testFramework: "nunit");
}
Expand Down
8 changes: 4 additions & 4 deletions tests/OmniSharp.DotNetTest.Tests/LegacyRunTestFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ await RunDotNetTestAsync(
public async Task RunNunitTest()
{
await RunDotNetTestAsync(
LegacyNunitTestProject,
LegacyNUnitTestProject,
methodName: "Main.Test.MainTest.Test",
testFramework: "nunit",
shouldPass: true);
Expand All @@ -61,7 +61,7 @@ await RunDotNetTestAsync(
public async Task RunNunitDataDriveTest1()
{
await RunDotNetTestAsync(
LegacyNunitTestProject,
LegacyNUnitTestProject,
methodName: "Main.Test.MainTest.DataDrivenTest1",
testFramework: "nunit",
shouldPass: false);
Expand All @@ -71,7 +71,7 @@ await RunDotNetTestAsync(
public async Task RunNunitDataDriveTest2()
{
await RunDotNetTestAsync(
LegacyNunitTestProject,
LegacyNUnitTestProject,
methodName: "Main.Test.MainTest.DataDrivenTest2",
testFramework: "nunit",
shouldPass: true);
Expand All @@ -81,7 +81,7 @@ await RunDotNetTestAsync(
public async Task RunNunitSourceDataDrivenTest()
{
await RunDotNetTestAsync(
LegacyNunitTestProject,
LegacyNUnitTestProject,
methodName: "Main.Test.MainTest.SourceDataDrivenTest",
testFramework: "nunit",
shouldPass: true);
Expand Down
10 changes: 4 additions & 6 deletions tests/OmniSharp.DotNetTest.Tests/TestDiscoveryFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ namespace OmniSharp.DotNetTest.Tests
public class TestDiscoveryFacts : AbstractTestFixture
{
private const string xunit = nameof(xunit);
private const string LegacyXunitTestProject = nameof(LegacyXunitTestProject);
private const string XunitTestMethod = "XunitTestMethod";
private const string XunitTestProject = nameof(XunitTestProject);

private const string nunit = nameof(nunit);
private const string LegacyNUnitTestProject = "LegacyNUnitTestProject";
private const string NUnitTestMethod = "NUnitTestMethod";
private const string NUnitTestProject = nameof(NUnitTestProject);

private const string TestProgram = "TestProgram.cs";

Expand All @@ -32,6 +28,8 @@ public TestDiscoveryFacts(ITestOutputHelper output)
this._testAssets = TestAssets.Instance;
}

public override DotNetCliVersion DotNetCliVersion { get; } = 0;

[Theory]
[InlineData(XunitTestProject, TestProgram, 8, 20, true, xunit, XunitTestMethod, "Main.Test.MainTest.Test")]
[InlineData(XunitTestProject, TestProgram, 16, 20, true, xunit, XunitTestMethod, "Main.Test.MainTest.DataDrivenTest1")]
Expand All @@ -48,7 +46,7 @@ public TestDiscoveryFacts(ITestOutputHelper output)
public async Task FindTestMethods(string projectName, string fileName, int line, int column, bool expectToFind, string expectedTestFramework, string expectedFeatureName, string expectedMethodName)
{
using (var testProject = await this._testAssets.GetTestProjectAsync(projectName))
using (var host = CreateOmniSharpHost(testProject.Directory))
using (var host = CreateOmniSharpHost(testProject.Directory, ConfigurationData, DotNetCliVersion.Current))
{
var filePath = Path.Combine(testProject.Directory, fileName);

Expand All @@ -70,7 +68,7 @@ public async Task FindTestMethods(string projectName, string fileName, int line,
public async Task LegacyFindTestMethods(string projectName, string fileName, int line, int column, bool expectToFind, string expectedTestFramework, string expectedFeatureName, string expectedMethodName)
{
using (var testProject = await this._testAssets.GetTestProjectAsync(projectName, legacyProject: true))
using (var host = CreateOmniSharpHost(testProject.Directory))
using (var host = CreateOmniSharpHost(testProject.Directory, ConfigurationData, DotNetCliVersion.Legacy))
{
var filePath = Path.Combine(testProject.Directory, fileName);

Expand Down
5 changes: 3 additions & 2 deletions tests/OmniSharp.Http.Tests/EndpointMiddlewareFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ class Response { }
[Export(typeof(IProjectSystem))]
class FakeProjectSystem : IProjectSystem
{
public string Key { get { return "Fake"; } }
public string Language { get { return LanguageNames.CSharp; } }
public string Key { get; } = "Fake";
public string Language { get; } = LanguageNames.CSharp;
public IEnumerable<string> Extensions { get; } = new[] { ".cs" };
public bool EnabledByDefault { get; } = true;

public Task<object> GetWorkspaceModelAsync(WorkspaceInformationRequest request)
{
Expand Down

0 comments on commit 5129ba5

Please sign in to comment.