Skip to content

Commit

Permalink
fixes add reference for *nix
Browse files Browse the repository at this point in the history
  • Loading branch information
nosami committed Dec 27, 2013
1 parent 5f5df2d commit 785be4d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NUnit.Framework;
using OmniSharp.ProjectManipulation.AddReference;
using Should;
using OmniSharp.Solution;

namespace OmniSharp.Tests.ProjectManipulation.AddReference
{
Expand Down Expand Up @@ -42,7 +43,7 @@ public void CanAddFileReference()

project.AsXml().ToString().ShouldEqual(expectedXml.ToString());
((FakeAssembly)project.References.First(r => r.GetType() == typeof(FakeAssembly)))
.AssemblyPath.ShouldEqual(@"c:\test\packages\SomeTest\lib\net40\Some.Test.dll");
.AssemblyPath.ForceWindowsPathSeparator().ShouldEqual(@"c:\test\packages\SomeTest\lib\net40\Some.Test.dll");
}

[Test]
Expand Down Expand Up @@ -74,7 +75,7 @@ public void CanAddFileReferenceWhenNoReferencesExist()
handler.AddReference(request);

project.AsXml().ToString().ShouldEqual(expectedXml.ToString());
((FakeAssembly)project.References.First(r => r.GetType() == typeof(FakeAssembly))).AssemblyPath.ShouldEqual(@"c:\test\packages\SomeTest\lib\net40\Some.Test.dll");
((FakeAssembly)project.References.First(r => r.GetType() == typeof(FakeAssembly))).AssemblyPath.ForceWindowsPathSeparator().ShouldEqual(@"c:\test\packages\SomeTest\lib\net40\Some.Test.dll");
}

[Test]
Expand Down
4 changes: 1 addition & 3 deletions OmniSharp/AutoComplete/AutoCompleteHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ public AutoCompleteHandler(ISolution solution, BufferParser parser, Logger logge
public IEnumerable<ICompletionData> CreateProvider(AutoCompleteRequest request)
{
request.Column = request.Column - request.WordToComplete.Length;

var completionContext = new BufferContext (request, _parser);

var partialWord = request.WordToComplete;

var project = _solution.ProjectContainingFile(request.FileName);

ICompletionContextProvider contextProvider = new DefaultCompletionContextProvider
(completionContext.Document, completionContext.ParsedContent.UnresolvedFile);

Expand All @@ -50,7 +49,6 @@ public IEnumerable<ICompletionData> CreateProvider(AutoCompleteRequest request)
{
EolMarker = Environment.NewLine
};

_logger.Debug("Getting Completion Data");

IEnumerable<ICompletionData> data = engine.GetCompletionData(completionContext.CursorPosition, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public AddReferenceResponse AddReference(IProject project, string reference)
projectXml.Element(MsBuildNameSpace + "Project").Add(projectItemGroup);
}

project.AddReference(reference.FixPath().Replace('/', '\\'));
project.AddReference(reference.FixPath());
project.Save(projectXml);

response.Message = string.Format("Reference to {0} added successfully", referenceName);
Expand Down
4 changes: 4 additions & 0 deletions OmniSharp/Solution/CSharpProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ public override string ToString()

public static IUnresolvedAssembly LoadAssembly(string assemblyFileName)
{
if (!File.Exists (assemblyFileName))
{
throw new FileNotFoundException ("Assembly does not exist!", assemblyFileName);
}
return assemblyDict.GetOrAdd(assemblyFileName, file => new CecilLoader().LoadAssemblyFile(file));
}

Expand Down
7 changes: 7 additions & 0 deletions OmniSharp/Solution/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public static string FixPath(this string path)
return path;
}

public static string ForceWindowsPathSeparator(this string path)
{
return path.Replace ('/', '\\');
}

/// <summary>
/// Returns the relative path of a file to another file
/// </summary>
Expand All @@ -42,5 +47,7 @@ public static string GetRelativePath(this string path, string pathToMakeRelative
{
return new Uri(path).MakeRelativeUri(new Uri(pathToMakeRelative)).ToString().Replace("/", @"\");
}


}
}

0 comments on commit 785be4d

Please sign in to comment.