diff --git a/src/OmniSharp.DotNet/DotNetProjectSystem.cs b/src/OmniSharp.DotNet/DotNetProjectSystem.cs index aace7bc338..05a5744fd7 100644 --- a/src/OmniSharp.DotNet/DotNetProjectSystem.cs +++ b/src/OmniSharp.DotNet/DotNetProjectSystem.cs @@ -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; @@ -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; @@ -327,16 +325,30 @@ private void UpdateCompilationOption(ProjectState state) var optimize = (option.Optimize ?? false) ? OptimizationLevel.Release : OptimizationLevel.Debug; + var suppressedDiagnostics = new Dictionary + { + {"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 { - { "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))