Skip to content

Commit

Permalink
Merge pull request #102 from tareqimbasher/feat/allow-unsafe-code
Browse files Browse the repository at this point in the history
Allows unsafe code
  • Loading branch information
tareqimbasher authored Oct 31, 2023
2 parents d8b88d1 + 005710a commit 9b90a54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Core/NetPad.Compilation/CSharp/CSharpCodeCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public CSharpCodeCompiler(IDotNetInfo dotNetInfo)

public CompilationResult Compile(CompilationInput input)
{
// TODO write a unit test to test assembly name
string assemblyName = "NetPad_CompiledAssembly";

if (input.OutputAssemblyNameTag != null)
Expand Down Expand Up @@ -60,7 +59,8 @@ private CSharpCompilation CreateCompilation(CompilationInput input, string assem
var compilationOptions = new CSharpCompilationOptions(input.OutputKind)
.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default)
.WithOptimizationLevel(OptimizationLevel.Debug)
.WithOverflowChecks(true);
.WithOverflowChecks(true)
.WithAllowUnsafe(true);

return CSharpCompilation.Create(assemblyName,
new[] { parsedSyntaxTree },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ public AppOmniSharpServer(
public async Task<bool> StartAsync()
{
_logger.LogDebug("Initializing script project for script: {Script}", _environment.Script);

await Project.CreateAsync(
_environment.Script.Config.TargetFrameworkVersion,
ProjectOutputType.Executable,
true);

await Project.SetProjectPropertyAsync("AllowUnsafeBlocks", "true");

await Project.RestoreAsync();

InitializeEventHandlers();
Expand Down

0 comments on commit 9b90a54

Please sign in to comment.