Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Respect "nowarn" setting in dotnet project system #734

Merged
merged 3 commits into from Jan 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/OmniSharp.DotNet/DotNetProjectSystem.cs
Expand Up @@ -4,7 +4,6 @@
using System.Composition;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down Expand Up @@ -318,7 +317,6 @@ private void UpdateCompilationOption(ProjectState state)
var context = state.ProjectContext;
var project = context.ProjectFile;
var option = project.GetCompilerOptions(context.TargetFramework, _compilationConfiguration);

var outputKind = option.EmitEntryPoint.GetValueOrDefault() ? OutputKind.ConsoleApplication :
OutputKind.DynamicallyLinkedLibrary;

Expand All @@ -327,16 +325,30 @@ private void UpdateCompilationOption(ProjectState state)

var optimize = (option.Optimize ?? false) ? OptimizationLevel.Release : OptimizationLevel.Debug;

var suppressedDiagnostics = new Dictionary<string, ReportDiagnostic>
{
{"CS1701", ReportDiagnostic.Suppress},
{"CS1702", ReportDiagnostic.Suppress},
{"CS1705", ReportDiagnostic.Suppress},
};

if (option.SuppressWarnings != null && option.SuppressWarnings.Any())
{
foreach (var nowarn in option.SuppressWarnings)
{
if (!suppressedDiagnostics.ContainsKey(nowarn))
{
suppressedDiagnostics.Add(nowarn, ReportDiagnostic.Suppress);
}
}
}

var csharpOptions = new CSharpCompilationOptions(outputKind)
.WithAllowUnsafe(option.AllowUnsafe ?? false)
.WithPlatform(ParsePlatfrom(option.Platform))
.WithGeneralDiagnosticOption(generalDiagnosticOpt)
.WithOptimizationLevel(optimize)
.WithSpecificDiagnosticOptions(new Dictionary<string, ReportDiagnostic> {
{ "CS1701", ReportDiagnostic.Suppress },
{ "CS1702", ReportDiagnostic.Suppress },
{ "CS1705", ReportDiagnostic.Suppress },
})
.WithSpecificDiagnosticOptions(suppressedDiagnostics)
.WithConcurrentBuild(false); // TODO: actually just need to disable on mono

if (!string.IsNullOrEmpty(option.KeyFile))
Expand Down