public static CompilerOptions Combine(params CompilerOptions[] options) { var result = new CompilerOptions(); 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.DebugSymbols != null) { result.DebugSymbols = option.DebugSymbols; } 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; } } return result; }
private void BuildTargetFrameworksAndConfigurations(JObject rawProject) { // Get the shared compilationOptions _defaultCompilerOptions = GetCompilationOptions(rawProject) ?? _emptyOptions; _defaultTargetFrameworkConfiguration = new TargetFrameworkInformation { Dependencies = new List <Library>() }; // Add default configurations _configurations["Debug"] = new CompilerOptions { DebugSymbols = "full", Defines = new[] { "DEBUG", "TRACE" }, Optimize = false }; _configurations["Release"] = new CompilerOptions { DebugSymbols = "pdbOnly", Defines = new[] { "RELEASE", "TRACE" }, Optimize = true }; // The configuration node has things like debug/release compiler settings /* * { * "configurations": { * "Debug": { * }, * "Release": { * } * } * } */ var configurations = rawProject["configurations"] as JObject; if (configurations != null) { foreach (var configuration in configurations) { var compilerOptions = GetCompilationOptions(configuration.Value); // Only use this as a configuration if it's not a target framework _configurations[configuration.Key] = compilerOptions; } } // The frameworks node is where target frameworks go /* * { * "frameworks": { * "net45": { * }, * "k10": { * } * } * } */ var frameworks = rawProject["frameworks"] as JObject; if (frameworks != null) { foreach (var framework in frameworks) { BuildTargetFrameworkNode(framework); } } }
private void BuildTargetFrameworksAndConfigurations(JsonObject projectJsonObject, ICollection<ICompilationMessage> diagnostics) { // Get the shared compilationOptions _defaultCompilerOptions = GetCompilationOptions(projectJsonObject) ?? new CompilerOptions(); _defaultTargetFrameworkConfiguration = new TargetFrameworkInformation { Dependencies = new List<LibraryDependency>() }; // Add default configurations _configurations["Debug"] = new CompilerOptions { Defines = new[] { "DEBUG", "TRACE" }, Optimize = false }; _configurations["Release"] = new CompilerOptions { Defines = new[] { "RELEASE", "TRACE" }, Optimize = true }; // The configuration node has things like debug/release compiler settings /* { "configurations": { "Debug": { }, "Release": { } } } */ var configurations = projectJsonObject.ValueAsJsonObject("configurations"); if (configurations != null) { foreach (var configKey in configurations.Keys) { var compilerOptions = GetCompilationOptions(configurations.ValueAsJsonObject(configKey)); // Only use this as a configuration if it's not a target framework _configurations[configKey] = compilerOptions; } } // The frameworks node is where target frameworks go /* { "frameworks": { "net45": { }, "k10": { } } } */ var frameworks = projectJsonObject.ValueAsJsonObject("frameworks"); if (frameworks != null) { foreach (var frameworkKey in frameworks.Keys) { try { var frameworkToken = frameworks.ValueAsJsonObject(frameworkKey); var success = BuildTargetFrameworkNode(frameworkKey, frameworkToken); if (!success) { diagnostics?.Add( new FileFormatMessage( $"\"{frameworkKey}\" is an unsupported framework", ProjectFilePath, CompilationMessageSeverity.Error, frameworkToken)); } } catch (Exception ex) { throw FileFormatException.Create(ex, frameworks.Value(frameworkKey), ProjectFilePath); } } } }
private void BuildTargetFrameworksAndConfigurations(JObject rawProject) { // Get the shared compilationOptions _defaultCompilerOptions = GetCompilationOptions(rawProject) ?? _emptyOptions; _defaultTargetFrameworkConfiguration = new TargetFrameworkInformation { Dependencies = new List<LibraryDependency>() }; // Add default configurations _configurations["Debug"] = new CompilerOptions { Defines = new[] { "DEBUG", "TRACE" }, Optimize = false }; _configurations["Release"] = new CompilerOptions { Defines = new[] { "RELEASE", "TRACE" }, Optimize = true }; // The configuration node has things like debug/release compiler settings /* { "configurations": { "Debug": { }, "Release": { } } } */ var configurations = rawProject["configurations"] as JObject; if (configurations != null) { foreach (var configuration in configurations) { var compilerOptions = GetCompilationOptions(configuration.Value); // Only use this as a configuration if it's not a target framework _configurations[configuration.Key] = compilerOptions; } } // The frameworks node is where target frameworks go /* { "frameworks": { "net45": { }, "k10": { } } } */ var frameworks = rawProject["frameworks"] as JObject; if (frameworks != null) { foreach (var framework in frameworks) { try { BuildTargetFrameworkNode(framework); } catch (Exception ex) { throw FileFormatException.Create(ex, framework.Value, ProjectFilePath); } } } }