Skip to content

Commit

Permalink
Merge pull request #553 from OmniSharp/troy/update.dep
Browse files Browse the repository at this point in the history
Merge dependencies update
  • Loading branch information
david-driscoll committed May 14, 2016
2 parents 2c6c8a4 + a94b5f7 commit 6d410ed
Show file tree
Hide file tree
Showing 40 changed files with 354 additions and 206 deletions.
4 changes: 3 additions & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<configuration>
<packageSources>
<clear/>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcirelease/api/v3/index.json" />
<add key="AspNetRC2" value="https://www.myget.org/F/aspnetrc2/api/v3/index.json" />
<add key="AspNetReleaseCI" value="https://www.myget.org/F/aspnetcirelease/api/v3/index.json" />
<add key="Coreclr-Xunit" value="https://www.myget.org/F/coreclr-xunit/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Task("PopulateRuntimes")
Task("BuildEnvironment")
.Does(() =>
{
var installScript = $"install.{shellExtension}";
var installScript = $"dotnet-install.{shellExtension}";
System.IO.Directory.CreateDirectory(dotnetFolder);
var scriptPath = System.IO.Path.Combine(dotnetFolder, installScript);
using (WebClient client = new WebClient())
Expand Down Expand Up @@ -238,7 +238,7 @@ Task("TestCore")
{
var logFile = System.IO.Path.Combine(logFolder, $"{testProject}-core-result.xml");
var testWorkingDir = System.IO.Path.Combine(testFolder, testProject);
Run(dotnetcli, $"test -xml \"{logFile}\" -notrait category=failing", testWorkingDir)
Run(dotnetcli, $"test -f netcoreapp1.0 -xml \"{logFile}\" -notrait category=failing", testWorkingDir)
.ExceptionOnError($"Test {testProject} failed for .NET Core.");
}
});
Expand Down
6 changes: 3 additions & 3 deletions build.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"UseSystemDotNetPath": "false",
"DotNetFolder": ".dotnet",
"DotNetInstallScriptURL": "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain",
"DotNetInstallScriptURL": "https://raw.githubusercontent.com/dotnet/cli/6cde21225e18fc48eeab3f4345ece3e6bb122e53/scripts/obtain/",
"DotNetChannel": "beta",
"DotNetVersion": "1.0.0-rc2-002416",
"DotNetVersion": "1.0.0-preview1-002702",
"BuildToolsFolder": ".tools",
"ArtifactsFolder": "artifacts",
"TestProjects": {
Expand All @@ -26,4 +26,4 @@
"netcoreapp1.0"
],
"MainProject": "OmniSharp"
}
}
33 changes: 16 additions & 17 deletions src/OmniSharp.Abstractions/project.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"warningsAsErrors": true,
"preserveCompilationContext": true
"buildOptions": {
"warningsAsErrors": true
},
"dependencies": {
"Newtonsoft.Json": "8.0.3",
"Microsoft.CodeAnalysis": "1.3.0-beta1-20160410-01",
"Microsoft.CodeAnalysis": "1.3.0-beta1-20160429-01",
"Microsoft.Composition": "1.0.30",
"Microsoft.Extensions.Caching.Memory": "1.0.0-rc2-20708",
"Microsoft.Extensions.Configuration": "1.0.0-rc2-20708",
"Microsoft.Extensions.Configuration.Binder": "1.0.0-rc2-20708",
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-20708",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-20708",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-20708",
"System.Reflection.Metadata": "1.3.0-rc2-24018"
"Microsoft.Extensions.Caching.Memory": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Binder": "1.0.0-rc2-final",
"Microsoft.Extensions.FileSystemGlobbing": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-final",
"System.Reflection.Metadata": "1.3.0-rc2-24027"
},
"frameworks": {
"net451": {
Expand All @@ -39,12 +38,12 @@
"portable-net45+win8"
],
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24018",
"System.Diagnostics.Process": "4.1.0-rc2-24018",
"System.Dynamic.Runtime": "4.0.11-rc2-24018",
"System.IO.FileSystem.Watcher": "4.0.0-rc2-24018",
"System.Threading.Thread": "4.0.0-rc2-24018"
"NETStandard.Library": "1.5.0-rc2-24027",
"System.Diagnostics.Process": "4.1.0-rc2-24027",
"System.Dynamic.Runtime": "4.0.11-rc2-24027",
"System.IO.FileSystem.Watcher": "4.0.0-rc2-24027",
"System.Threading.Thread": "4.0.0-rc2-24027"
}
}
}
}
}
16 changes: 8 additions & 8 deletions src/OmniSharp.Bootstrap/project.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"buildOptions": {
"warningsAsErrors": true,
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.Composition": "1.0.30",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-20708",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-final",
"Newtonsoft.Json": "8.0.3"
},
"commands": {
Expand All @@ -25,12 +25,12 @@
"portable-net45+win8"
],
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24018",
"System.Dynamic.Runtime": "4.0.11-rc2-24018",
"System.Linq.Expressions": "4.0.11-rc2-24018",
"System.Security.Cryptography.Algorithms": "4.1.0-rc2-24018",
"System.Xml.XDocument": "4.0.11-rc2-24018"
"NETStandard.Library": "1.5.0-rc2-24027",
"System.Dynamic.Runtime": "4.0.11-rc2-24027",
"System.Linq.Expressions": "4.0.11-rc2-24027",
"System.Security.Cryptography.Algorithms": "4.1.0-rc2-24027",
"System.Xml.XDocument": "4.0.11-rc2-24027"
}
}
}
}
}
10 changes: 2 additions & 8 deletions src/OmniSharp.DotNet/DotNetProjectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class DotNetProjectSystem : IProjectSystem
private readonly PackagesRestoreTool _packageRestore;
private readonly OmnisharpWorkspace _omnisharpWorkspace;
private readonly ProjectStatesCache _projectStates;
private WorkspaceContext _workspaceContext;
private DotNetWorkspace _workspaceContext;
private bool _enableRestorePackages = false;

[ImportingConstructor]
Expand Down Expand Up @@ -99,13 +99,7 @@ public void Initalize(IConfiguration configuration)

_logger.LogInformation($"Auto package restore: {_enableRestorePackages}");

_workspaceContext = WorkspaceContext.Create();
var projects = ProjectSearcher.Search(_environment.Path);
_logger.LogInformation($"Originated from {projects.Count()} projects.");
foreach (var path in projects)
{
_workspaceContext.AddProject(path);
}
_workspaceContext = new DotNetWorkspace(_environment.Path);

Update(allowRestore: true);
}
Expand Down
169 changes: 169 additions & 0 deletions src/OmniSharp.DotNet/DotNetWorkspace.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Graph;

namespace OmniSharp.DotNet
{

public class DotNetWorkspace : Workspace
{
private readonly HashSet<string> _projects = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

private bool _needRefresh;

public DotNetWorkspace(string initialPath) : base(ProjectReaderSettings.ReadFromEnvironment(), true)
{
var paths = ResolveProjectPath(initialPath);
if (paths != null && paths.Any())
{
foreach (var path in paths)
{
AddProject(path);
}
}
}

public void AddProject(string path)
{
var projectPath = NormalizeProjectPath(path);

if (projectPath != null)
{
_needRefresh = _projects.Add(path);
}
}

public void RemoveProject(string path)
{
_needRefresh = _projects.Remove(path);
}

public IReadOnlyList<string> GetAllProjects()
{
Refresh();
return _projects.ToList().AsReadOnly();
}

public IReadOnlyList<ProjectContext> GetProjectContexts(string projectPath)
{
return (IReadOnlyList<ProjectContext>)GetProjectContextCollection(projectPath)?.ProjectContexts.AsReadOnly() ??
Enumerable.Empty<ProjectContext>().ToList().AsReadOnly();
}

/// <summary>
/// Refresh all cached projects in the Workspace
/// </summary>
public void Refresh()
{
if (!_needRefresh)
{
return;
}

var basePaths = new List<string>(_projects);
_projects.Clear();

foreach (var projectDirectory in basePaths)
{
var project = GetProject(projectDirectory);
if (project == null)
{
continue;
}

_projects.Add(project.ProjectDirectory);

foreach (var projectContext in GetProjectContextCollection(project.ProjectDirectory).ProjectContexts)
{
foreach (var reference in GetProjectReferences(projectContext))
{
var referencedProject = GetProject(reference.Path);
if (referencedProject != null)
{
_projects.Add(referencedProject.ProjectDirectory);
}
}
}
}

_needRefresh = false;
}

protected override IEnumerable<ProjectContext> BuildProjectContexts(Project project)
{
foreach (var framework in project.GetTargetFrameworks())
{
yield return CreateBaseProjectBuilder(project)
.AsDesignTime()
.WithTargetFramework(framework.FrameworkName)
.Build();
}
}

private static List<string> ResolveProjectPath(string projectPath)
{
if (File.Exists(projectPath))
{
var filename = Path.GetFileName(projectPath);
if (!Project.FileName.Equals(filename, StringComparison.OrdinalIgnoreCase) &&
!GlobalSettings.FileName.Equals(filename, StringComparison.OrdinalIgnoreCase))
{
return null;
}

projectPath = Path.GetDirectoryName(projectPath);
}

if (File.Exists(Path.Combine(projectPath, Project.FileName)))
{
return new List<string> { projectPath };
}

if (File.Exists(Path.Combine(projectPath, GlobalSettings.FileName)))
{
var root = ProjectRootResolver.ResolveRootDirectory(projectPath);
GlobalSettings globalSettings;
if (GlobalSettings.TryGetGlobalSettings(projectPath, out globalSettings))
{
return globalSettings.ProjectSearchPaths
.Select(searchPath => Path.Combine(globalSettings.DirectoryPath, searchPath))
.Where(actualPath => Directory.Exists(actualPath))
.SelectMany(actualPath => Directory.GetDirectories(actualPath))
.Where(actualPath => File.Exists(Path.Combine(actualPath, Project.FileName)))
.Select(path => Path.GetFullPath(path))
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
}
}

return null;
}

private static IEnumerable<ProjectDescription> GetProjectReferences(ProjectContext context)
{
var projectDescriptions = context.LibraryManager
.GetLibraries()
.Where(lib => lib.Identity.Type == LibraryType.Project)
.OfType<ProjectDescription>();

foreach (var description in projectDescriptions)
{
if (description.Identity.Name == context.ProjectFile.Name)
{
continue;
}

// if this is an assembly reference then don't threat it as project reference
if (!string.IsNullOrEmpty(description.TargetFrameworkInfo?.AssemblyPath))
{
continue;
}

yield return description;
}
}
}
}
23 changes: 10 additions & 13 deletions src/OmniSharp.DotNet/project.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"preserveCompilationContext": true
},
"dependencies": {
"OmniSharp.Abstractions": "1.0.0",
"OmniSharp.Roslyn": "1.0.0",
"Microsoft.CodeAnalysis": "1.3.0-beta1-20160410-01",
"Microsoft.CodeAnalysis.Common": "1.3.0-beta1-20160410-01",
"Microsoft.DotNet.ProjectModel": "1.0.0-rc2-002439",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-20708"
"Microsoft.CodeAnalysis": "1.3.0-beta1-20160429-01",
"Microsoft.CodeAnalysis.Common": "1.3.0-beta1-20160429-01",
"Microsoft.DotNet.ProjectModel": "1.0.0-rc2-002702",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc2-final"
},
"frameworks": {
"net451": {
Expand All @@ -25,12 +22,12 @@
"portable-net45+win8"
],
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24018",
"System.IO.Compression": "4.1.0-rc2-24018",
"System.Runtime.Loader": "4.0.0-rc2-24018",
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24018",
"System.Security.Cryptography.Algorithms": "4.1.0-rc2-24018"
"NETStandard.Library": "1.5.0-rc2-24027",
"System.IO.Compression": "4.1.0-rc2-24027",
"System.Runtime.Loader": "4.0.0-rc2-24027",
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027",
"System.Security.Cryptography.Algorithms": "4.1.0-rc2-24027"
}
}
}
}
}
Loading

0 comments on commit 6d410ed

Please sign in to comment.