-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #932 from cake-build/feature/cake
Cake support
- Loading branch information
Showing
65 changed files
with
19,163 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("OmniSharp.Cake.Tests")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Scripting; | ||
|
||
namespace OmniSharp.Cake | ||
{ | ||
internal class CachingScriptMetadataResolver : MetadataReferenceResolver | ||
{ | ||
private static readonly Dictionary<string, ImmutableArray<PortableExecutableReference>> DirectReferenceCache = new Dictionary<string, ImmutableArray<PortableExecutableReference>>(); | ||
private static readonly Dictionary<string, PortableExecutableReference> MissingReferenceCache = new Dictionary<string, PortableExecutableReference>(); | ||
private static readonly MetadataReferenceResolver DefaultRuntimeResolver = ScriptMetadataResolver.Default; | ||
|
||
public override bool Equals(object other) | ||
{ | ||
return DefaultRuntimeResolver.Equals(other); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return DefaultRuntimeResolver.GetHashCode(); | ||
} | ||
|
||
public override bool ResolveMissingAssemblies => DefaultRuntimeResolver.ResolveMissingAssemblies; | ||
|
||
public override PortableExecutableReference ResolveMissingAssembly(MetadataReference definition, AssemblyIdentity referenceIdentity) | ||
{ | ||
if (MissingReferenceCache.TryGetValue(referenceIdentity.Name, out var result)) | ||
{ | ||
return result; | ||
} | ||
|
||
result = DefaultRuntimeResolver.ResolveMissingAssembly(definition, referenceIdentity); | ||
if (result != null) | ||
{ | ||
MissingReferenceCache[referenceIdentity.Name] = result; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string baseFilePath, MetadataReferenceProperties properties) | ||
{ | ||
var key = $"{reference}-{baseFilePath}"; | ||
if (DirectReferenceCache.TryGetValue(key, out var result)) | ||
{ | ||
return result; | ||
} | ||
|
||
result = DefaultRuntimeResolver.ResolveReference(reference, baseFilePath, properties); | ||
if (result.Length > 0) | ||
{ | ||
DirectReferenceCache[key] = result; | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace OmniSharp.Cake | ||
{ | ||
internal class CakeContextModel | ||
{ | ||
public CakeContextModel(string filePath) | ||
{ | ||
Path = filePath; | ||
} | ||
|
||
public string Path { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace OmniSharp.Cake | ||
{ | ||
internal class CakeContextModelCollection | ||
{ | ||
public CakeContextModelCollection(IEnumerable<CakeContextModel> projects) | ||
{ | ||
Projects = projects; | ||
} | ||
|
||
public IEnumerable<CakeContextModel> Projects { get; } | ||
} | ||
} |
Oops, something went wrong.