From 2deb9d343a4abaa1dc2892da07a0211f50b080ca Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Wed, 2 Mar 2016 15:53:59 -0800 Subject: [PATCH] Plumbde through the option --- .../CommonCompilerOptionsExtensions.cs | 12 ++++++++++++ .../ProjectJsonWorkspace.cs | 6 ++++++ .../CommonCompilerOptions.cs | 8 ++++++++ .../DependencyContextBuilder.cs | 1 + src/Microsoft.DotNet.ProjectModel/ProjectReader.cs | 1 + .../DependencyContextJsonReader.cs | 3 ++- .../DependencyContextWriter.cs | 6 +++++- src/dotnet/commands/dotnet-compile-csc/Program.cs | 9 ++++++--- 8 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.DotNet.Compiler.Common/CommonCompilerOptionsExtensions.cs b/src/Microsoft.DotNet.Compiler.Common/CommonCompilerOptionsExtensions.cs index 9c711b9f4..3f2803a97 100644 --- a/src/Microsoft.DotNet.Compiler.Common/CommonCompilerOptionsExtensions.cs +++ b/src/Microsoft.DotNet.Compiler.Common/CommonCompilerOptionsExtensions.cs @@ -32,6 +32,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common internal static readonly OptionTemplate s_publicSignTemplate = new OptionTemplate("public-sign"); + internal static readonly OptionTemplate s_debugTypeTemplate = new OptionTemplate("debug-type"); + internal static readonly OptionTemplate s_emitEntryPointTemplate = new OptionTemplate("emit-entry-point"); internal static readonly OptionTemplate s_generateXmlDocumentation = new OptionTemplate("generate-xml-documentation"); @@ -44,6 +46,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common IReadOnlyList suppressWarnings = null; string languageVersion = null; string platform = null; + string debugType = null; bool? allowUnsafe = null; bool? warningsAsErrors = null; bool? optimize = null; @@ -62,6 +65,8 @@ namespace Microsoft.DotNet.Cli.Compiler.Common syntax.DefineOptionList(s_additionalArgumentsTemplate.LongName, ref additionalArguments, "Pass the additional argument directly to the compiler"); + syntax.DefineOption(s_debugTypeTemplate, ref debugType, "The type of PDB to emit: portable or full"); + syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion, "The version of the language used to compile"); @@ -104,6 +109,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common KeyFile = keyFile, DelaySign = delaySign, PublicSign = publicSign, + DebugType = debugType, EmitEntryPoint = emitEntryPoint, GenerateXmlDocumentation = generateXmlDocumentation, AdditionalArguments = additionalArguments @@ -115,6 +121,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common var defines = options.Defines; var suppressWarnings = options.SuppressWarnings; var languageVersion = options.LanguageVersion; + var debugType = options.DebugType; var platform = options.Platform; var allowUnsafe = options.AllowUnsafe; var warningsAsErrors = options.WarningsAsErrors; @@ -183,6 +190,11 @@ namespace Microsoft.DotNet.Cli.Compiler.Common args.Add(s_publicSignTemplate.ToLongArg(publicSign)); } + if (debugType != null) + { + args.Add(s_debugTypeTemplate.ToLongArg(debugType)); + } + if (emitEntryPoint != null) { args.Add(s_emitEntryPointTemplate.ToLongArg(emitEntryPoint)); diff --git a/src/Microsoft.DotNet.ProjectModel.Workspaces/ProjectJsonWorkspace.cs b/src/Microsoft.DotNet.ProjectModel.Workspaces/ProjectJsonWorkspace.cs index 9dbdedf8a..0c226bc1c 100644 --- a/src/Microsoft.DotNet.ProjectModel.Workspaces/ProjectJsonWorkspace.cs +++ b/src/Microsoft.DotNet.ProjectModel.Workspaces/ProjectJsonWorkspace.cs @@ -10,6 +10,7 @@ using System.Runtime.InteropServices; using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Emit; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Text; using Microsoft.DotNet.Cli.Compiler.Common; @@ -195,9 +196,14 @@ namespace Microsoft.DotNet.ProjectModel.Workspaces platform = Platform.AnyCpu; } + var debugType = StringComparer.OrdinalIgnoreCase.Equals(compilerOptions.DebugType, "full") + ? DebugInformationFormat.pdb + :DebugInformationFormat.Portable; + options = options .WithAllowUnsafe(allowUnsafe) .WithPlatform(platform) + .WithDebugInformationFormat(debugType) .WithGeneralDiagnosticOption(warningsAsErrors ? ReportDiagnostic.Error : ReportDiagnostic.Default) .WithOptimizationLevel(optimize ? OptimizationLevel.Release : OptimizationLevel.Debug); diff --git a/src/Microsoft.DotNet.ProjectModel/CommonCompilerOptions.cs b/src/Microsoft.DotNet.ProjectModel/CommonCompilerOptions.cs index 3e4e6216e..c417828ef 100644 --- a/src/Microsoft.DotNet.ProjectModel/CommonCompilerOptions.cs +++ b/src/Microsoft.DotNet.ProjectModel/CommonCompilerOptions.cs @@ -27,6 +27,8 @@ namespace Microsoft.DotNet.ProjectModel public bool? PublicSign { get; set; } + public string DebugType { get; set; } + public bool? EmitEntryPoint { get; set; } public bool? PreserveCompilationContext { get; set; } @@ -49,6 +51,7 @@ namespace Microsoft.DotNet.ProjectModel KeyFile == other.KeyFile && DelaySign == other.DelaySign && PublicSign == other.PublicSign && + DebugType == other.DebugType && EmitEntryPoint == other.EmitEntryPoint && GenerateXmlDocumentation == other.GenerateXmlDocumentation && PreserveCompilationContext == other.PreserveCompilationContext && @@ -131,6 +134,11 @@ namespace Microsoft.DotNet.ProjectModel result.PublicSign = option.PublicSign; } + if (option.DebugType != null) + { + result.DebugType = option.DebugType; + } + if (option.EmitEntryPoint != null) { result.EmitEntryPoint = option.EmitEntryPoint; diff --git a/src/Microsoft.DotNet.ProjectModel/DependencyContextBuilder.cs b/src/Microsoft.DotNet.ProjectModel/DependencyContextBuilder.cs index 3208231d6..2411ce72b 100644 --- a/src/Microsoft.DotNet.ProjectModel/DependencyContextBuilder.cs +++ b/src/Microsoft.DotNet.ProjectModel/DependencyContextBuilder.cs @@ -45,6 +45,7 @@ namespace Microsoft.Extensions.DependencyModel compilerOptions.KeyFile, compilerOptions.DelaySign, compilerOptions.PublicSign, + compilerOptions.DebugType, compilerOptions.EmitEntryPoint, compilerOptions.GenerateXmlDocumentation); } diff --git a/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs b/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs index 1336d21dc..2a58b3bd5 100644 --- a/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs +++ b/src/Microsoft.DotNet.ProjectModel/ProjectReader.cs @@ -569,6 +569,7 @@ namespace Microsoft.DotNet.ProjectModel KeyFile = rawOptions.ValueAsString("keyFile"), DelaySign = rawOptions.ValueAsNullableBoolean("delaySign"), PublicSign = rawOptions.ValueAsNullableBoolean("publicSign"), + DebugType = rawOptions.ValueAsString("debugType"), EmitEntryPoint = rawOptions.ValueAsNullableBoolean("emitEntryPoint"), GenerateXmlDocumentation = rawOptions.ValueAsNullableBoolean("xmlDoc"), PreserveCompilationContext = rawOptions.ValueAsNullableBoolean("preserveCompilationContext") diff --git a/src/Microsoft.Extensions.DependencyModel/DependencyContextJsonReader.cs b/src/Microsoft.Extensions.DependencyModel/DependencyContextJsonReader.cs index 881ae3441..558878b35 100644 --- a/src/Microsoft.Extensions.DependencyModel/DependencyContextJsonReader.cs +++ b/src/Microsoft.Extensions.DependencyModel/DependencyContextJsonReader.cs @@ -55,6 +55,7 @@ namespace Microsoft.Extensions.DependencyModel compilationOptionsObject[DependencyContextStrings.KeyFilePropertyName]?.Value(), compilationOptionsObject[DependencyContextStrings.DelaySignPropertyName]?.Value(), compilationOptionsObject[DependencyContextStrings.PublicSignPropertyName]?.Value(), + compilationOptionsObject[DependencyContextStrings.DebugTypePropertyName]?.Value(), compilationOptionsObject[DependencyContextStrings.EmitEntryPointPropertyName]?.Value(), compilationOptionsObject[DependencyContextStrings.GenerateXmlDocumentationPropertyName]?.Value() ); @@ -149,4 +150,4 @@ namespace Microsoft.Extensions.DependencyModel public bool Serviceable; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs b/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs index 78aed3d67..dca0e08b0 100644 --- a/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs +++ b/src/Microsoft.Extensions.DependencyModel/DependencyContextWriter.cs @@ -71,6 +71,10 @@ namespace Microsoft.Extensions.DependencyModel { o[DependencyContextStrings.PublicSignPropertyName] = compilationOptions.PublicSign; } + if (compilationOptions.DebugType != null) + { + o[DependencyContextStrings.DebugTypePropertyName] = compilationOptions.DebugType; + } if (compilationOptions.EmitEntryPoint != null) { o[DependencyContextStrings.EmitEntryPointPropertyName] = compilationOptions.EmitEntryPoint; @@ -157,4 +161,4 @@ namespace Microsoft.Extensions.DependencyModel ); } } -} \ No newline at end of file +} diff --git a/src/dotnet/commands/dotnet-compile-csc/Program.cs b/src/dotnet/commands/dotnet-compile-csc/Program.cs index 500eceae0..9e4a26b29 100644 --- a/src/dotnet/commands/dotnet-compile-csc/Program.cs +++ b/src/dotnet/commands/dotnet-compile-csc/Program.cs @@ -89,7 +89,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc // Generate assembly info var assemblyInfo = Path.Combine(tempOutDir, $"dotnet-compile.assemblyinfo.cs"); - + File.WriteAllText(assemblyInfo, AssemblyInfoFileGenerator.GenerateCSharp(assemblyInfoOptions, sources)); allArgs.Add($"\"{assemblyInfo}\""); @@ -106,7 +106,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc // Only the first should be quoted. This is handled // in dotnet-compile where the information is present. allArgs.AddRange(resources.Select(resource => $"-resource:{resource}")); - + allArgs.AddRange(sources.Select(s => $"\"{s}\"")); var rsp = Path.Combine(tempOutDir, "dotnet-compile-csc.rsp"); @@ -129,7 +129,6 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc { "-nostdlib", "-nologo", - "-debug:portable" }; return args; @@ -214,6 +213,10 @@ namespace Microsoft.DotNet.Tools.Compiler.Csc commonArgs.Add("-t:library"); } + commonArgs.Add((string.IsNullOrEmpty(options.DebugType) || options.DebugType == "portable") + ? "-debug:portable" + : "-debug:full"); + return commonArgs; }