Skip to content

Commit

Permalink
Web: fixed native compiler issues in .NET Core being the same as in Mono
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelTroka committed Jan 26, 2018
1 parent 9abde3b commit 07a3fd4
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Computator.NET.Core/Compilation/NativeCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,8 @@ private CompilationErrorPlace GetPlaceForLine(int line)

public Assembly Compile(string input)
{
if (RuntimeInformation.IsUnix)
{
if (!Directory.Exists(AppInformation.TempDirectory))
{
Directory.CreateDirectory(AppInformation.TempDirectory);
}
//fix for #39 - otherwise in Mono CSharpCodeProvider will always return the same assembly
_parameters.OutputAssembly = Path.Combine(AppInformation.TempDirectory, Guid.NewGuid().ToString());
}
FixForMonoAndNetCore();

var results = CompileAssemblyFromSource(_parameters, input);

if (results.Errors.HasErrors)
Expand Down Expand Up @@ -152,6 +145,18 @@ public Assembly Compile(string input)
return results.CompiledAssembly;
}

private void FixForMonoAndNetCore()
{
//fix for #39 - otherwise in Mono CSharpCodeProvider will always return the same assembly
//this also happens on .NET Core
if (!Directory.Exists(AppInformation.TempDirectory))
{
Directory.CreateDirectory(AppInformation.TempDirectory);
}

_parameters.OutputAssembly = Path.Combine(AppInformation.TempDirectory, Guid.NewGuid().ToString());
}

private CompilationException CreateCompilationExceptionFromCompilerResults(CompilerResults results)
{
var compilationException = new CompilationException();
Expand Down

0 comments on commit 07a3fd4

Please sign in to comment.