From d900eaf370c87d564b9a246bbfa32ea29531cf98 Mon Sep 17 00:00:00 2001 From: filipw Date: Fri, 27 Jan 2017 16:06:04 +0100 Subject: [PATCH 1/3] respect "no warn" --- src/OmniSharp.DotNet/DotNetProjectSystem.cs | 26 ++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/OmniSharp.DotNet/DotNetProjectSystem.cs b/src/OmniSharp.DotNet/DotNetProjectSystem.cs index aace7bc338..f14523df02 100644 --- a/src/OmniSharp.DotNet/DotNetProjectSystem.cs +++ b/src/OmniSharp.DotNet/DotNetProjectSystem.cs @@ -12,6 +12,7 @@ using Microsoft.DotNet.ProjectModel; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using NuGet.Packaging; using OmniSharp.DotNet.Cache; using OmniSharp.DotNet.Extensions; using OmniSharp.DotNet.Models; @@ -318,7 +319,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 +327,30 @@ private void UpdateCompilationOption(ProjectState state) var optimize = (option.Optimize ?? false) ? OptimizationLevel.Release : OptimizationLevel.Debug; + var suppressedOptions = 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 (!suppressedOptions.ContainsKey(nowarn)) + { + suppressedOptions.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(suppressedOptions) .WithConcurrentBuild(false); // TODO: actually just need to disable on mono if (!string.IsNullOrEmpty(option.KeyFile)) From ae90d35f08fa689bcfa56313571aa3bc736ccdd8 Mon Sep 17 00:00:00 2001 From: filipw Date: Fri, 27 Jan 2017 16:06:25 +0100 Subject: [PATCH 2/3] removed unused namespaces --- src/OmniSharp.DotNet/DotNetProjectSystem.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/OmniSharp.DotNet/DotNetProjectSystem.cs b/src/OmniSharp.DotNet/DotNetProjectSystem.cs index f14523df02..1987420a1d 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; @@ -12,7 +11,6 @@ using Microsoft.DotNet.ProjectModel; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -using NuGet.Packaging; using OmniSharp.DotNet.Cache; using OmniSharp.DotNet.Extensions; using OmniSharp.DotNet.Models; From cd479db65ecf82f1e4bdc0e4827d0807e5dfabd9 Mon Sep 17 00:00:00 2001 From: filipw Date: Fri, 27 Jan 2017 16:09:23 +0100 Subject: [PATCH 3/3] suppressedOptions => suppressedDiagnostics --- src/OmniSharp.DotNet/DotNetProjectSystem.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OmniSharp.DotNet/DotNetProjectSystem.cs b/src/OmniSharp.DotNet/DotNetProjectSystem.cs index 1987420a1d..05a5744fd7 100644 --- a/src/OmniSharp.DotNet/DotNetProjectSystem.cs +++ b/src/OmniSharp.DotNet/DotNetProjectSystem.cs @@ -325,7 +325,7 @@ private void UpdateCompilationOption(ProjectState state) var optimize = (option.Optimize ?? false) ? OptimizationLevel.Release : OptimizationLevel.Debug; - var suppressedOptions = new Dictionary + var suppressedDiagnostics = new Dictionary { {"CS1701", ReportDiagnostic.Suppress}, {"CS1702", ReportDiagnostic.Suppress}, @@ -336,9 +336,9 @@ private void UpdateCompilationOption(ProjectState state) { foreach (var nowarn in option.SuppressWarnings) { - if (!suppressedOptions.ContainsKey(nowarn)) + if (!suppressedDiagnostics.ContainsKey(nowarn)) { - suppressedOptions.Add(nowarn, ReportDiagnostic.Suppress); + suppressedDiagnostics.Add(nowarn, ReportDiagnostic.Suppress); } } } @@ -348,7 +348,7 @@ private void UpdateCompilationOption(ProjectState state) .WithPlatform(ParsePlatfrom(option.Platform)) .WithGeneralDiagnosticOption(generalDiagnosticOpt) .WithOptimizationLevel(optimize) - .WithSpecificDiagnosticOptions(suppressedOptions) + .WithSpecificDiagnosticOptions(suppressedDiagnostics) .WithConcurrentBuild(false); // TODO: actually just need to disable on mono if (!string.IsNullOrEmpty(option.KeyFile))