Skip to content

Commit

Permalink
Merge pull request #734 from filipw/bugfix/vscode-542
Browse files Browse the repository at this point in the history
Respect "nowarn" setting in dotnet project system
  • Loading branch information
DustinCampbell committed Jan 27, 2017
2 parents 3e7e9c0 + cd479db commit 8faf41b
Showing 1 changed file with 19 additions and 7 deletions.
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

0 comments on commit 8faf41b

Please sign in to comment.