diff --git a/CHANGELOG.md b/CHANGELOG.md index 5937f07aed..6ef11803c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfoExtensions.cs b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfoExtensions.cs index 69b76345ad..fd61c17442 100644 --- a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfoExtensions.cs +++ b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfoExtensions.cs @@ -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) diff --git a/test-assets/test-projects/AllowUnsafe/AllowUnsafe.csproj b/test-assets/test-projects/AllowUnsafe/AllowUnsafe.csproj new file mode 100644 index 0000000000..7ed1b0f016 --- /dev/null +++ b/test-assets/test-projects/AllowUnsafe/AllowUnsafe.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + true + + + \ No newline at end of file diff --git a/test-assets/test-projects/AllowUnsafe/Program.cs b/test-assets/test-projects/AllowUnsafe/Program.cs new file mode 100644 index 0000000000..714bb23a60 --- /dev/null +++ b/test-assets/test-projects/AllowUnsafe/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static unsafe void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} \ No newline at end of file diff --git a/tests/OmniSharp.MSBuild.Tests/ProjectFileInfoTests.cs b/tests/OmniSharp.MSBuild.Tests/ProjectFileInfoTests.cs index ed0b3a972c..7baf050945 100644 --- a/tests/OmniSharp.MSBuild.Tests/ProjectFileInfoTests.cs +++ b/tests/OmniSharp.MSBuild.Tests/ProjectFileInfoTests.cs @@ -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); + } + } } }