2015-12-10 13:06:33 -08:00
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
|
|
2016-01-04 12:49:13 -08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2015-12-10 13:06:33 -08:00
|
|
|
|
using Microsoft.DotNet.ProjectModel;
|
|
|
|
|
using NuGet.Frameworks;
|
|
|
|
|
|
2016-01-04 23:12:40 -08:00
|
|
|
|
namespace Microsoft.DotNet.Cli.Compiler.Common
|
2015-12-10 13:06:33 -08:00
|
|
|
|
{
|
2016-01-04 23:12:40 -08:00
|
|
|
|
public static class ProjectContextExtensions
|
2015-12-10 13:06:33 -08:00
|
|
|
|
{
|
|
|
|
|
public static string ProjectName(this ProjectContext context) => context.RootProject.Identity.Name;
|
|
|
|
|
|
2016-02-03 10:57:25 -08:00
|
|
|
|
public static string GetDisplayName(this ProjectContext context) => $"{context.RootProject.Identity.Name} ({context.TargetFramework})";
|
2016-01-20 14:56:29 -08:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2015-12-10 13:06:33 -08:00
|
|
|
|
}
|
|
|
|
|
}
|