-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* release/0.8.0: Add GitHub Actions & Remove Bitrise Badges Update src/Cake.Scripting/Cake.Scripting.csproj (GH-148) Also use Basic.Reference.Assemblies * fixes #148 (GH-148) Use Cake Scripting Conventions
- Loading branch information
Showing
6 changed files
with
85 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Reflection; | ||
|
||
#pragma warning disable IDE0130 | ||
// Temporary polyfill see https://github.com/cake-build/cake/pull/3715 | ||
namespace Cake.Core.Scripting | ||
#pragma warning restore IDE0130 | ||
{ | ||
/// <summary> | ||
/// Represents a framework reference assembly resolver. | ||
/// </summary> | ||
public interface IReferenceAssemblyResolver | ||
{ | ||
/// <summary> | ||
/// Finds framwork reference assemblies. | ||
/// </summary> | ||
/// <returns>The resolved reference assemblies.</returns> | ||
Assembly[] GetReferenceAssemblies(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/Cake.Scripting/Reflection/ReferenceAssemblyResolver.cs
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,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Cake.Core.Diagnostics; | ||
using Cake.Core.Scripting; | ||
|
||
namespace Cake.Scripting.Reflection | ||
{ | ||
public sealed class ReferenceAssemblyResolver : IReferenceAssemblyResolver | ||
{ | ||
private readonly ICakeLog _log; | ||
|
||
public ReferenceAssemblyResolver(ICakeLog log) | ||
{ | ||
_log = log; | ||
} | ||
|
||
public Assembly[] GetReferenceAssemblies() | ||
{ | ||
IEnumerable<Assembly> TryGetReferenceAssemblies() | ||
{ | ||
foreach (var reference in Basic.Reference.Assemblies.Net60.All) | ||
{ | ||
Assembly name; | ||
try | ||
{ | ||
name = Assembly.Load(System.IO.Path.GetFileNameWithoutExtension(reference.FilePath)); | ||
} | ||
catch (Exception ex) | ||
{ | ||
_log.Debug(log => log("Failed to load {0}\r\n{1}", reference.FilePath, ex)); | ||
continue; | ||
} | ||
|
||
yield return name; | ||
} | ||
} | ||
|
||
return TryGetReferenceAssemblies().ToArray(); | ||
} | ||
} | ||
} |
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