Skip to content

Commit

Permalink
Merge pull request #1567 from filipw/bugfix/allow-unsafe
Browse files Browse the repository at this point in the history
fixed AllowUnsafe regression
  • Loading branch information
david-driscoll authored Jul 22, 2019
2 parents f6b33e0 + 694b92c commit c88a425
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All changes to the project will be documented in this file.

## [1.34.1] - not yet released
* Fixed a regression introduced in 1.32.20 which caused `AllowUnsafeCode` in csproj to also enable `TreatWarningsAsErrors` behavior ([#1565](https://github.com/OmniSharp/omnisharp-roslyn/issues/1565), PR: [#1567](https://github.com/OmniSharp/omnisharp-roslyn/pull/1567))

## [1.34.0] - 2019-07-15
* Added support for Roslyn code actions that normally need UI - they used to be explicitly sipped by OmniSharp, now it surfaces them with predefined defaults instead. ([#1220](https://github.com/OmniSharp/omnisharp-roslyn/issues/1220), PR: [#1406](https://github.com/OmniSharp/omnisharp-roslyn/pull/1406)) These are:
* extract interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static CSharpCompilationOptions CreateCompilationOptions(this ProjectFile

if (projectFileInfo.AllowUnsafeCode)
{
compilationOptions = compilationOptions.WithAllowUnsafe(true).WithGeneralDiagnosticOption(ReportDiagnostic.Error);
compilationOptions = compilationOptions.WithAllowUnsafe(true);
}

if (projectFileInfo.TreatWarningsAsErrors)
Expand Down
9 changes: 9 additions & 0 deletions test-assets/test-projects/AllowUnsafe/AllowUnsafe.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

</Project>
12 changes: 12 additions & 0 deletions test-assets/test-projects/AllowUnsafe/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace ConsoleApplication
{
public class Program
{
public static unsafe void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
16 changes: 16 additions & 0 deletions tests/OmniSharp.MSBuild.Tests/ProjectFileInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,21 @@ public async Task ExternAlias()
Assert.Equal("abc", projectFileInfo.ReferenceAliases[libpath]);
}
}

[Fact]
public async Task AllowUnsafe()
{
using (var host = CreateOmniSharpHost())
using (var testProject = await _testAssets.GetTestProjectAsync("AllowUnsafe"))
{
var projectFilePath = Path.Combine(testProject.Directory, "AllowUnsafe.csproj");
var projectFileInfo = CreateProjectFileInfo(host, testProject, projectFilePath);
Assert.True(projectFileInfo.AllowUnsafeCode);

var compilationOptions = projectFileInfo.CreateCompilationOptions();
Assert.True(compilationOptions.AllowUnsafe);
Assert.Equal(ReportDiagnostic.Default, compilationOptions.GeneralDiagnosticOption);
}
}
}
}

0 comments on commit c88a425

Please sign in to comment.