Add default suppress to compiler options message
This commit is contained in:
parent
7555793363
commit
1b8f3a0025
10 changed files with 55 additions and 36 deletions
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
|
{
|
||||||
|
public class DefaultCompilerWarningSuppresses
|
||||||
|
{
|
||||||
|
public static IReadOnlyDictionary<string, IReadOnlyList<string>> Suppresses { get; } = new Dictionary<string, IReadOnlyList<string>>
|
||||||
|
{
|
||||||
|
{ "csc", new string[] {"CS1701", "CS1702", "CS1705" } }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -71,7 +71,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
|
|
||||||
return rootOutputPath;
|
return rootOutputPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MakeCompilationOutputRunnable(this ProjectContext context, string outputPath, string configuration)
|
public static void MakeCompilationOutputRunnable(this ProjectContext context, string outputPath, string configuration)
|
||||||
{
|
{
|
||||||
context
|
context
|
||||||
|
@ -115,7 +115,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
targetDirectory = EnsureTrailingSlash(targetDirectory);
|
targetDirectory = EnsureTrailingSlash(targetDirectory);
|
||||||
|
|
||||||
var pathMap = sourceFiles
|
var pathMap = sourceFiles
|
||||||
.ToDictionary(s => s,
|
.ToDictionary(s => s,
|
||||||
s => Path.Combine(targetDirectory,
|
s => Path.Combine(targetDirectory,
|
||||||
PathUtility.GetRelativePath(sourceDirectory, s)));
|
PathUtility.GetRelativePath(sourceDirectory, s)));
|
||||||
|
|
||||||
|
@ -199,5 +199,19 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
appConfig.Save(stream);
|
appConfig.Save(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CommonCompilerOptions GetLanguageSpecificCompilerOptions(this ProjectContext context, NuGetFramework framework, string configurationName)
|
||||||
|
{
|
||||||
|
var baseOption = context.ProjectFile.GetCompilerOptions(framework, configurationName);
|
||||||
|
|
||||||
|
IReadOnlyList<string> defaultSuppresses;
|
||||||
|
var compilerName = context.ProjectFile.CompilerName ?? "csc";
|
||||||
|
if (DefaultCompilerWarningSuppresses.Suppresses.TryGetValue(compilerName, out defaultSuppresses))
|
||||||
|
{
|
||||||
|
baseOption.SuppressWarnings = (baseOption.SuppressWarnings ?? Enumerable.Empty<string>()).Concat(defaultSuppresses).Distinct();
|
||||||
|
}
|
||||||
|
|
||||||
|
return baseOption;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.DotNet.ProjectModel.Server.Helpers;
|
using Microsoft.DotNet.ProjectModel.Server.Helpers;
|
||||||
using Microsoft.DotNet.ProjectModel.Server.Models;
|
using Microsoft.DotNet.ProjectModel.Server.Models;
|
||||||
|
using Microsoft.DotNet.Cli.Compiler.Common;
|
||||||
using NuGet.Frameworks;
|
using NuGet.Frameworks;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.ProjectModel.Server
|
namespace Microsoft.DotNet.ProjectModel.Server
|
||||||
|
@ -62,7 +63,7 @@ namespace Microsoft.DotNet.ProjectModel.Server
|
||||||
snapshot.RootDependency = context.ProjectFile.Name;
|
snapshot.RootDependency = context.ProjectFile.Name;
|
||||||
snapshot.TargetFramework = context.TargetFramework;
|
snapshot.TargetFramework = context.TargetFramework;
|
||||||
snapshot.SourceFiles = allSourceFiles.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(path => path).ToList();
|
snapshot.SourceFiles = allSourceFiles.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(path => path).ToList();
|
||||||
snapshot.CompilerOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration);
|
snapshot.CompilerOptions = context.GetLanguageSpecificCompilerOptions(context.TargetFramework, configuration);
|
||||||
snapshot.ProjectReferences = allProjectReferences.OrderBy(reference => reference.Name).ToList();
|
snapshot.ProjectReferences = allProjectReferences.OrderBy(reference => reference.Name).ToList();
|
||||||
snapshot.FileReferences = allFileReferences.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(path => path).ToList();
|
snapshot.FileReferences = allFileReferences.Distinct(StringComparer.OrdinalIgnoreCase).OrderBy(path => path).ToList();
|
||||||
snapshot.DependencyDiagnostics = allDependencyDiagnostics;
|
snapshot.DependencyDiagnostics = allDependencyDiagnostics;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"System.Threading.ThreadPool": "4.0.10-beta-23704",
|
"System.Threading.ThreadPool": "4.0.10-beta-23704",
|
||||||
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23704",
|
"System.Runtime.Serialization.Primitives": "4.1.0-rc2-23704",
|
||||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||||
|
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
|
||||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||||
"type": "build",
|
"type": "build",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
|
|
|
@ -12,7 +12,7 @@ using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.CSharp;
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
using Microsoft.CodeAnalysis.Host.Mef;
|
using Microsoft.CodeAnalysis.Host.Mef;
|
||||||
using Microsoft.CodeAnalysis.Text;
|
using Microsoft.CodeAnalysis.Text;
|
||||||
using Microsoft.DotNet.ProjectModel;
|
using Microsoft.DotNet.Cli.Compiler.Common;
|
||||||
using NuGet.Frameworks;
|
using NuGet.Frameworks;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.ProjectModel.Workspaces
|
namespace Microsoft.DotNet.ProjectModel.Workspaces
|
||||||
|
@ -68,7 +68,7 @@ namespace Microsoft.DotNet.ProjectModel.Workspaces
|
||||||
// TODO: ctor argument?
|
// TODO: ctor argument?
|
||||||
var configuration = "Debug";
|
var configuration = "Debug";
|
||||||
|
|
||||||
var compilationOptions = project.ProjectFile.GetCompilerOptions(project.TargetFramework, configuration);
|
var compilationOptions = project.GetLanguageSpecificCompilerOptions(project.TargetFramework, configuration);
|
||||||
|
|
||||||
var compilationSettings = ToCompilationSettings(compilationOptions, project.TargetFramework, project.ProjectFile.ProjectDirectory);
|
var compilationSettings = ToCompilationSettings(compilationOptions, project.TargetFramework, project.ProjectFile.ProjectDirectory);
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ namespace Microsoft.DotNet.ProjectModel.Workspaces
|
||||||
_cache[path] = assemblyMetadata;
|
_cache[path] = assemblyMetadata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return assemblyMetadata.GetReference();
|
return assemblyMetadata.GetReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,13 +146,8 @@ namespace Microsoft.DotNet.ProjectModel.Workspaces
|
||||||
{
|
{
|
||||||
var options = GetCompilationOptions(compilerOptions, projectDirectory);
|
var options = GetCompilationOptions(compilerOptions, projectDirectory);
|
||||||
|
|
||||||
// Disable 1702 until roslyn turns this off by default
|
options = options.WithSpecificDiagnosticOptions(compilerOptions.SuppressWarnings.ToDictionary(
|
||||||
options = options.WithSpecificDiagnosticOptions(new Dictionary<string, ReportDiagnostic>
|
suppress => suppress, _ => ReportDiagnostic.Suppress));
|
||||||
{
|
|
||||||
{ "CS1701", ReportDiagnostic.Suppress }, // Binding redirects
|
|
||||||
{ "CS1702", ReportDiagnostic.Suppress },
|
|
||||||
{ "CS1705", ReportDiagnostic.Suppress }
|
|
||||||
});
|
|
||||||
|
|
||||||
AssemblyIdentityComparer assemblyIdentityComparer =
|
AssemblyIdentityComparer assemblyIdentityComparer =
|
||||||
targetFramework.IsDesktop() ?
|
targetFramework.IsDesktop() ?
|
||||||
|
@ -235,4 +230,4 @@ namespace Microsoft.DotNet.ProjectModel.Workspaces
|
||||||
public CSharpCompilationOptions CompilationOptions { get; set; }
|
public CSharpCompilationOptions CompilationOptions { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
"compilationOptions": {
|
"compilationOptions": {
|
||||||
"keyFile": "../../tools/Key.snk"
|
"keyFile": "../../tools/Key.snk"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NETStandard.Library": "1.0.0-rc2-23704",
|
"NETStandard.Library": "1.0.0-rc2-23704",
|
||||||
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
"Microsoft.DotNet.ProjectModel": "1.0.0-*",
|
||||||
"Microsoft.CodeAnalysis.CSharp.Workspaces": "1.2.0-beta1-20160108-01"
|
"Microsoft.DotNet.Compiler.Common": "1.0.0-*",
|
||||||
},
|
"Microsoft.CodeAnalysis.CSharp.Workspaces": "1.2.0-beta1-20160108-01"
|
||||||
"frameworks": {
|
},
|
||||||
"dnxcore50": {
|
"frameworks": {
|
||||||
"imports": "portable-net45+win8"
|
"dnxcore50": {
|
||||||
}
|
"imports": "portable-net45+win8"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
|
|
@ -124,10 +124,6 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc
|
||||||
? "-debug:full"
|
? "-debug:full"
|
||||||
: "-debug:portable");
|
: "-debug:portable");
|
||||||
|
|
||||||
args.Add("-nowarn:CS1701");
|
|
||||||
args.Add("-nowarn:CS1702");
|
|
||||||
args.Add("-nowarn:CS1705");
|
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
// used in incremental compilation for the key file
|
// used in incremental compilation for the key file
|
||||||
public static CommonCompilerOptions ResolveCompilationOptions(ProjectContext context, string configuration)
|
public static CommonCompilerOptions ResolveCompilationOptions(ProjectContext context, string configuration)
|
||||||
{
|
{
|
||||||
var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration);
|
var compilationOptions = context.GetLanguageSpecificCompilerOptions(context.TargetFramework, configuration);
|
||||||
|
|
||||||
// Path to strong naming key in environment variable overrides path in project.json
|
// Path to strong naming key in environment variable overrides path in project.json
|
||||||
var environmentKeyFile = Environment.GetEnvironmentVariable(EnvironmentNames.StrongNameKeyFile);
|
var environmentKeyFile = Environment.GetEnvironmentVariable(EnvironmentNames.StrongNameKeyFile);
|
||||||
|
|
|
@ -374,9 +374,6 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
.Execute();
|
.Execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void CopyExport(string outputPath, LibraryExport export)
|
private static void CopyExport(string outputPath, LibraryExport export)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue