private static CSharpCompilationOptions GetCompilationOptions(CommonCompilerOptions compilerOptions, string projectDirectory) { var outputKind = compilerOptions.EmitEntryPoint.GetValueOrDefault() ? OutputKind.ConsoleApplication : OutputKind.DynamicallyLinkedLibrary; var options = new CSharpCompilationOptions(outputKind); string platformValue = compilerOptions.Platform; bool allowUnsafe = compilerOptions.AllowUnsafe ?? false; bool optimize = compilerOptions.Optimize ?? false; bool warningsAsErrors = compilerOptions.WarningsAsErrors ?? false; Platform platform; if (!Enum.TryParse(value: platformValue, ignoreCase: true, result: out platform)) { platform = Platform.AnyCpu; } options = options .WithAllowUnsafe(allowUnsafe) .WithPlatform(platform) .WithGeneralDiagnosticOption(warningsAsErrors ? ReportDiagnostic.Error : ReportDiagnostic.Default) .WithOptimizationLevel(optimize ? OptimizationLevel.Release : OptimizationLevel.Debug); return AddSigningOptions(options, compilerOptions, projectDirectory); }
public DependencyContext Build(CommonCompilerOptions compilerOptions, IEnumerable<LibraryExport> compilationExports, IEnumerable<LibraryExport> runtimeExports, bool portable, NuGetFramework target, string runtime) { if (compilationExports == null) { compilationExports = Enumerable.Empty<LibraryExport>(); } var dependencyLookup = compilationExports .Concat(runtimeExports) .Select(export => export.Library.Identity) .Distinct() .Select(identity => new Dependency(identity.Name, identity.Version.ToString())) .ToDictionary(dependency => dependency.Name); var compilationOptions = compilerOptions != null ? GetCompilationOptions(compilerOptions) : CompilationOptions.Default; var runtimeSignature = GenerateRuntimeSignature(runtimeExports); return new DependencyContext( new TargetInfo(target.DotNetFrameworkName, runtime, runtimeSignature, portable), compilationOptions, GetLibraries(compilationExports, dependencyLookup, runtime: false).Cast<CompilationLibrary>(), GetLibraries(runtimeExports, dependencyLookup, runtime: true).Cast<RuntimeLibrary>(), new RuntimeFallbacks[] {}); }
public void SimpleSerialize() { var options = new CommonCompilerOptions(); options.AdditionalArguments = new[] { "-highentropyva+" }; var args = options.SerializeToArgs(); Assert.Equal(new [] { "--additional-argument:-highentropyva+" }, args); }
public Executable(ProjectContext context, OutputPaths outputPaths, LibraryExporter exporter, string configuration) { _context = context; _outputPaths = outputPaths; _runtimeOutputPath = outputPaths.RuntimeOutputPath; _intermediateOutputPath = outputPaths.IntermediateOutputDirectoryPath; _exporter = exporter; _compilerOptions = _context.ProjectFile.GetCompilerOptions(_context.TargetFramework, configuration); }
public static List<CultureResgenIO> GetCultureResources(Project project, string outputPath, CommonCompilerOptions compilationOptions) { if (compilationOptions.EmbedInclude == null) { return GetCultureResources(project, outputPath); } return GetCultureResourcesFromIncludeEntries(project, outputPath, compilationOptions); }
public static IEnumerable<string> GetCompilationSources(ProjectContext project, CommonCompilerOptions compilerOptions) { if (compilerOptions.CompileInclude == null) { return project.ProjectFile.Files.SourceFiles; } var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilerOptions.CompileInclude, "/", diagnostics: null); return includeFiles.Select(f => f.SourcePath); }
public void WithSpaces() { var options = new CommonCompilerOptions(); options.AdditionalArguments = new[] { "-highentropyva+", "-addmodule:\"path with spaces\";\"after semicolon\"" }; var args = options.SerializeToArgs(); Assert.Equal(new [] { "--additional-argument:-highentropyva+", "--additional-argument:-addmodule:\"path with spaces\";\"after semicolon\"" }, args); }
private static void EqualAfterDeserialize(IEnumerable<string> args, CommonCompilerOptions original) { CommonCompilerOptions newOptions = null; ArgumentSyntax.Parse(args, syntax => { newOptions = CommonCompilerOptionsExtensions.Parse(syntax); }); Assert.Equal(original, newOptions); }
private static CompilationOptions GetCompilationOptions(CommonCompilerOptions compilerOptions) { return new CompilationOptions(compilerOptions.Defines, compilerOptions.LanguageVersion, compilerOptions.Platform, compilerOptions.AllowUnsafe, compilerOptions.WarningsAsErrors, compilerOptions.Optimize, compilerOptions.KeyFile, compilerOptions.DelaySign, compilerOptions.PublicSign, compilerOptions.EmitEntryPoint); }
public DependencyContext Build(CommonCompilerOptions compilerOptions = null, IEnumerable<LibraryExport> compilationExports = null, IEnumerable<LibraryExport> runtimeExports = null, bool portable = false, NuGetFramework target = null, string runtime = null) { _defaultFramework = NuGetFramework.Parse("net451"); return new DependencyContextBuilder(_referenceAssembliesPath).Build( compilerOptions, compilationExports ?? new LibraryExport[] { }, runtimeExports ?? new LibraryExport[] {}, portable, target ?? _defaultFramework, runtime ?? string.Empty); }
// used in incremental compilation public static List<NonCultureResgenIO> GetNonCultureResourcesFromIncludeEntries( Project project, string intermediateOutputPath, CommonCompilerOptions compilationOptions) { var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilationOptions.EmbedInclude, "/", diagnostics: null); return (from resourceFile in includeFiles let inputFile = resourceFile.SourcePath where string.IsNullOrEmpty(ResourceUtility.GetResourceCultureName(inputFile)) let target = resourceFile.IsCustomTarget ? resourceFile.TargetPath : null let metadataName = GetResourceFileMetadataName(project, resourceFile.SourcePath, target) let outputFile = ResourceUtility.IsResxFile(inputFile) ? Path.Combine(intermediateOutputPath, metadataName) : null select new NonCultureResgenIO(inputFile, outputFile, metadataName) ).ToList(); }
public GivenThatIWantToLoadAProjectJsonFile() { var json = new JObject(); _emptyProject = GetProject(json); _jsonCompilationOptions = new JObject(); _jsonCompilationOptions.Add("define", new JArray(_someDefines)); _jsonCompilationOptions.Add("nowarn", new JArray(_noWarnings)); _jsonCompilationOptions.Add("additionalArguments", new JArray(_someAdditionalArguments)); _jsonCompilationOptions.Add("languageVersion", SomeLanguageVersion); _jsonCompilationOptions.Add("outputName", SomeOutputName); _jsonCompilationOptions.Add("compilerName", SomeCompilerName); _jsonCompilationOptions.Add("platform", SomePlatform); _jsonCompilationOptions.Add("keyFile", SomeKeyFile); _jsonCompilationOptions.Add("debugType", SomeDebugType); _jsonCompilationOptions.Add("allowUnsafe", true); _jsonCompilationOptions.Add("warningsAsErrors", true); _jsonCompilationOptions.Add("optimize", true); _jsonCompilationOptions.Add("delaySign", true); _jsonCompilationOptions.Add("publicSign", true); _jsonCompilationOptions.Add("emitEntryPoint", true); _jsonCompilationOptions.Add("xmlDoc", true); _jsonCompilationOptions.Add("preserveCompilationContext", true); _commonCompilerOptions = new CommonCompilerOptions { Defines = _someDefines, SuppressWarnings = _noWarnings, AdditionalArguments = _someAdditionalArguments, LanguageVersion = SomeLanguageVersion, OutputName = SomeOutputName, CompilerName = SomeCompilerName, Platform = SomePlatform, KeyFile = SomeKeyFile, DebugType = SomeDebugType, AllowUnsafe = true, WarningsAsErrors = true, Optimize = true, DelaySign = true, PublicSign = true, EmitEntryPoint = true, GenerateXmlDocumentation = true, PreserveCompilationContext = true }; }
public static DependencyContext Build(CommonCompilerOptions compilerOptions, LibraryExporter libraryExporter, string configuration, NuGetFramework target, string runtime) { var dependencies = libraryExporter.GetAllExports().Where(export => export.Library.Framework.Equals(target)).ToList(); // Sometimes we have package and reference assembly with the same name (System.Runtime for example) thats why we // deduplicating them prefering reference assembly var dependencyLookup = dependencies .OrderBy(export => export.Library.Identity.Type == LibraryType.ReferenceAssembly) .GroupBy(export => export.Library.Identity.Name) .Select(exports => exports.First()) .Select(export => new Dependency(export.Library.Identity.Name, export.Library.Identity.Version.ToString())) .ToDictionary(dependency => dependency.Name); return new DependencyContext(target.DotNetFrameworkName, runtime, GetCompilationOptions(compilerOptions), GetLibraries(dependencies, dependencyLookup, target, configuration, runtime: false).Cast<CompilationLibrary>().ToArray(), GetLibraries(dependencies, dependencyLookup, target, configuration, runtime: true).Cast<RuntimeLibrary>().ToArray()); }
protected static bool AddNonCultureResources( Project project, List<string> compilerArgs, string intermediateOutputPath, CommonCompilerOptions compilationOptions) { List<CompilerUtil.NonCultureResgenIO> resgenFiles = null; if (compilationOptions.EmbedInclude == null) { resgenFiles = CompilerUtil.GetNonCultureResources(project, intermediateOutputPath); } else { resgenFiles = CompilerUtil.GetNonCultureResourcesFromIncludeEntries(project, intermediateOutputPath, compilationOptions); } foreach (var resgenFile in resgenFiles) { if (ResourceUtility.IsResxFile(resgenFile.InputFile)) { var result = Resgen.ResgenCommand.Run( new[] { resgenFile.InputFile }, culture: null, outputFile: resgenFile.OutputFile, version: project.Version.Version.ToString(), compilationReferences: null); if (result != 0) { return false; } compilerArgs.Add($"--resource:\"{resgenFile.OutputFile}\",{Path.GetFileName(resgenFile.MetadataName)}"); } else { compilerArgs.Add($"--resource:\"{resgenFile.InputFile}\",{Path.GetFileName(resgenFile.MetadataName)}"); } } return true; }
private static CSharpCompilationOptions AddSigningOptions(CSharpCompilationOptions options, CommonCompilerOptions compilerOptions, string projectDirectory) { var useOssSigning = compilerOptions.PublicSign == true; var keyFile = compilerOptions.KeyFile; if (!string.IsNullOrEmpty(keyFile)) { keyFile = Path.GetFullPath(Path.Combine(projectDirectory, compilerOptions.KeyFile)); if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || useOssSigning) { return options.WithCryptoPublicKey( SnkUtils.ExtractPublicKey(File.ReadAllBytes(keyFile))); } options = options.WithCryptoKeyFile(keyFile); return options.WithDelaySign(compilerOptions.DelaySign); } return options; }
private static IEnumerable<string> TranslateCommonOptions(CommonCompilerOptions options, string outputName) { List<string> commonArgs = new List<string>(); if (options.Defines != null) { commonArgs.AddRange(options.Defines.Select(def => $"-d:{def}")); } if (options.SuppressWarnings != null) { } // Additional arguments are added verbatim if (options.AdditionalArguments != null) { commonArgs.AddRange(options.AdditionalArguments); } if (options.LanguageVersion != null) { } if (options.Platform != null) { commonArgs.Add($"--platform:{options.Platform}"); } if (options.AllowUnsafe == true) { } if (options.WarningsAsErrors == true) { commonArgs.Add("--warnaserror"); } if (options.Optimize == true) { commonArgs.Add("--optimize"); } if (options.KeyFile != null) { } if (options.DelaySign == true) { } if (options.PublicSign == true) { } if (options.GenerateXmlDocumentation == true) { commonArgs.Add($"--doc:{Path.ChangeExtension(outputName, "xml")}"); } if (options.EmitEntryPoint != true) { commonArgs.Add("--target:library"); } else { commonArgs.Add("--target:exe"); //HACK we need default.win32manifest for exe if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var win32manifestPath = Path.Combine(AppContext.BaseDirectory, "default.win32manifest"); commonArgs.Add($"--win32manifest:{win32manifestPath}"); } } return commonArgs; }
public static CommonCompilerOptions Combine(params CommonCompilerOptions[] options) { var result = new CommonCompilerOptions(); foreach (var option in options) { // Skip null options if (option == null) { continue; } // Defines, suppressions, and additional arguments are always combined result.Defines = Combine(option.Defines, result.Defines); result.SuppressWarnings = Combine(option.SuppressWarnings, result.SuppressWarnings); result.AdditionalArguments = Combine(option.AdditionalArguments, result.AdditionalArguments); if (option.LanguageVersion != null) { result.LanguageVersion = option.LanguageVersion; } if (option.Platform != null) { result.Platform = option.Platform; } if (option.AllowUnsafe != null) { result.AllowUnsafe = option.AllowUnsafe; } if (option.WarningsAsErrors != null) { result.WarningsAsErrors = option.WarningsAsErrors; } if (option.Optimize != null) { result.Optimize = option.Optimize; } if (option.KeyFile != null) { result.KeyFile = option.KeyFile; } if (option.DelaySign != null) { result.DelaySign = option.DelaySign; } if (option.PublicSign != null) { result.PublicSign = option.PublicSign; } if (option.DebugType != null) { result.DebugType = option.DebugType; } if (option.EmitEntryPoint != null) { result.EmitEntryPoint = option.EmitEntryPoint; } if (option.PreserveCompilationContext != null) { result.PreserveCompilationContext = option.PreserveCompilationContext; } if (option.GenerateXmlDocumentation != null) { result.GenerateXmlDocumentation = option.GenerateXmlDocumentation; } if (option.OutputName != null) { result.OutputName = option.OutputName; } if (option.CompileInclude != null) { result.CompileInclude = option.CompileInclude; } if (option.EmbedInclude != null) { result.EmbedInclude = option.EmbedInclude; } if (option.CopyToOutputInclude != null) { result.CopyToOutputInclude = option.CopyToOutputInclude; } // compilerName set in the root cannot be overriden. if (result.CompilerName == null) { result.CompilerName = option.CompilerName; } } return result; }
public static CommonCompilerOptions Combine(params CommonCompilerOptions[] options) { var result = new CommonCompilerOptions(); foreach (var option in options) { // Skip null options if (option == null) { continue; } // Defines, suppressions, and additional arguments are always combined result.Defines = Combine(option.Defines, result.Defines); result.SuppressWarnings = Combine(option.SuppressWarnings, result.SuppressWarnings); result.AdditionalArguments = Combine(option.AdditionalArguments, result.AdditionalArguments); if (option.LanguageVersion != null) { result.LanguageVersion = option.LanguageVersion; } if (option.Platform != null) { result.Platform = option.Platform; } if (option.AllowUnsafe != null) { result.AllowUnsafe = option.AllowUnsafe; } if (option.WarningsAsErrors != null) { result.WarningsAsErrors = option.WarningsAsErrors; } if (option.Optimize != null) { result.Optimize = option.Optimize; } if (option.KeyFile != null) { result.KeyFile = option.KeyFile; } if (option.DelaySign != null) { result.DelaySign = option.DelaySign; } if (option.PublicSign != null) { result.PublicSign = option.PublicSign; } if (option.EmitEntryPoint != null) { result.EmitEntryPoint = option.EmitEntryPoint; } if (option.PreserveCompilationContext != null) { result.PreserveCompilationContext = option.PreserveCompilationContext; } if (option.GenerateXmlDocumentation != null) { result.GenerateXmlDocumentation = option.GenerateXmlDocumentation; } } return(result); }
private static IEnumerable<string> TranslateCommonOptions(CommonCompilerOptions options) { List<string> commonArgs = new List<string>(); if (options.Defines != null) { commonArgs.AddRange(options.Defines.Select(def => $"-d:{def}")); } if (options.Platform != null) { commonArgs.Add($"--platform:{options.Platform}"); } if (options.WarningsAsErrors == true) { commonArgs.Add("--warnaserror"); } if (options.Optimize == true) { commonArgs.Add("--optimize"); } if (options.EmitEntryPoint != true) { commonArgs.Add("--target:library"); } else { commonArgs.Add("--target:exe"); //HACK we need default.win32manifest for exe if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var win32manifestPath = Path.Combine(AppContext.BaseDirectory, "default.win32manifest"); commonArgs.Add($"--win32manifest:\"{win32manifestPath}\""); } } return commonArgs; }
public static List<CultureResgenIO> GetCultureResourcesFromIncludeEntries(Project project, string outputPath, CommonCompilerOptions compilationOptions) { var includeFiles = IncludeFilesResolver.GetIncludeFiles(compilationOptions.EmbedInclude, "/", diagnostics: null); return (from resourceFileGroup in includeFiles .GroupBy(resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.SourcePath)) let culture = resourceFileGroup.Key where !string.IsNullOrEmpty(culture) let inputFileToMetadata = resourceFileGroup.ToDictionary( r => r.SourcePath, r => GetResourceFileMetadataName(project, r.SourcePath, r.IsCustomTarget ? r.TargetPath : null)) let resourceOutputPath = Path.Combine(outputPath, culture) let outputFile = Path.Combine(resourceOutputPath, project.Name + ".resources.dll") select new CultureResgenIO(culture, inputFileToMetadata, outputFile)) .ToList(); }
private static int RenamePublishedHost(ProjectContext context, string outputPath, CommonCompilerOptions compilationOptions) { if (context.TargetFramework.IsDesktop()) { return 0; } var publishedHostFile = ResolvePublishedHostFile(outputPath); if (publishedHostFile == null) { Reporter.Output.WriteLine($"publish: warning: host executable not available in dependencies, using host for current platform"); // TODO should this be an error? CoreHost.CopyTo(outputPath, compilationOptions.OutputName + Constants.ExeSuffix); return 0; } var publishedHostExtension = Path.GetExtension(publishedHostFile); var renamedHostName = compilationOptions.OutputName + publishedHostExtension; var renamedHostFile = Path.Combine(outputPath, renamedHostName); try { Reporter.Verbose.WriteLine($"publish: renaming published host {publishedHostFile} to {renamedHostFile}"); File.Copy(publishedHostFile, renamedHostFile, true); File.Delete(publishedHostFile); } catch (Exception e) { Reporter.Error.WriteLine($"publish: Failed to rename {publishedHostFile} to {renamedHostFile}: {e.Message}"); return 1; } return 0; }
private static int PublishHost(ProjectContext context, string outputPath, CommonCompilerOptions compilationOptions) { if (context.TargetFramework.IsDesktop()) { return 0; } foreach (var binaryName in Constants.HostBinaryNames) { var hostBinaryPath = Path.Combine(AppContext.BaseDirectory, binaryName); if (!File.Exists(hostBinaryPath)) { Reporter.Error.WriteLine($"Cannot find {binaryName} in the dotnet directory.".Red()); return 1; } var outputBinaryName = binaryName.Equals(Constants.HostExecutableName) ? compilationOptions.OutputName + Constants.ExeSuffix : binaryName; var outputBinaryPath = Path.Combine(outputPath, outputBinaryName); File.Copy(hostBinaryPath, outputBinaryPath, overwrite: true); } return 0; }
private static CompilationSettings ToCompilationSettings(CommonCompilerOptions compilerOptions, NuGetFramework targetFramework, string projectDirectory) { var options = GetCompilationOptions(compilerOptions, projectDirectory); // Disable 1702 until roslyn turns this off by default options = options.WithSpecificDiagnosticOptions(new Dictionary<string, ReportDiagnostic> { { "CS1701", ReportDiagnostic.Suppress }, // Binding redirects { "CS1702", ReportDiagnostic.Suppress }, { "CS1705", ReportDiagnostic.Suppress } }); AssemblyIdentityComparer assemblyIdentityComparer = targetFramework.IsDesktop() ? DesktopAssemblyIdentityComparer.Default : null; options = options.WithAssemblyIdentityComparer(assemblyIdentityComparer); LanguageVersion languageVersion; if (!Enum.TryParse<LanguageVersion>(value: compilerOptions.LanguageVersion, ignoreCase: true, result: out languageVersion)) { languageVersion = LanguageVersion.CSharp6; } var settings = new CompilationSettings { LanguageVersion = languageVersion, Defines = compilerOptions.Defines ?? Enumerable.Empty<string>(), CompilationOptions = options }; return settings; }
protected static bool GenerateCultureResourceAssemblies( Project project, List<LibraryExport> dependencies, string outputPath, CommonCompilerOptions compilationOptions) { var referencePaths = CompilerUtil.GetReferencePathsForCultureResgen(dependencies); List<CompilerUtil.CultureResgenIO> cultureResgenFiles = null; if (compilationOptions.EmbedInclude == null) { cultureResgenFiles = CompilerUtil.GetCultureResources(project, outputPath); } else { cultureResgenFiles = CompilerUtil.GetCultureResourcesFromIncludeEntries(project, outputPath, compilationOptions); } foreach (var resgenFile in cultureResgenFiles) { var resourceOutputPath = Path.GetDirectoryName(resgenFile.OutputFile); if (!Directory.Exists(resourceOutputPath)) { Directory.CreateDirectory(resourceOutputPath); } var result = Resgen.ResgenCommand.Run( resgenFile.InputFileToMetadata.Select(fileToMetadata => $"{fileToMetadata.Key},{fileToMetadata.Value}"), resgenFile.Culture, resgenFile.OutputFile, project.Version.Version.ToString(), referencePaths); if (result != 0) { return false; } } return true; }
private static void AddNonCultureResources( ProjectContext project, string intermediaryOutputPath, List<string> inputs, IList<string> outputs, CommonCompilerOptions compilationOptions) { List<CompilerUtil.NonCultureResgenIO> resources = null; if (compilationOptions.EmbedInclude == null) { resources = CompilerUtil.GetNonCultureResources(project.ProjectFile, intermediaryOutputPath); } else { resources = CompilerUtil.GetNonCultureResourcesFromIncludeEntries(project.ProjectFile, intermediaryOutputPath, compilationOptions); } foreach (var resourceIO in resources) { inputs.Add(resourceIO.InputFile); if (resourceIO.OutputFile != null) { outputs.Add(resourceIO.OutputFile); } } }
private static IEnumerable<string> TranslateCommonOptions(CommonCompilerOptions options, string outputName) { List<string> commonArgs = new List<string>(); if (options.Defines != null) { commonArgs.AddRange(options.Defines.Select(def => $"-d:{def}")); } if (options.SuppressWarnings != null) { commonArgs.AddRange(options.SuppressWarnings.Select(w => $"-nowarn:{w}")); } // Additional arguments are added verbatim if (options.AdditionalArguments != null) { commonArgs.AddRange(options.AdditionalArguments); } if (options.LanguageVersion != null) { commonArgs.Add($"-langversion:{GetLanguageVersion(options.LanguageVersion)}"); } if (options.Platform != null) { commonArgs.Add($"-platform:{options.Platform}"); } if (options.AllowUnsafe == true) { commonArgs.Add("-unsafe"); } if (options.WarningsAsErrors == true) { commonArgs.Add("-warnaserror"); } if (options.Optimize == true) { commonArgs.Add("-optimize"); } if (options.KeyFile != null) { commonArgs.Add($"-keyfile:\"{options.KeyFile}\""); // If we're not on Windows, full signing isn't supported, so we'll // public sign, unless the public sign switch has explicitly been // set to false if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && options.PublicSign == null) { commonArgs.Add("-publicsign"); } } if (options.DelaySign == true) { commonArgs.Add("-delaysign"); } if (options.PublicSign == true) { commonArgs.Add("-publicsign"); } if (options.GenerateXmlDocumentation == true) { commonArgs.Add($"-doc:{Path.ChangeExtension(outputName, "xml")}"); } if (options.EmitEntryPoint != true) { commonArgs.Add("-t:library"); } return commonArgs; }
private static void AddCultureResources( ProjectContext project, string outputPath, List<string> inputs, List<string> outputs, CommonCompilerOptions compilationOptions) { List<CompilerUtil.CultureResgenIO> resources = null; if (compilationOptions.EmbedInclude == null) { resources = CompilerUtil.GetCultureResources(project.ProjectFile, outputPath); } else { resources = CompilerUtil.GetCultureResourcesFromIncludeEntries(project.ProjectFile, outputPath, compilationOptions); } foreach (var cultureResourceIO in resources) { inputs.AddRange(cultureResourceIO.InputFileToMetadata.Keys); if (cultureResourceIO.OutputFile != null) { outputs.Add(cultureResourceIO.OutputFile); } } }
public static CommonCompilerOptions Combine(params CommonCompilerOptions[] options) { var result = new CommonCompilerOptions(); foreach (var option in options) { // Skip null options if (option == null) { continue; } // Defines are always combined if (option.Defines != null) { var existing = result.Defines ?? Enumerable.Empty<string>(); result.Defines = existing.Concat(option.Defines).Distinct(); } if (option.LanguageVersion != null) { result.LanguageVersion = option.LanguageVersion; } if (option.Platform != null) { result.Platform = option.Platform; } if (option.AllowUnsafe != null) { result.AllowUnsafe = option.AllowUnsafe; } if (option.WarningsAsErrors != null) { result.WarningsAsErrors = option.WarningsAsErrors; } if (option.Optimize != null) { result.Optimize = option.Optimize; } if (option.KeyFile != null) { result.KeyFile = option.KeyFile; } if (option.DelaySign != null) { result.DelaySign = option.DelaySign; } if (option.PublicSign != null) { result.PublicSign = option.PublicSign; } if (option.EmitEntryPoint != null) { result.EmitEntryPoint = option.EmitEntryPoint; } } return result; }
public static CommonCompilerOptions Combine(params CommonCompilerOptions[] options) { var result = new CommonCompilerOptions(); foreach (var option in options) { // Skip null options if (option == null) { continue; } // Defines are always combined if (option.Defines != null) { var existing = result.Defines ?? Enumerable.Empty <string>(); result.Defines = existing.Concat(option.Defines).Distinct(); } if (option.LanguageVersion != null) { result.LanguageVersion = option.LanguageVersion; } if (option.Platform != null) { result.Platform = option.Platform; } if (option.AllowUnsafe != null) { result.AllowUnsafe = option.AllowUnsafe; } if (option.WarningsAsErrors != null) { result.WarningsAsErrors = option.WarningsAsErrors; } if (option.Optimize != null) { result.Optimize = option.Optimize; } if (option.KeyFile != null) { result.KeyFile = option.KeyFile; } if (option.DelaySign != null) { result.DelaySign = option.DelaySign; } if (option.PublicSign != null) { result.PublicSign = option.PublicSign; } if (option.EmitEntryPoint != null) { result.EmitEntryPoint = option.EmitEntryPoint; } if (option.PreserveCompilationContext != null) { result.PreserveCompilationContext = option.PreserveCompilationContext; } if (option.GenerateXmlDocumentation != null) { result.GenerateXmlDocumentation = option.GenerateXmlDocumentation; } } return(result); }