Skip to content

Commit

Permalink
exp #1
Browse files Browse the repository at this point in the history
  • Loading branch information
troydai committed Jun 3, 2016
1 parent 82f5603 commit df8b18b
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 13 deletions.
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"tasks": [
{
"taskName": "publish",
"args": [
"${workspaceRoot}/tests/MSBuildTestDriver"
],
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
}
]
}
16 changes: 9 additions & 7 deletions src/OmniSharp.MSBuild/MSBuildProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using OmniSharp.Models;
using OmniSharp.Models.v1;
using OmniSharp.MSBuild.Analyzers;
using OmniSharp.MSBuild.ProjectFile;
using OmniSharp.Options;
using OmniSharp.Services;
Expand All @@ -39,6 +37,8 @@ public class MSBuildProjectSystem : IProjectSystem

private MSBuildOptions _options;

private readonly ILoggerFactory _loggerFactory;

[ImportingConstructor]
public MSBuildProjectSystem(OmnisharpWorkspace workspace,
IOmnisharpEnvironment env,
Expand All @@ -52,13 +52,15 @@ public MSBuildProjectSystem(OmnisharpWorkspace workspace,
_metadataReferenceCache = metadataReferenceCache;
_watcher = watcher;
_env = env;
_logger = loggerFactory.CreateLogger<MSBuildProjectSystem>();
_emitter = emitter;
_context = context;

_logger = loggerFactory.CreateLogger("OmniSharp#MSBuild");
_loggerFactory = loggerFactory;
}

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

public void Initalize(IConfiguration configuration)
Expand Down Expand Up @@ -191,7 +193,7 @@ private ProjectFileInfo CreateProject(string projectFilePath)

try
{
projectFileInfo = ProjectFileInfo.Create(_options, _logger, _env.Path, projectFilePath, diagnostics);
projectFileInfo = ProjectFileInfo.Create(_options, _loggerFactory.CreateLogger("OmniSharp#ProjectFileInfo"), _env.Path, projectFilePath, diagnostics);

if (projectFileInfo == null)
{
Expand Down Expand Up @@ -309,7 +311,7 @@ private void UpdateProject(ProjectFileInfo projectFileInfo)
}

// TODO: Enable Analyzer

// var unusedAnalyzers = new Dictionary<string, AnalyzerReference>(project.AnalyzerReferences.ToDictionary(a => a.FullPath));

// foreach (var analyzerPath in projectFileInfo.Analyzers)
Expand Down
7 changes: 6 additions & 1 deletion src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ public class ProjectFileInfo

public string AssemblyOriginatorKeyFile { get; private set; }

public static ProjectFileInfo Create(MSBuildOptions options, ILogger logger, string solutionDirectory, string projectFilePath, ICollection<MSBuildDiagnosticsMessage> diagnostics)
public static ProjectFileInfo Create(
MSBuildOptions options,
ILogger logger,
string solutionDirectory,
string projectFilePath,
ICollection<MSBuildDiagnosticsMessage> diagnostics)
{
var projectFileInfo = new ProjectFileInfo();
projectFileInfo.ProjectFilePath = projectFilePath;
Expand Down
3 changes: 2 additions & 1 deletion src/OmniSharp.MSBuild/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Microsoft.Build.Framework": "0.1.0-*",
"Microsoft.Build.Targets": "0.1.0-*",
"Microsoft.Build.Tasks.Core": "0.1.0-*",
"Microsoft.Build.Utilities.Core": "0.1.0-*"
"Microsoft.Build.Utilities.Core": "0.1.0-*",
"Microsoft.Net.Compilers": "1.3.0-beta1-20160525-03"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/OmniSharp/p.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kill $(ps aux | grep "/Users/troydai/Code/omnisharp-roslyn/src/OmniSharp/bin/Debug/netcoreapp1.0/osx.10.11-x64/publish/OmniSharp" | grep -v "grep" | cut -d " " -f10)
../../.dotnet/dotnet publish -f netcoreapp1.0
6 changes: 3 additions & 3 deletions src/OmniSharp/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},
"dependencies": {
"OmniSharp.Host": "1.0.0",
"OmniSharp.Roslyn.CSharp": "1.0.0",
"OmniSharp.DotNet": "1.0.0",
"OmniSharp.DotNetTest": "1.0.0"
"OmniSharp.Roslyn.CSharp": "1.0.0"//,
//"OmniSharp.DotNet": "1.0.0",
//"OmniSharp.DotNetTest": "1.0.0"
},
"frameworks": {
"net451": {
Expand Down
30 changes: 30 additions & 0 deletions tests/MSBuildTestDriver/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using OmniSharp.Models;
using OmniSharp.MSBuild.ProjectFile;
using OmniSharp.Options;
using TestCommon;

namespace MSBuildTestDriver
{
public class MSBuildTestProgram
{
public static void Main(string[] args)
{
var loggerFactory = new LoggerFactory();
loggerFactory.AddConsole();
var logger = loggerFactory.CreateLogger("MSBuild Test Driver");

var testProject = TestsContext.Default.GetTestSample("CsProjectSample01");
var option = new MSBuildOptions();
var diagnstics = new List<MSBuildDiagnosticsMessage>();
var project = ProjectFileInfo.Create(
option,
logger,
testProject,
System.IO.Path.Combine(testProject, "ConsoleApplication1", "ConsoleApplication1.csproj"),
diagnstics);
}
}
}
31 changes: 31 additions & 0 deletions tests/MSBuildTestDriver/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.CodeAnalysis.CSharp.Workspaces": "1.3.0-beta1-20160525-03",
"TestCommon": "1.0.0",
"TestUtility": "1.0.0",
"OmniSharp.MSBuild": "1.0.0",
"Microsoft.Build": "0.1.0-*",
"Microsoft.Build.Framework": "0.1.0-*",
"Microsoft.Build.Targets": "0.1.0-*",
"Microsoft.Build.Tasks.Core": "0.1.0-*",
"Microsoft.Build.Utilities.Core": "0.1.0-*",
"Microsoft.Net.Compilers": "1.3.0-beta1-20160525-03",
"Microsoft.NETCore.App": "1.0.0-rc3-004338"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"netstandardapp1.5",
"dnxcore50",
"portable-net45+win8"
]
}
},
"runtimes": {
"osx.10.11-x64": {}
}
}
34 changes: 34 additions & 0 deletions tests/OmniSharp.MSBuild.Tests/ProjectSystemFacts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Xunit;
using TestCommon;
using OmniSharp.MSBuild.ProjectFile;
using OmniSharp.Options;
using System.IO;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using OmniSharp.Models;

namespace OmniSharp.MSBuild.Tests
{
public class ProjectSystemFacts
{
// [Fact]
public void OpenSimpleConsoleApp()
{
var testProject = TestsContext.Default.GetTestSample("CsProjectSample01");
var option = new MSBuildOptions();
var loggerFactory = new LoggerFactory();
loggerFactory.AddConsole();
var logger = loggerFactory.CreateLogger("OpenSimpleConsoleApp.Test");
var diagnstics = new List<MSBuildDiagnosticsMessage>();
var project = ProjectFileInfo.Create(
option,
logger,
testProject,
Path.Combine(testProject, "ConsoleApplication1", "ConsoleApplication1.csproj"),
diagnstics);

// var projectSystem = new MSBuildProjectSystem();
Assert.NotNull(project);
}
}
}
4 changes: 3 additions & 1 deletion tests/OmniSharp.MSBuild.Tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"dependencies": {
"OmniSharp.Tests": "1.0.0",
"Microsoft.CodeAnalysis.CSharp.Workspaces": "1.3.0-beta1-20160525-03",
"xunit": "2.1.0"
"xunit": "2.1.0",
"TestCommon": "1.0.0",
"TestUtility": "1.0.0"
},
"frameworks": {
"netcoreapp1.0": {
Expand Down
4 changes: 4 additions & 0 deletions tests/TestSamples/CsProjectSample01/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Place your settings in this file to overwrite default and user settings.
{
"csharp.omnisharp": "/Users/troydai/Code/omnisharp-roslyn/src/OmniSharp/bin/Debug/netcoreapp1.0/osx.10.11-x64/publish/OmniSharp"
}

0 comments on commit df8b18b

Please sign in to comment.