forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CompilationOptionsConverter.cs
34 lines (31 loc) · 1.55 KB
/
CompilationOptionsConverter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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;
using Microsoft.Build.Framework;
using Microsoft.Extensions.DependencyModel;
namespace Microsoft.NET.Build.Tasks
{
internal static class CompilationOptionsConverter
{
public static CompilationOptions ConvertFrom(ITaskItem compilerOptionsItem)
{
if (compilerOptionsItem == null)
{
return null;
}
return new CompilationOptions(
compilerOptionsItem.GetMetadata("DefineConstants")?.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries),
compilerOptionsItem.GetMetadata("LangVersion"),
compilerOptionsItem.GetMetadata("PlatformTarget"),
compilerOptionsItem.GetBooleanMetadata("AllowUnsafeBlocks"),
compilerOptionsItem.GetBooleanMetadata("TreatWarningsAsErrors"),
compilerOptionsItem.GetBooleanMetadata("Optimize"),
compilerOptionsItem.GetMetadata("AssemblyOriginatorKeyFile"),
compilerOptionsItem.GetBooleanMetadata("DelaySign"),
compilerOptionsItem.GetBooleanMetadata("PublicSign"),
compilerOptionsItem.GetMetadata("DebugType"),
"exe".Equals(compilerOptionsItem.GetMetadata("OutputType"), StringComparison.OrdinalIgnoreCase),
compilerOptionsItem.GetBooleanMetadata("GenerateDocumentationFile"));
}
}
}