-
-
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.
* Working on in-memory compilation * Almost working * Cleanup * Don't support trace logging * More speedup * Use runtime image * Use self-contained app * Move ready-to-run configuration into project file * Don't remove globalization options * Use correct Docker call from code * Remove todo * Refactor and fix concurrency issue * Rename * Update to latest formatter * Format code
- Loading branch information
1 parent
1cd34d8
commit c3ca3f5
Showing
37 changed files
with
213 additions
and
262 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,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using Exercism.Tests; | ||
|
||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.Text; | ||
|
||
namespace Exercism.TestRunner.CSharp | ||
{ | ||
internal static class TestCompilation | ||
{ | ||
public static Compilation Compile(Options options) => | ||
CSharpCompilation.Create(Guid.NewGuid().ToString("N"), SyntaxTrees(options), References(), CompilationOptions()); | ||
|
||
private static IEnumerable<SyntaxTree> SyntaxTrees(Options options) | ||
{ | ||
SyntaxTree ParseSyntaxTree(string file) | ||
{ | ||
var source = SourceText.From(File.OpenRead(file)); | ||
var syntaxTree = CSharpSyntaxTree.ParseText(source, path: file); | ||
|
||
// We need to rewrite the test suite to un-skip all tests and capture any console output | ||
if (file == options.TestsFilePath) | ||
{ | ||
return syntaxTree.Rewrite(); | ||
} | ||
|
||
return syntaxTree; | ||
} | ||
|
||
return Directory.EnumerateFiles(options.InputDirectory, "*.cs", SearchOption.AllDirectories) | ||
.Select(ParseSyntaxTree); | ||
} | ||
|
||
private static CSharpCompilationOptions CompilationOptions() => | ||
new(OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release); | ||
|
||
private static IEnumerable<PortableExecutableReference> References() | ||
{ | ||
var trustedAssembliesPaths = ((string)AppContext.GetData("TRUSTED_PLATFORM_ASSEMBLIES"))!.Split(Path.PathSeparator); | ||
return trustedAssembliesPaths | ||
.Select(p => MetadataReference.CreateFromFile(p)) | ||
.Append(MetadataReference.CreateFromFile(typeof(Xunit.FactAttribute).Assembly.Location)) | ||
.Append(MetadataReference.CreateFromFile(typeof(Xunit.Assert).Assembly.Location)) | ||
.Append(MetadataReference.CreateFromFile(typeof(TaskAttribute).Assembly.Location)); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.