Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fixed AllowUnsafe regression #1567

Merged
merged 4 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}
}