diff --git a/Roslyn.sln b/Roslyn.sln
index ae17d51ae20e4d90d15ee929e4c32f03a7196ec5..3894677141deab65d31caf94d9fe07abfc0c1366 100644
--- a/Roslyn.sln
+++ b/Roslyn.sln
@@ -1,4 +1,5 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
+
+Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23025.0
MinimumVisualStudioVersion = 10.0.40219.1
@@ -358,8 +359,8 @@ Global
src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d3}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{afde6bea-5038-4a4a-a88e-dbd2e4088eed}*SharedItemsImports = 4
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{fa0e905d-ec46-466d-b7b2-3b5557f9428c}*SharedItemsImports = 4
- src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\Core\SharedCollections\SharedCollections.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
+ src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 4
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 4
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{bedc5a4a-809e-4017-9cfd-6c8d4e1847f0}*SharedItemsImports = 4
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{b501a547-c911-4a05-ac6e-274a50dff30e}*SharedItemsImports = 4
@@ -4823,6 +4824,34 @@ Global
{D874349C-8BB3-4BDC-8535-2D52CCCA1198}.Release|x64.Build.0 = Release|Any CPU
{D874349C-8BB3-4BDC-8535-2D52CCCA1198}.Release|x86.ActiveCfg = Release|Any CPU
{D874349C-8BB3-4BDC-8535-2D52CCCA1198}.Release|x86.Build.0 = Release|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|ARM.ActiveCfg = Debug|ARM
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|ARM.Build.0 = Debug|ARM
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x64.ActiveCfg = Debug|x64
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x64.Build.0 = Debug|x64
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodDebug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodDebug|ARM.ActiveCfg = Debug|ARM
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodDebug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodDebug|x64.ActiveCfg = Debug|x64
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodDebug|x86.ActiveCfg = Debug|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodRelease|Any CPU.ActiveCfg = Release|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodRelease|ARM.ActiveCfg = Release|ARM
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodRelease|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodRelease|x64.ActiveCfg = Release|x64
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.DogfoodRelease|x86.ActiveCfg = Release|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|ARM.ActiveCfg = Release|ARM
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|ARM.Build.0 = Release|ARM
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x64.ActiveCfg = Release|x64
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x64.Build.0 = Release|x64
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x86.ActiveCfg = Release|Any CPU
{76242A2D-2600-49DD-8C15-FEA07ECB1842}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76242A2D-2600-49DD-8C15-FEA07ECB1842}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76242A2D-2600-49DD-8C15-FEA07ECB1842}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -5577,22 +5606,6 @@ Global
{06ECCF53-B9B8-4CC2-83C0-E308BF645F7F}.Release|x64.Build.0 = Release|Any CPU
{06ECCF53-B9B8-4CC2-83C0-E308BF645F7F}.Release|x86.ActiveCfg = Release|Any CPU
{06ECCF53-B9B8-4CC2-83C0-E308BF645F7F}.Release|x86.Build.0 = Release|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|ARM.ActiveCfg = Debug|ARM
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|ARM.Build.0 = Debug|ARM
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x64.ActiveCfg = Debug|x64
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Debug|x64.Build.0 = Debug|x64
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Any CPU.Build.0 = Release|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|ARM.ActiveCfg = Release|ARM
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|ARM.Build.0 = Release|ARM
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x64.ActiveCfg = Release|x64
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -5724,6 +5737,7 @@ Global
{C1930979-C824-496B-A630-70F5369A636F} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{FCFA8808-A1B6-48CC-A1EA-0B8CA8AEDA8E} = {32A48625-F0AD-419D-828B-A50BDABA38EA}
{D874349C-8BB3-4BDC-8535-2D52CCCA1198} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
+ {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{3140FE61-0856-4367-9AA3-8081B9A80E35} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB}
{76242A2D-2600-49DD-8C15-FEA07ECB1842} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB}
{76242A2D-2600-49DD-8C15-FEA07ECB1843} = {151F6994-AEB3-4B12-B746-2ACFF26C7BBB}
@@ -5751,6 +5765,5 @@ Global
{2491A9B9-C0A8-49EE-9077-A32DE76E1E94} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC}
{5CA5F70E-0FDB-467B-B22C-3CD5994F0087} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC}
{81F048A1-B30A-4E74-9BD3-2655DA1DBEA6} = {999FBDA2-33DA-4F74-B957-03AC72CCE5EC}
- {1DFEA9C5-973C-4179-9B1B-0F32288E1EF2} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
EndGlobalSection
EndGlobal
diff --git a/src/Workspaces/CSharp/Portable/CSharpWorkspace.csproj b/src/Workspaces/CSharp/Portable/CSharpWorkspace.csproj
index 9bea7f63e38e19a3509f72e59e99baf8a49b4f12..e055060fc6109010e87c2a920b9452a5ac491730 100644
--- a/src/Workspaces/CSharp/Portable/CSharpWorkspace.csproj
+++ b/src/Workspaces/CSharp/Portable/CSharpWorkspace.csproj
@@ -116,7 +116,7 @@
-
+
True
True
diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpCommandLineParserService.cs b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpCommandLineParserService.cs
new file mode 100644
index 0000000000000000000000000000000000000000..fc58591fbc7e34499b6a768cb63a7336ddc0686e
--- /dev/null
+++ b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpCommandLineParserService.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Composition;
+using Microsoft.CodeAnalysis.CSharp.Utilities;
+using Microsoft.CodeAnalysis.Host;
+using Microsoft.CodeAnalysis.Host.Mef;
+using Roslyn.Utilities;
+
+namespace Microsoft.CodeAnalysis.CSharp
+{
+ [ExportLanguageService(typeof(ICommandLineParserService), LanguageNames.CSharp), Shared]
+ internal sealed class CSharpCommandLineParserService : ICommandLineParserService
+ {
+ public CommandLineArguments Parse(IEnumerable arguments, string baseDirectory, bool isInteractive, string sdkDirectory)
+ {
+#if SCRIPTING
+ var parser = isInteractive ? CSharpCommandLineParser.Interactive : CSharpCommandLineParser.Default;
+#else
+ var parser = CSharpCommandLineParser.Default;
+#endif
+ return parser.Parse(arguments, baseDirectory, sdkDirectory);
+ }
+ }
+}
diff --git a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpHostBuildDataFactory.cs b/src/Workspaces/CSharp/Portable/LanguageServices/CSharpHostBuildDataFactory.cs
deleted file mode 100644
index c0e6260eacece039fbd2b050bfa1833dadec3be4..0000000000000000000000000000000000000000
--- a/src/Workspaces/CSharp/Portable/LanguageServices/CSharpHostBuildDataFactory.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Composition;
-using Microsoft.CodeAnalysis.CSharp.Utilities;
-using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.Host.Mef;
-using Roslyn.Utilities;
-
-namespace Microsoft.CodeAnalysis.CSharp
-{
- [ExportLanguageService(typeof(ICommandLineArgumentsFactoryService), LanguageNames.CSharp), Shared]
- internal sealed class CSharpCommandLineParserFactory : ICommandLineArgumentsFactoryService
- {
- public CommandLineArguments CreateCommandLineArguments(IEnumerable arguments, string baseDirectory, bool isInteractive, string sdkDirectory)
- {
- var parser = isInteractive ? CSharpCommandLineParser.Interactive : CSharpCommandLineParser.Default;
- return parser.Parse(arguments, baseDirectory, sdkDirectory);
- }
- }
-
- [ExportLanguageService(typeof(IHostBuildDataFactory), LanguageNames.CSharp), Shared]
- internal sealed class CSharpHostBuildDataFactory : IHostBuildDataFactory
- {
- public HostBuildData Create(HostBuildOptions options)
- {
- var parseOptions = new CSharpParseOptions(languageVersion: LanguageVersion.CSharp6, documentationMode: DocumentationMode.Parse);
- var compilationOptions = new CSharpCompilationOptions(
- OutputKind.ConsoleApplication,
- xmlReferenceResolver: new XmlFileResolver(options.ProjectDirectory),
- sourceReferenceResolver: new SourceFileResolver(ImmutableArray.Empty, options.ProjectDirectory),
- metadataReferenceResolver: new AssemblyReferenceResolver(
- new MetadataFileReferenceResolver(ImmutableArray.Empty, options.ProjectDirectory),
- MetadataFileReferenceProvider.Default),
- strongNameProvider: new DesktopStrongNameProvider(ImmutableArray.Create(options.ProjectDirectory, options.OutputDirectory)),
- assemblyIdentityComparer: DesktopAssemblyIdentityComparer.Default);
- var warnings = new List>(options.Warnings);
-
- if (options.OutputKind.HasValue)
- {
- var kind = options.OutputKind.Value;
- compilationOptions = compilationOptions.WithOutputKind(kind);
- if (compilationOptions.Platform == Platform.AnyCpu32BitPreferred &&
- (kind == OutputKind.DynamicallyLinkedLibrary || kind == OutputKind.NetModule || kind == OutputKind.WindowsRuntimeMetadata))
- {
- compilationOptions = compilationOptions.WithPlatform(Platform.AnyCpu);
- }
- }
-
- if (!string.IsNullOrEmpty(options.DefineConstants))
- {
- IEnumerable diagnostics;
- parseOptions = parseOptions.WithPreprocessorSymbols(CSharpCommandLineParser.ParseConditionalCompilationSymbols(options.DefineConstants, out diagnostics));
- }
-
- if (options.DocumentationFile != null)
- {
- parseOptions = parseOptions.WithDocumentationMode(!string.IsNullOrEmpty(options.DocumentationFile) ? DocumentationMode.Diagnose : DocumentationMode.Parse);
- }
-
- if (options.LanguageVersion != null)
- {
- var languageVersion = CompilationOptionsConversion.GetLanguageVersion(options.LanguageVersion);
- if (languageVersion.HasValue)
- {
- parseOptions = parseOptions.WithLanguageVersion(languageVersion.Value);
- }
- }
-
- if (!string.IsNullOrEmpty(options.PlatformWith32BitPreference))
- {
- Platform platform;
- if (Enum.TryParse(options.PlatformWith32BitPreference, true, out platform))
- {
- if (platform == Platform.AnyCpu &&
- compilationOptions.OutputKind != OutputKind.DynamicallyLinkedLibrary &&
- compilationOptions.OutputKind != OutputKind.NetModule &&
- compilationOptions.OutputKind != OutputKind.WindowsRuntimeMetadata)
- {
- platform = Platform.AnyCpu32BitPreferred;
- }
-
- compilationOptions = compilationOptions.WithPlatform(platform);
- }
- }
-
- if (options.AllowUnsafeBlocks.HasValue)
- {
- compilationOptions = compilationOptions.WithAllowUnsafe(options.AllowUnsafeBlocks.Value);
- }
-
- if (options.CheckForOverflowUnderflow.HasValue)
- {
- compilationOptions = compilationOptions.WithOverflowChecks(options.CheckForOverflowUnderflow.Value);
- }
-
- if (options.DelaySign != null)
- {
- bool delaySignExplicitlySet = options.DelaySign.Item1;
- bool delaySign = options.DelaySign.Item2;
- compilationOptions = compilationOptions.WithDelaySign(delaySignExplicitlySet ? delaySign : (bool?)null);
- }
-
- if (!string.IsNullOrEmpty(options.ApplicationConfiguration))
- {
- var appConfigPath = FileUtilities.ResolveRelativePath(options.ApplicationConfiguration, options.ProjectDirectory);
- try
- {
- using (var appConfigStream = PortableShim.FileStream.Create(appConfigPath, PortableShim.FileMode.Open, PortableShim.FileAccess.Read))
- {
- compilationOptions = compilationOptions.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.LoadFromXml(appConfigStream));
- }
- }
- catch (Exception)
- {
- }
- }
-
- if (!string.IsNullOrEmpty(options.KeyContainer))
- {
- compilationOptions = compilationOptions.WithCryptoKeyContainer(options.KeyContainer);
- }
-
- if (!string.IsNullOrEmpty(options.KeyFile))
- {
- var fullPath = FileUtilities.ResolveRelativePath(options.KeyFile, options.ProjectDirectory);
- compilationOptions = compilationOptions.WithCryptoKeyFile(fullPath);
- }
-
- if (!string.IsNullOrEmpty(options.MainEntryPoint))
- {
- compilationOptions = compilationOptions.WithMainTypeName(options.MainEntryPoint);
- }
-
- if (!string.IsNullOrEmpty(options.ModuleAssemblyName))
- {
- compilationOptions = compilationOptions.WithModuleName(options.ModuleAssemblyName);
- }
-
- if (options.Optimize.HasValue)
- {
- compilationOptions = compilationOptions.WithOptimizationLevel(options.Optimize.Value ? OptimizationLevel.Release : OptimizationLevel.Debug);
- }
-
- if (!string.IsNullOrEmpty(options.Platform))
- {
- Platform plat;
- if (Enum.TryParse(options.Platform, ignoreCase: true, result: out plat))
- {
- compilationOptions = compilationOptions.WithPlatform(plat);
- }
- }
-
- // Get options from the ruleset file, if any.
- if (!string.IsNullOrEmpty(options.RuleSetFile))
- {
- var fullPath = FileUtilities.ResolveRelativePath(options.RuleSetFile, options.ProjectDirectory);
-
- Dictionary specificDiagnosticOptions;
- var generalDiagnosticOption = RuleSet.GetDiagnosticOptionsFromRulesetFile(fullPath, out specificDiagnosticOptions);
- compilationOptions = compilationOptions.WithGeneralDiagnosticOption(generalDiagnosticOption);
- warnings.AddRange(specificDiagnosticOptions);
- }
-
- if (options.WarningsAsErrors.HasValue)
- {
- compilationOptions = compilationOptions.WithGeneralDiagnosticOption(options.WarningsAsErrors.Value ? ReportDiagnostic.Error : ReportDiagnostic.Default);
- }
-
- if (options.WarningLevel.HasValue)
- {
- compilationOptions = compilationOptions.WithWarningLevel(options.WarningLevel.Value);
- }
-
- compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(warnings);
- return new HostBuildData(
- parseOptions,
- compilationOptions);
- }
- }
-}
diff --git a/src/Workspaces/Core/Desktop/Workspace/CommandLineProject.cs b/src/Workspaces/Core/Desktop/Workspace/CommandLineProject.cs
index 5b42026628df9cca69e7f9bf66ee88c0ccf16dc4..c2c54d41c83595f7b025a15a5107165a598f9c43 100644
--- a/src/Workspaces/Core/Desktop/Workspace/CommandLineProject.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/CommandLineProject.cs
@@ -30,8 +30,8 @@ public static ProjectInfo CreateProjectInfo(string projectName, string language,
throw new ArgumentException(WorkspacesResources.UnrecognizedLanguageName);
}
- var commandLineArgumentsFactory = languageServices.GetRequiredService();
- var commandLineArguments = commandLineArgumentsFactory.CreateCommandLineArguments(commandLineArgs, projectDirectory, isInteractive: false, sdkDirectory: RuntimeEnvironment.GetRuntimeDirectory());
+ var commandLineParser = languageServices.GetRequiredService();
+ var commandLineArguments = commandLineParser.Parse(commandLineArgs, projectDirectory, isInteractive: false, sdkDirectory: RuntimeEnvironment.GetRuntimeDirectory());
// TODO (tomat): to match csc.exe/vbc.exe we should use CommonCommandLineCompiler.ExistingReferencesResolver to deal with #r's
var referenceResolver = new MetadataFileReferenceResolver(commandLineArguments.ReferencePaths, commandLineArguments.BaseDirectory);
diff --git a/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.CSharpProjectFile.cs b/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.CSharpProjectFile.cs
index 7a0653bca735c1b0d7a2189f2d7b72fa4ffc69bb..703dca64c853ccb96bcbe7aafdf6e5801e2e722d 100644
--- a/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.CSharpProjectFile.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.CSharpProjectFile.cs
@@ -23,18 +23,9 @@ internal partial class CSharpProjectFileLoader : ProjectFileLoader
{
private class CSharpProjectFile : ProjectFile
{
- private readonly IMetadataService _metadataService;
- private readonly IAnalyzerService _analyzerService;
- private readonly IHostBuildDataFactory _msbuildHost;
- private readonly ICommandLineArgumentsFactoryService _commandLineArgumentsFactoryService;
-
- public CSharpProjectFile(CSharpProjectFileLoader loader, MSB.Evaluation.Project project, IMetadataService metadataService, IAnalyzerService analyzerService)
+ public CSharpProjectFile(CSharpProjectFileLoader loader, MSB.Evaluation.Project project)
: base(loader, project)
{
- _metadataService = metadataService;
- _analyzerService = analyzerService;
- _msbuildHost = loader.MSBuildHost;
- _commandLineArgumentsFactoryService = loader.CommandLineArgumentsFactoryService;
}
public override SourceCodeKind GetSourceCodeKind(string documentFileName)
@@ -92,32 +83,23 @@ private ProjectFileInfo CreateProjectFileInfo(CSharpCompilerInputs compilerInput
.Select(s => MakeDocumentFileInfo(projectDirectory, s))
.ToImmutableArray();
- var additionalDocs = compilerInputs.AdditionalFiles
- .Select(s => MakeDocumentFileInfo(projectDirectory, s))
- .ToImmutableArray();
-
- IEnumerable metadataRefs;
- IEnumerable analyzerRefs;
- this.GetReferences(compilerInputs, executedProject, out metadataRefs, out analyzerRefs);
+ var additionalDocs = compilerInputs.AdditionalSources
+ .Select(s => MakeDocumentFileInfo(projectDirectory, s))
+ .ToImmutableArray();
var outputPath = Path.Combine(this.GetOutputDirectory(), compilerInputs.OutputFileName);
var assemblyName = this.GetAssemblyName();
- var msbuildData = _msbuildHost.Create(compilerInputs.Options);
return new ProjectFileInfo(
outputPath,
assemblyName,
- msbuildData.CompilationOptions,
- msbuildData.ParseOptions,
- compilerInputs.CodePage,
+ compilerInputs.CommandLineArgs,
docs,
additionalDocs,
- this.GetProjectReferences(executedProject),
- metadataRefs,
- analyzerRefs);
+ this.GetProjectReferences(executedProject));
}
- private DocumentFileInfo MakeDocumentFileInfo(string projectDirectory, MSB.Framework.ITaskItem item)
+ private DocumentFileInfo MakeDocumentFileInfo(string projectDirectory, ITaskItem item)
{
var filePath = GetDocumentFilePath(item);
var logicalPath = GetDocumentLogicalPath(item, projectDirectory);
@@ -126,7 +108,7 @@ private DocumentFileInfo MakeDocumentFileInfo(string projectDirectory, MSB.Frame
return new DocumentFileInfo(filePath, logicalPath, isLinked, isGenerated);
}
- private ImmutableArray GetAliases(MSB.Framework.ITaskItem item)
+ private ImmutableArray GetAliases(ITaskItem item)
{
var aliasesText = item.GetMetadata("Aliases");
@@ -138,66 +120,6 @@ private ImmutableArray GetAliases(MSB.Framework.ITaskItem item)
return ImmutableArray.CreateRange(aliasesText.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries));
}
- private void GetReferences(
- CSharpCompilerInputs compilerInputs,
- MSB.Execution.ProjectInstance executedProject,
- out IEnumerable metadataReferences,
- out IEnumerable analyzerReferences)
- {
- // use command line parser to do reference translation same as command line compiler
-
- var args = new List();
-
- if (compilerInputs.LibPaths != null && compilerInputs.LibPaths.Count > 0)
- {
- args.Add("/lib:\"" + string.Join(";", compilerInputs.LibPaths) + "\"");
- }
-
- foreach (var mr in compilerInputs.References)
- {
- if (!IsProjectReferenceOutputAssembly(mr))
- {
- var filePath = GetDocumentFilePath(mr);
-
- var aliases = GetAliases(mr);
- if (aliases.IsDefaultOrEmpty)
- {
- args.Add("/r:\"" + filePath + "\"");
- }
- else
- {
- foreach (var alias in aliases)
- {
- args.Add("/r:" + alias + "=\"" + filePath + "\"");
- }
- }
- }
- }
-
- foreach (var ar in compilerInputs.AnalyzerReferences)
- {
- var filePath = GetDocumentFilePath(ar);
- args.Add("/a:\"" + filePath + "\"");
- }
-
- if (compilerInputs.NoStandardLib)
- {
- args.Add("/nostdlib");
- }
-
- var commandLineArgs = _commandLineArgumentsFactoryService.CreateCommandLineArguments(args, executedProject.Directory, isInteractive: false, sdkDirectory: RuntimeEnvironment.GetRuntimeDirectory());
-
- var resolver = new MetadataFileReferenceResolver(commandLineArgs.ReferencePaths, commandLineArgs.BaseDirectory);
- metadataReferences = commandLineArgs.ResolveMetadataReferences(new AssemblyReferenceResolver(resolver, _metadataService.GetProvider()));
-
- var analyzerLoader = _analyzerService.GetLoader();
- foreach (var path in commandLineArgs.AnalyzerReferences.Select(r => r.FilePath))
- {
- analyzerLoader.AddDependencyLocation(path);
- }
- analyzerReferences = commandLineArgs.ResolveAnalyzerReferences(analyzerLoader);
- }
-
private void InitializeFromModel(CSharpCompilerInputs compilerInputs, MSB.Execution.ProjectInstance executedProject)
{
compilerInputs.BeginInitialization();
@@ -277,28 +199,27 @@ private class CSharpCompilerInputs :
private readonly CSharpProjectFile _projectFile;
internal bool Initialized { get; private set; }
- internal HostBuildOptions Options { get; private set; }
- internal int CodePage { get; private set; }
- internal IEnumerable Sources { get; private set; }
- internal IEnumerable References { get; private set; }
- internal IEnumerable AnalyzerReferences { get; private set; }
- internal IEnumerable AdditionalFiles { get; private set; }
- internal IReadOnlyList LibPaths { get; private set; }
- internal bool NoStandardLib { get; private set; }
+ internal string ProjectDirectory { get; }
+ internal string OutputDirectory { get; }
internal string OutputFileName { get; private set; }
+ internal List CommandLineArgs { get; }
+ internal IEnumerable Sources { get; private set; }
+ internal IEnumerable AdditionalSources { get; private set; }
+
+ private bool _emitDebugInfo;
+ private string _debugType;
+
+ private string _targetType;
+ private string _platform;
internal CSharpCompilerInputs(CSharpProjectFile projectFile)
{
_projectFile = projectFile;
- this.Options = new HostBuildOptions();
- this.Sources = SpecializedCollections.EmptyEnumerable();
- this.References = SpecializedCollections.EmptyEnumerable();
- this.AnalyzerReferences = SpecializedCollections.EmptyEnumerable();
- this.AdditionalFiles = SpecializedCollections.EmptyEnumerable();
- this.LibPaths = SpecializedCollections.EmptyReadOnlyList();
-
- this.Options.ProjectDirectory = Path.GetDirectoryName(projectFile.FilePath);
- this.Options.OutputDirectory = projectFile.GetOutputDirectory();
+ this.CommandLineArgs = new List();
+ this.Sources = SpecializedCollections.EmptyEnumerable();
+ this.AdditionalSources = SpecializedCollections.EmptyEnumerable();
+ this.ProjectDirectory = Path.GetDirectoryName(projectFile.FilePath);
+ this.OutputDirectory = projectFile.GetOutputDirectory();
}
public bool Compile()
@@ -315,213 +236,314 @@ public bool EndInitialization(out string errorMessage, out int errorCode)
this.Initialized = true;
errorMessage = string.Empty;
errorCode = 0;
- return true;
- }
- public bool SetHighEntropyVA(bool highEntropyVA)
- {
- // we don't capture emit options
+ if (_emitDebugInfo)
+ {
+ if (string.Equals(_debugType, "none", StringComparison.OrdinalIgnoreCase))
+ {
+ // does this mean not debug???
+ this.CommandLineArgs.Add("/debug");
+ }
+ else if (string.Equals(_debugType, "pdbonly", StringComparison.OrdinalIgnoreCase))
+ {
+ this.CommandLineArgs.Add("/debug:pdbonly");
+ }
+ else if (string.Equals(_debugType, "full", StringComparison.OrdinalIgnoreCase))
+ {
+ this.CommandLineArgs.Add("/debug:full");
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(_platform))
+ {
+ if (string.Equals("anycpu32bitpreferred", _platform, StringComparison.InvariantCultureIgnoreCase)
+ && (string.Equals("library", _targetType, StringComparison.InvariantCultureIgnoreCase)
+ || string.Equals("module", _targetType, StringComparison.InvariantCultureIgnoreCase)
+ || string.Equals("winmdobj", _targetType, StringComparison.InvariantCultureIgnoreCase)))
+ {
+ _platform = "anycpu";
+ }
+
+ this.CommandLineArgs.Add("/platform:" + _platform);
+ }
+
return true;
}
- public bool SetPlatformWith32BitPreference(string platformWith32BitPreference)
+ public bool IsDesignTime()
{
- this.Options.PlatformWith32BitPreference = platformWith32BitPreference;
return true;
}
- public bool SetSubsystemVersion(string subsystemVersion)
+ public bool IsUpToDate()
{
- // we don't capture emit options
return true;
}
- public bool SetApplicationConfiguration(string applicationConfiguration)
+ public bool SetHighEntropyVA(bool highEntropyVA)
{
- this.Options.ApplicationConfiguration = applicationConfiguration;
+ if (highEntropyVA)
+ {
+ this.CommandLineArgs.Add("/highentropyva");
+ }
+
return true;
}
- public bool SetWin32Manifest(string win32Manifest)
+ public bool SetSubsystemVersion(string subsystemVersion)
{
- // Not used?
+ if (!string.IsNullOrWhiteSpace(subsystemVersion))
+ {
+ this.CommandLineArgs.Add("/subsystemversion:" + subsystemVersion);
+ }
+
return true;
}
- public bool IsDesignTime()
+ public bool SetApplicationConfiguration(string applicationConfiguration)
{
+ this.CommandLineArgs.Add("/appconfig:" + applicationConfiguration);
return true;
}
- public bool IsUpToDate()
+ public bool SetWin32Manifest(string win32Manifest)
{
+ if (!string.IsNullOrWhiteSpace(win32Manifest))
+ {
+ this.CommandLineArgs.Add("/win32manifest:\"" + win32Manifest + "\"");
+ }
+
return true;
}
public bool SetAddModules(string[] addModules)
{
- // ???
+ if (addModules != null && addModules.Length > 0)
+ {
+ this.CommandLineArgs.Add("/addmodule:\"" + string.Join(";", addModules) + "\"");
+ }
+
return true;
}
public bool SetAdditionalLibPaths(string[] additionalLibPaths)
{
- this.LibPaths = additionalLibPaths;
+ if (additionalLibPaths != null && additionalLibPaths.Length > 0)
+ {
+ this.CommandLineArgs.Add("/lib:\"" + string.Join(";", additionalLibPaths) + "\"");
+ }
return true;
}
public bool SetAllowUnsafeBlocks(bool allowUnsafeBlocks)
{
- this.Options.AllowUnsafeBlocks = allowUnsafeBlocks;
+ if (allowUnsafeBlocks)
+ {
+ this.CommandLineArgs.Add("/unsafe");
+ }
+
return true;
}
public bool SetBaseAddress(string baseAddress)
{
- // we don't capture emit options
+ if (!string.IsNullOrWhiteSpace(baseAddress))
+ {
+ this.CommandLineArgs.Add("/baseaddress:" + baseAddress);
+ }
+
return true;
}
public bool SetCheckForOverflowUnderflow(bool checkForOverflowUnderflow)
{
- this.Options.CheckForOverflowUnderflow = checkForOverflowUnderflow;
+ if (checkForOverflowUnderflow)
+ {
+ this.CommandLineArgs.Add("/checked");
+ }
+
return true;
}
public bool SetCodePage(int codePage)
{
- this.CodePage = codePage;
+ if (codePage != 0)
+ {
+ this.CommandLineArgs.Add("/codepage:" + codePage);
+ }
+
return true;
}
public bool SetDebugType(string debugType)
{
- // ignore, just check for expected values for backwards compat
- return string.Equals(debugType, "none", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(debugType, "pdbonly", StringComparison.OrdinalIgnoreCase) ||
- string.Equals(debugType, "full", StringComparison.OrdinalIgnoreCase);
+ _debugType = debugType;
+ return true;
}
public bool SetDefineConstants(string defineConstants)
{
- this.Options.DefineConstants = defineConstants;
+ if (!string.IsNullOrWhiteSpace(defineConstants))
+ {
+ this.CommandLineArgs.Add("/define:" + defineConstants);
+ }
+
return true;
}
- private static readonly char[] s_preprocessorSymbolSeparators = new char[] { ';', ',' };
-
public bool SetDelaySign(bool delaySignExplicitlySet, bool delaySign)
{
- this.Options.DelaySign = Tuple.Create(delaySignExplicitlySet, delaySign);
+ if (delaySignExplicitlySet)
+ {
+ this.CommandLineArgs.Add("/delaysign" + (delaySign ? "+" : "-"));
+ }
+
return true;
}
public bool SetDisabledWarnings(string disabledWarnings)
{
- this.SetWarnings(disabledWarnings, ReportDiagnostic.Suppress);
+ if (!string.IsNullOrWhiteSpace(disabledWarnings))
+ {
+ this.CommandLineArgs.Add("/nowarn:" + disabledWarnings);
+ }
+
return true;
}
- private void SetWarnings(string warnings, ReportDiagnostic reportStyle)
+ public bool SetDocumentationFile(string documentationFile)
{
- if (!string.IsNullOrEmpty(warnings))
+ if (!string.IsNullOrWhiteSpace(documentationFile))
{
- foreach (var warning in warnings.Split(s_preprocessorSymbolSeparators, StringSplitOptions.None))
- {
- int warningId;
- if (int.TryParse(warning, out warningId))
- {
- this.Options.Warnings["CS" + warningId.ToString("0000")] = reportStyle;
- }
- else
- {
- this.Options.Warnings[warning] = reportStyle;
- }
- }
+ this.CommandLineArgs.Add("/doc:\"" + documentationFile + "\"");
}
- }
- public bool SetDocumentationFile(string documentationFile)
- {
- this.Options.DocumentationFile = documentationFile;
return true;
}
public bool SetEmitDebugInformation(bool emitDebugInformation)
{
- // we don't capture emit options
+ _emitDebugInfo = emitDebugInformation;
return true;
}
public bool SetErrorReport(string errorReport)
{
- // ?? prompt?
+ if (!string.IsNullOrWhiteSpace(errorReport))
+ {
+ this.CommandLineArgs.Add("/errorreport:" + errorReport.ToLower());
+ }
+
return true;
}
public bool SetFileAlignment(int fileAlignment)
{
- // we don't capture emit options
+ this.CommandLineArgs.Add("/filealign:" + fileAlignment);
return true;
}
public bool SetGenerateFullPaths(bool generateFullPaths)
{
- // ??
+ if (generateFullPaths)
+ {
+ this.CommandLineArgs.Add("/fullpaths");
+ }
+
return true;
}
public bool SetKeyContainer(string keyContainer)
{
- this.Options.KeyContainer = keyContainer;
+ if (!string.IsNullOrWhiteSpace(keyContainer))
+ {
+ this.CommandLineArgs.Add("/keycontainer:\"" + keyContainer + "\"");
+ }
+
return true;
}
public bool SetKeyFile(string keyFile)
{
- this.Options.KeyFile = keyFile;
+ if (!string.IsNullOrWhiteSpace(keyFile))
+ {
+ // keyFile = FileUtilities.ResolveRelativePath(keyFile, this.ProjectDirectory);
+ this.CommandLineArgs.Add("/keyfile:\"" + keyFile + "\"");
+ }
+
return true;
}
public bool SetLangVersion(string langVersion)
{
- this.Options.LanguageVersion = langVersion;
+ if (!string.IsNullOrWhiteSpace(langVersion))
+ {
+ this.CommandLineArgs.Add("/langversion:" + langVersion);
+ }
+
return true;
}
- public bool SetLinkResources(MSB.Framework.ITaskItem[] linkResources)
+ public bool SetLinkResources(ITaskItem[] linkResources)
{
- // ??
+ if (linkResources != null && linkResources.Length > 0)
+ {
+ foreach (var lr in linkResources)
+ {
+ this.CommandLineArgs.Add("/linkresource:\"" + _projectFile.GetDocumentFilePath(lr) + "\"");
+ }
+ }
+
return true;
}
public bool SetMainEntryPoint(string targetType, string mainEntryPoint)
{
- this.Options.MainEntryPoint = mainEntryPoint;
+ if (!string.IsNullOrWhiteSpace(mainEntryPoint))
+ {
+ this.CommandLineArgs.Add("/main:\"" + mainEntryPoint + "\"");
+ }
+
return true;
}
public bool SetModuleAssemblyName(string moduleAssemblyName)
{
- this.Options.ModuleAssemblyName = moduleAssemblyName;
+ if (!string.IsNullOrWhiteSpace(moduleAssemblyName))
+ {
+ this.CommandLineArgs.Add("/moduleassemblyname:\"" + moduleAssemblyName + "\"");
+ }
+
return true;
}
public bool SetNoConfig(bool noConfig)
{
- // ??
+ if (noConfig)
+ {
+ this.CommandLineArgs.Add("/noconfig");
+ }
+
return true;
}
public bool SetNoStandardLib(bool noStandardLib)
{
- this.NoStandardLib = noStandardLib;
+ if (noStandardLib)
+ {
+ this.CommandLineArgs.Add("/nostdlib");
+ }
+
return true;
}
public bool SetOptimize(bool optimize)
{
- this.Options.Optimize = optimize;
+ if (optimize)
+ {
+ this.CommandLineArgs.Add("/optimize");
+ }
+
return true;
}
@@ -529,63 +551,127 @@ public bool SetOutputAssembly(string outputAssembly)
{
// ?? looks to be output file in obj directory not binaries\debug directory
this.OutputFileName = Path.GetFileName(outputAssembly);
+ this.CommandLineArgs.Add("/out:\"" + outputAssembly + "\"");
return true;
}
public bool SetPdbFile(string pdbFile)
{
- // ??
+ if (!string.IsNullOrWhiteSpace(pdbFile))
+ {
+ this.CommandLineArgs.Add($"/pdb:\"{pdbFile}\"");
+ }
+
return true;
}
public bool SetPlatform(string platform)
{
- this.Options.Platform = platform;
+ _platform = platform;
return true;
}
- public bool SetReferences(MSB.Framework.ITaskItem[] references)
+ public bool SetPlatformWith32BitPreference(string platformWith32BitPreference)
{
- this.References = references ?? SpecializedCollections.EmptyEnumerable();
+ SetPlatform(platformWith32BitPreference);
return true;
}
- public bool SetAnalyzers(MSB.Framework.ITaskItem[] analyzerReferences)
+ public bool SetReferences(ITaskItem[] references)
{
- this.AnalyzerReferences = analyzerReferences ?? SpecializedCollections.EmptyEnumerable();
+ if (references != null)
+ {
+ foreach (var mr in references)
+ {
+ if (!_projectFile.IsProjectReferenceOutputAssembly(mr))
+ {
+ var filePath = _projectFile.GetDocumentFilePath(mr);
+
+ var aliases = _projectFile.GetAliases(mr);
+ if (aliases.IsDefaultOrEmpty)
+ {
+ this.CommandLineArgs.Add("/reference:\"" + filePath + "\"");
+ }
+ else
+ {
+ foreach (var alias in aliases)
+ {
+ this.CommandLineArgs.Add("/reference:" + alias + "=\"" + filePath + "\"");
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public bool SetAnalyzers(ITaskItem[] analyzerReferences)
+ {
+ if (analyzerReferences != null)
+ {
+ foreach (var ar in analyzerReferences)
+ {
+ var filePath = _projectFile.GetDocumentFilePath(ar);
+ this.CommandLineArgs.Add("/analyzer:\"" + filePath + "\"");
+ }
+ }
+
return true;
}
public bool SetAdditionalFiles(ITaskItem[] additionalFiles)
{
- this.AdditionalFiles = additionalFiles ?? SpecializedCollections.EmptyEnumerable();
+ if (additionalFiles != null && additionalFiles.Length > 0)
+ {
+ this.AdditionalSources = additionalFiles;
+ }
+
return true;
}
- public bool SetResources(MSB.Framework.ITaskItem[] resources)
+ public bool SetResources(ITaskItem[] resources)
{
- // ??
+ if (resources != null && resources.Length > 0)
+ {
+ foreach (var r in resources)
+ {
+ this.CommandLineArgs.Add("/resource:\"" + _projectFile.GetDocumentFilePath(r) + "\"");
+ }
+ }
+
return true;
}
- public bool SetResponseFiles(MSB.Framework.ITaskItem[] responseFiles)
+ public bool SetResponseFiles(ITaskItem[] responseFiles)
{
- // ??
+ if (responseFiles != null && responseFiles.Length > 0)
+ {
+ foreach (var rf in responseFiles)
+ {
+ this.CommandLineArgs.Add("@\"" + _projectFile.GetDocumentFilePath(rf) + "\"");
+ }
+ }
+
return true;
}
- public bool SetSources(MSB.Framework.ITaskItem[] sources)
+ public bool SetSources(ITaskItem[] sources)
{
- this.Sources = sources ?? SpecializedCollections.EmptyEnumerable();
+ if (sources != null && sources.Length > 0)
+ {
+ this.Sources = sources;
+ }
+
return true;
}
public bool SetTargetType(string targetType)
{
- OutputKind kind;
- if (ProjectFile.TryGetOutputKind(targetType, out kind))
+ if (!string.IsNullOrWhiteSpace(targetType))
{
- this.Options.OutputKind = kind;
+ _targetType = targetType.ToLower();
+ this.CommandLineArgs.Add("/target:" + _targetType);
}
return true;
@@ -593,41 +679,67 @@ public bool SetTargetType(string targetType)
public bool SetRuleSet(string ruleSetFile)
{
- this.Options.RuleSetFile = ruleSetFile;
+ if (!string.IsNullOrWhiteSpace(ruleSetFile))
+ {
+ this.CommandLineArgs.Add("/ruleset:\"" + ruleSetFile + "\"");
+ }
+
return true;
}
public bool SetTreatWarningsAsErrors(bool treatWarningsAsErrors)
{
- this.Options.WarningsAsErrors = treatWarningsAsErrors;
+ if (treatWarningsAsErrors)
+ {
+ this.CommandLineArgs.Add("/warningaserror");
+ }
+
return true;
}
public bool SetWarningLevel(int warningLevel)
{
- this.Options.WarningLevel = warningLevel;
+ this.CommandLineArgs.Add("/warn:" + warningLevel);
return true;
}
public bool SetWarningsAsErrors(string warningsAsErrors)
{
- this.SetWarnings(warningsAsErrors, ReportDiagnostic.Error);
+ if (!string.IsNullOrWhiteSpace(warningsAsErrors))
+ {
+ this.CommandLineArgs.Add("/warnaserror+:" + warningsAsErrors);
+ }
+
return true;
}
public bool SetWarningsNotAsErrors(string warningsNotAsErrors)
{
- this.SetWarnings(warningsNotAsErrors, ReportDiagnostic.Default);
+ if (!string.IsNullOrWhiteSpace(warningsNotAsErrors))
+ {
+ this.CommandLineArgs.Add("/warnaserror-:" + warningsNotAsErrors);
+ }
+
return true;
}
public bool SetWin32Icon(string win32Icon)
{
+ if (!string.IsNullOrWhiteSpace(win32Icon))
+ {
+ this.CommandLineArgs.Add("/win32icon:\"" + win32Icon + "\"");
+ }
+
return true;
}
public bool SetWin32Resource(string win32Resource)
{
+ if (!string.IsNullOrWhiteSpace(win32Resource))
+ {
+ this.CommandLineArgs.Add("/win32res:\"" + win32Resource + "\"");
+ }
+
return true;
}
}
diff --git a/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.cs b/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.cs
index 3c5bfdd44dbdfcd642bebcf5909fe38e2b81d13a..25c2ec60afb13d54af8da9c4ddc0b724e156aae8 100644
--- a/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoader.cs
@@ -11,11 +11,8 @@ namespace Microsoft.CodeAnalysis.CSharp
{
internal partial class CSharpProjectFileLoader : ProjectFileLoader
{
- private readonly HostWorkspaceServices _workspaceServices;
-
- public CSharpProjectFileLoader(HostWorkspaceServices workspaceServices)
+ public CSharpProjectFileLoader()
{
- _workspaceServices = workspaceServices;
}
public override string Language
@@ -23,19 +20,9 @@ public override string Language
get { return LanguageNames.CSharp; }
}
- public IHostBuildDataFactory MSBuildHost
- {
- get { return _workspaceServices.GetLanguageServices(Language).GetService(); }
- }
-
- public ICommandLineArgumentsFactoryService CommandLineArgumentsFactoryService
- {
- get { return _workspaceServices.GetLanguageServices(Language).GetService(); }
- }
-
protected override ProjectFile CreateProjectFile(MSB.Evaluation.Project loadedProject)
{
- return new CSharpProjectFile(this, loadedProject, _workspaceServices.GetService(), _workspaceServices.GetService());
+ return new CSharpProjectFile(this, loadedProject);
}
}
}
diff --git a/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoaderFactory.cs b/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoaderFactory.cs
index e14affc09ae490558f29f6c73fada7a02ba1709a..e2aa602907712e4ca910e5e0655a8a354130f910 100644
--- a/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoaderFactory.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/MSBuild/CSharp/CSharpProjectFileLoaderFactory.cs
@@ -17,7 +17,7 @@ internal class CSharpProjectFileLoaderFactory : ILanguageServiceFactory
{
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
{
- return new CSharpProjectFileLoader(languageServices.WorkspaceServices);
+ return new CSharpProjectFileLoader();
}
}
}
\ No newline at end of file
diff --git a/src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs b/src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
index 534f73c36e9155f0f3402b87f157b0c639bae13f..1f1d19072a2c8562315e0709ab253ddce741097a 100644
--- a/src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/MSBuild/MSBuildWorkspace.cs
@@ -20,6 +20,7 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
+using System.Runtime.InteropServices;
namespace Microsoft.CodeAnalysis.MSBuild
{
@@ -631,8 +632,8 @@ private async Task GetOrLoadProjectAsync(string projectFilePath, IPro
private async Task LoadProjectAsync(string projectFilePath, IProjectFileLoader loader, bool preferMetadata, Dictionary loadedProjects, CancellationToken cancellationToken)
{
- System.Diagnostics.Debug.Assert(projectFilePath != null);
- System.Diagnostics.Debug.Assert(loader != null);
+ Debug.Assert(projectFilePath != null);
+ Debug.Assert(loader != null);
var projectId = this.GetOrCreateProjectId(projectFilePath);
@@ -641,6 +642,10 @@ private async Task LoadProjectAsync(string projectFilePath, IProjectF
var projectFile = await loader.LoadProjectFileAsync(projectFilePath, _properties, cancellationToken).ConfigureAwait(false);
var projectFileInfo = await projectFile.GetProjectFileInfoAsync(cancellationToken).ConfigureAwait(false);
+ var projectDirectory = Path.GetDirectoryName(projectFilePath);
+ var outputFilePath = projectFileInfo.OutputFilePath;
+ var outputDirectory = Path.GetDirectoryName(outputFilePath);
+
VersionStamp version;
if (!string.IsNullOrEmpty(projectFilePath) && File.Exists(projectFilePath))
{
@@ -651,11 +656,37 @@ private async Task LoadProjectAsync(string projectFilePath, IProjectF
version = VersionStamp.Create();
}
- // Documents
+ // translate information from command line args
+ var commandLineParser = this.Services.GetLanguageServices(loader.Language).GetService();
+ var metadataService = this.Services.GetService();
+ var analyzerService = this.Services.GetService();
+
+ var commandLineArgs = commandLineParser.Parse(
+ arguments: projectFileInfo.CommandLineArgs,
+ baseDirectory: projectDirectory,
+ isInteractive: false,
+ sdkDirectory: RuntimeEnvironment.GetRuntimeDirectory());
+
+ var resolver = new MetadataFileReferenceResolver(commandLineArgs.ReferencePaths, commandLineArgs.BaseDirectory);
+ var metadataReferences = commandLineArgs.ResolveMetadataReferences(new AssemblyReferenceResolver(resolver, metadataService.GetProvider()));
+
+ var analyzerLoader = analyzerService.GetLoader();
+ foreach (var path in commandLineArgs.AnalyzerReferences.Select(r => r.FilePath))
+ {
+ analyzerLoader.AddDependencyLocation(path);
+ }
+
+ var analyzerReferences = commandLineArgs.ResolveAnalyzerReferences(analyzerLoader);
+
+ var defaultEncoding = commandLineArgs.Encoding;
+
+ // docs & additional docs
var docFileInfos = projectFileInfo.Documents.ToImmutableArrayOrEmpty();
- CheckDocuments(docFileInfos, projectFilePath, projectId);
+ var additionalDocFileInfos = projectFileInfo.AdditionalDocuments.ToImmutableArrayOrEmpty();
- Encoding defaultEncoding = GetDefaultEncoding(projectFileInfo.CodePage);
+ // check for duplicate documents
+ var allDocFileInfos = docFileInfos.AddRange(additionalDocFileInfos);
+ CheckDocuments(allDocFileInfos, projectFilePath, projectId);
var docs = new List();
foreach (var docFileInfo in docFileInfos)
@@ -675,7 +706,7 @@ private async Task LoadProjectAsync(string projectFilePath, IProjectF
}
var additionalDocs = new List();
- foreach (var docFileInfo in projectFileInfo.AdditionalDocuments)
+ foreach (var docFileInfo in additionalDocFileInfos)
{
string name;
ImmutableArray folders;
@@ -695,13 +726,11 @@ private async Task LoadProjectAsync(string projectFilePath, IProjectF
var resolvedReferences = await this.ResolveProjectReferencesAsync(
projectId, projectFilePath, projectFileInfo.ProjectReferences, preferMetadata, loadedProjects, cancellationToken).ConfigureAwait(false);
- var metadataReferences = projectFileInfo.MetadataReferences
- .Concat(resolvedReferences.MetadataReferences);
-
- var outputFilePath = projectFileInfo.OutputFilePath;
- var assemblyName = projectFileInfo.AssemblyName;
+ // add metadata references for project refs converted to metadata refs
+ metadataReferences = metadataReferences.Concat(resolvedReferences.MetadataReferences);
// if the project file loader couldn't figure out an assembly name, make one using the project's file path.
+ var assemblyName = commandLineArgs.CompilationName;
if (string.IsNullOrWhiteSpace(assemblyName))
{
assemblyName = Path.GetFileNameWithoutExtension(projectFilePath);
@@ -713,6 +742,24 @@ private async Task LoadProjectAsync(string projectFilePath, IProjectF
}
}
+ // make sure that doc-comments at least get parsed.
+ var parseOptions = commandLineArgs.ParseOptions;
+ if (parseOptions.DocumentationMode == DocumentationMode.None)
+ {
+ parseOptions = parseOptions.WithDocumentationMode(DocumentationMode.Parse);
+ }
+
+ // add all the extra options that are really behavior overrides
+ var compOptions = commandLineArgs.CompilationOptions
+ .WithXmlReferenceResolver(new XmlFileResolver(projectDirectory))
+ .WithSourceReferenceResolver(new SourceFileResolver(ImmutableArray.Empty, projectDirectory))
+ .WithMetadataReferenceResolver(
+ new AssemblyReferenceResolver(
+ new MetadataFileReferenceResolver(ImmutableArray.Empty, projectDirectory),
+ MetadataFileReferenceProvider.Default))
+ .WithStrongNameProvider(new DesktopStrongNameProvider(ImmutableArray.Create(projectDirectory, outputFilePath)))
+ .WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default);
+
loadedProjects.Add(
projectId,
ProjectInfo.Create(
@@ -723,12 +770,12 @@ private async Task LoadProjectAsync(string projectFilePath, IProjectF
loader.Language,
projectFilePath,
outputFilePath,
- projectFileInfo.CompilationOptions,
- projectFileInfo.ParseOptions,
- docs,
- resolvedReferences.ProjectReferences,
- metadataReferences,
- analyzerReferences: projectFileInfo.AnalyzerReferences,
+ compilationOptions: compOptions,
+ parseOptions: parseOptions,
+ documents: docs,
+ projectReferences: resolvedReferences.ProjectReferences,
+ metadataReferences: metadataReferences,
+ analyzerReferences: analyzerReferences,
additionalDocuments: additionalDocs,
isSubmission: false,
hostObjectType: null));
@@ -736,25 +783,6 @@ private async Task LoadProjectAsync(string projectFilePath, IProjectF
return projectId;
}
- private static Encoding GetDefaultEncoding(int codePage)
- {
- // If no CodePage was specified in the project file, then the FileTextLoader will
- // attempt to use UTF8 before falling back on Encoding.Default.
- if (codePage == 0)
- {
- return null;
- }
-
- try
- {
- return Encoding.GetEncoding(codePage);
- }
- catch (ArgumentOutOfRangeException)
- {
- return null;
- }
- }
-
private static readonly char[] s_directorySplitChars = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar };
private static void GetDocumentNameAndFolders(string logicalPath, out string name, out ImmutableArray folders)
diff --git a/src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/IProjectFile.cs b/src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/IProjectFile.cs
index 01ff65e46735452e302ee183e1a94bd68ec8b552..c401b188b73ac2c8a612337093e74eb48c2ebb07 100644
--- a/src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/IProjectFile.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/IProjectFile.cs
@@ -36,11 +36,6 @@ internal interface IProjectFile
///
string GetDocumentExtension(SourceCodeKind kind);
- ///
- /// Gets a specific project file property.
- ///
- string GetPropertyValue(string name);
-
///
/// Add a source document to a project file.
///
diff --git a/src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/ProjectFileInfo.cs b/src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/ProjectFileInfo.cs
index ec17dd2aefcc6c12ebcf219e6af874619332a4b9..15b4d19951c23eae74f21de83214c845b1992d9d 100644
--- a/src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/ProjectFileInfo.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/MSBuild/ProjectFile/ProjectFileInfo.cs
@@ -23,19 +23,9 @@ internal sealed class ProjectFileInfo
public string AssemblyName { get; }
///
- /// The compilation options for this project.
+ /// The command line args used to compile the project.
///
- public CompilationOptions CompilationOptions { get; }
-
- ///
- /// The parse options for this project.
- ///
- public ParseOptions ParseOptions { get; }
-
- ///
- /// The codepage for this project.
- ///
- public int CodePage { get; }
+ public IReadOnlyList CommandLineArgs { get; }
///
/// The source documents.
@@ -52,38 +42,20 @@ internal sealed class ProjectFileInfo
///
public IReadOnlyList ProjectReferences { get; }
- ///
- /// References to other metadata files; libraries and executables.
- ///
- public IReadOnlyList MetadataReferences { get; }
-
- ///
- /// References to analyzer assembly files; contains diagnostic analyzers.
- ///
- public IReadOnlyList AnalyzerReferences { get; }
-
public ProjectFileInfo(
string outputPath,
string assemblyName,
- CompilationOptions compilationOptions,
- ParseOptions parseOptions,
- int codePage,
+ IEnumerable commandLineArgs,
IEnumerable documents,
IEnumerable additionalDocuments,
- IEnumerable projectReferences,
- IEnumerable metadataReferences,
- IEnumerable analyzerReferences)
+ IEnumerable projectReferences)
{
this.OutputFilePath = outputPath;
this.AssemblyName = assemblyName;
- this.CompilationOptions = compilationOptions;
- this.ParseOptions = parseOptions;
- this.CodePage = codePage;
+ this.CommandLineArgs = commandLineArgs.ToImmutableArrayOrEmpty();
this.Documents = documents.ToImmutableReadOnlyListOrEmpty();
- this.AdditionalDocuments = additionalDocuments.ToImmutableReadOnlyListOrEmpty();
+ this.AdditionalDocuments = additionalDocuments.ToImmutableArrayOrEmpty();
this.ProjectReferences = projectReferences.ToImmutableReadOnlyListOrEmpty();
- this.MetadataReferences = metadataReferences.ToImmutableReadOnlyListOrEmpty();
- this.AnalyzerReferences = analyzerReferences.ToImmutableReadOnlyListOrEmpty();
}
}
}
diff --git a/src/Workspaces/Core/Desktop/Workspace/MSBuild/VisualBasic/VisualBasicProjectFileLoader.cs b/src/Workspaces/Core/Desktop/Workspace/MSBuild/VisualBasic/VisualBasicProjectFileLoader.cs
index 22fdcfe802b4720759264061d6201cc014fd832b..7fdd3f45a218179ce1f448f230e03548740432b5 100644
--- a/src/Workspaces/Core/Desktop/Workspace/MSBuild/VisualBasic/VisualBasicProjectFileLoader.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/MSBuild/VisualBasic/VisualBasicProjectFileLoader.cs
@@ -24,41 +24,24 @@ namespace Microsoft.CodeAnalysis.VisualBasic
{
internal class VisualBasicProjectFileLoader : ProjectFileLoader
{
- private readonly HostWorkspaceServices _workspaceServices;
-
- internal HostLanguageServices LanguageServices
- {
- get { return _workspaceServices.GetLanguageServices(LanguageNames.VisualBasic); }
- }
-
public override string Language
{
get { return LanguageNames.VisualBasic; }
}
- internal VisualBasicProjectFileLoader(HostWorkspaceServices workspaceServices)
+ internal VisualBasicProjectFileLoader()
{
- _workspaceServices = workspaceServices;
}
protected override ProjectFile CreateProjectFile(MSB.Evaluation.Project loadedProject)
{
- return new VisualBasicProjectFile(this, loadedProject, _workspaceServices.GetService(), _workspaceServices.GetService());
+ return new VisualBasicProjectFile(this, loadedProject);
}
internal class VisualBasicProjectFile : ProjectFile
{
- private readonly IMetadataService _metadataService;
- private readonly IAnalyzerService _analyzerService;
- private readonly IHostBuildDataFactory _hostBuildDataFactory;
- private readonly ICommandLineArgumentsFactoryService _commandLineArgumentsFactory;
-
- public VisualBasicProjectFile(VisualBasicProjectFileLoader loader, MSB.Evaluation.Project loadedProject, IMetadataService metadataService, IAnalyzerService analyzerService) : base(loader, loadedProject)
+ public VisualBasicProjectFile(VisualBasicProjectFileLoader loader, MSB.Evaluation.Project loadedProject) : base(loader, loadedProject)
{
- _metadataService = metadataService;
- _analyzerService = analyzerService;
- _hostBuildDataFactory = loader.LanguageServices.GetService();
- _commandLineArgumentsFactory = loader.LanguageServices.GetService();
}
public override SourceCodeKind GetSourceCodeKind(string documentFileName)
@@ -104,82 +87,16 @@ public override async Task GetProjectFileInfoAsync(Cancellation
private ProjectFileInfo CreateProjectFileInfo(VisualBasicProjectFileLoader.VisualBasicProjectFile.VisualBasicCompilerInputs compilerInputs, ProjectInstance executedProject)
{
- IEnumerable metadataReferences = null;
- IEnumerable analyzerReferences = null;
- this.GetReferences(compilerInputs, executedProject, ref metadataReferences, ref analyzerReferences);
string outputPath = Path.Combine(this.GetOutputDirectory(), compilerInputs.OutputFileName);
string assemblyName = this.GetAssemblyName();
- HostBuildData hostBuildData = _hostBuildDataFactory.Create(compilerInputs.HostBuildOptions);
- return new ProjectFileInfo(outputPath, assemblyName, hostBuildData.CompilationOptions, hostBuildData.ParseOptions, compilerInputs.CodePage, this.GetDocuments(compilerInputs.Sources, executedProject), this.GetDocuments(compilerInputs.AdditionalFiles, executedProject), base.GetProjectReferences(executedProject), metadataReferences, analyzerReferences);
- }
-
- private void GetReferences(VisualBasicProjectFileLoader.VisualBasicProjectFile.VisualBasicCompilerInputs compilerInputs, ProjectInstance executedProject, ref IEnumerable metadataReferences, ref IEnumerable analyzerReferences)
- {
- // use command line parser to compute references using common logic
- List list = new List();
- if (compilerInputs.LibPaths != null && compilerInputs.LibPaths.Count() > 0)
- {
- list.Add("/libpath:\"" + string.Join(";", compilerInputs.LibPaths) + "\"");
- }
-
- // metadata references
- foreach (var current in compilerInputs.References)
- {
- if (!IsProjectReferenceOutputAssembly(current))
- {
- string documentFilePath = base.GetDocumentFilePath(current);
- list.Add("/r:\"" + documentFilePath + "\"");
- }
- }
-
- // analyzer references
- foreach (var current in compilerInputs.AnalyzerReferences)
- {
- string documentFilePath2 = base.GetDocumentFilePath(current);
- list.Add("/a:\"" + documentFilePath2 + "\"");
- }
-
- if (compilerInputs.NoStandardLib)
- {
- list.Add("/nostdlib");
- }
-
- if (!string.IsNullOrEmpty(compilerInputs.VbRuntime))
- {
- if (compilerInputs.VbRuntime == "Default")
- {
- list.Add("/vbruntime+");
- }
- else if (compilerInputs.VbRuntime == "Embed")
- {
- list.Add("/vbruntime*");
- }
- else if (compilerInputs.VbRuntime == "None")
- {
- list.Add("/vbruntime-");
- }
- else
- {
- list.Add("/vbruntime: " + compilerInputs.VbRuntime);
- }
- }
-
- if (!string.IsNullOrEmpty(compilerInputs.SdkPath))
- {
- list.Add("/sdkpath:" + compilerInputs.SdkPath);
- }
-
- CommandLineArguments commandLineArguments = _commandLineArgumentsFactory.CreateCommandLineArguments(list, executedProject.Directory, false, RuntimeEnvironment.GetRuntimeDirectory());
- MetadataFileReferenceResolver pathResolver = new MetadataFileReferenceResolver(commandLineArguments.ReferencePaths, commandLineArguments.BaseDirectory);
- metadataReferences = commandLineArguments.ResolveMetadataReferences(new AssemblyReferenceResolver(pathResolver, _metadataService.GetProvider()));
- IAnalyzerAssemblyLoader loader = _analyzerService.GetLoader();
- foreach (var path in commandLineArguments.AnalyzerReferences.Select((r) => r.FilePath))
- {
- loader.AddDependencyLocation(path);
- }
-
- analyzerReferences = commandLineArguments.ResolveAnalyzerReferences(loader);
+ return new ProjectFileInfo(
+ outputPath,
+ assemblyName,
+ compilerInputs.CommandLineArgs,
+ this.GetDocuments(compilerInputs.Sources, executedProject),
+ this.GetDocuments(compilerInputs.AdditionalFiles, executedProject),
+ base.GetProjectReferences(executedProject));
}
private IEnumerable GetDocuments(IEnumerable sources, ProjectInstance executedProject)
@@ -289,31 +206,26 @@ private class VisualBasicCompilerInputs :
{
private readonly VisualBasicProjectFile _projectFile;
private bool _initialized;
- private HostBuildOptions _options;
- private int _codePage;
- private IEnumerable _sources;
- private IEnumerable _additionalFiles;
- private IEnumerable _references;
- private IEnumerable _analyzerReferences;
- private bool _noStandardLib;
- private readonly Dictionary _warnings;
- private string _sdkPath;
- private bool _targetCompactFramework;
- private string _vbRuntime;
- private IEnumerable _libPaths;
+ private string _projectDirectory;
+ private string _outputDirectory;
+ private List _commandLineArgs;
+ private IEnumerable _sources;
+ private IEnumerable _additionalFiles;
private string _outputFileName;
+ private bool _emitDocComments;
+ private string _docCommentFile;
+ private string _targetType;
+ private string _platform;
+
public VisualBasicCompilerInputs(VisualBasicProjectFile projectFile)
{
_projectFile = projectFile;
- _options = new HostBuildOptions();
- _sources = SpecializedCollections.EmptyEnumerable();
- _references = SpecializedCollections.EmptyEnumerable();
- _analyzerReferences = SpecializedCollections.EmptyEnumerable();
- _warnings = new Dictionary();
-
- _options.ProjectDirectory = Path.GetDirectoryName(projectFile.FilePath);
- _options.OutputDirectory = projectFile.GetOutputDirectory();
+ _commandLineArgs = new List();
+ _sources = SpecializedCollections.EmptyEnumerable();
+ _additionalFiles = SpecializedCollections.EmptyEnumerable(); ;
+ _projectDirectory = Path.GetDirectoryName(projectFile.FilePath);
+ _outputDirectory = projectFile.GetOutputDirectory();
}
public bool Initialized
@@ -321,78 +233,105 @@ public bool Initialized
get { return _initialized; }
}
- public HostBuildOptions HostBuildOptions
+ public List CommandLineArgs
{
- get { return _options; }
+ get { return _commandLineArgs; }
}
- public int CodePage
+ public IEnumerable Sources
{
- get { return _codePage; }
- }
-
- public IEnumerable References
- {
- get { return _references; }
+ get { return _sources; }
}
- public IEnumerable AnalyzerReferences
+ public IEnumerable AdditionalFiles
{
- get { return _analyzerReferences; }
+ get { return _additionalFiles; }
}
- public IEnumerable Sources
+ public string OutputFileName
{
- get { return _sources; }
+ get { return _outputFileName; }
}
- public IEnumerable AdditionalFiles
+ public string OutputDirectory
{
- get { return _additionalFiles; }
+ get { return _outputDirectory; }
}
- public bool NoStandardLib
+ public string ProjectDirectory
{
- get { return _noStandardLib; }
+ get { return _projectDirectory; }
}
- public string VbRuntime
+ public void BeginInitialization()
{
- get { return _vbRuntime; }
}
- public string SdkPath
+ public bool Compile()
{
- get { return _sdkPath; }
+ return false;
}
- public bool TargetCompactFramework
+ public int CompileAsync(out IntPtr buildSucceededEvent, out IntPtr buildFailedEvent)
{
- get { return _targetCompactFramework; }
+ buildSucceededEvent = IntPtr.Zero;
+ buildFailedEvent = IntPtr.Zero;
+ return 0;
}
- public IEnumerable LibPaths
+ public bool Compile1()
{
- get { return _libPaths; }
+ return false;
}
- public string OutputFileName
+ bool IVbcHostObjectFreeThreaded.Compile()
{
- get { return _outputFileName; }
+ return Compile1();
}
- public void BeginInitialization()
+ public int EndCompile(bool buildSuccess)
{
+ return 0;
}
- public bool Compile()
+ public IVbcHostObjectFreeThreaded GetFreeThreadedHostObject()
{
- return false;
+ return null;
}
public void EndInitialization()
{
_initialized = true;
+
+ if (_emitDocComments)
+ {
+ if (!string.IsNullOrWhiteSpace(_docCommentFile))
+ {
+ _commandLineArgs.Add("/doc:\"" + _docCommentFile + "\"");
+ }
+ else
+ {
+ _commandLineArgs.Add("/doc");
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(_targetType))
+ {
+ this.CommandLineArgs.Add("/target:" + _targetType);
+ }
+
+ if (!string.IsNullOrWhiteSpace(_platform))
+ {
+ if (string.Equals("anycpu32bitpreferred", _platform, StringComparison.InvariantCultureIgnoreCase)
+ && (string.Equals("library", _targetType, StringComparison.InvariantCultureIgnoreCase)
+ || string.Equals("module", _targetType, StringComparison.InvariantCultureIgnoreCase)
+ || string.Equals("winmdobj", _targetType, StringComparison.InvariantCultureIgnoreCase)))
+ {
+ _platform = "AnyCpu";
+ }
+
+ this.CommandLineArgs.Add("/platform:" + _platform);
+ }
}
public bool IsDesignTime()
@@ -407,366 +346,576 @@ public bool IsUpToDate()
public bool SetAdditionalLibPaths(string[] additionalLibPaths)
{
- _libPaths = additionalLibPaths;
+ if (additionalLibPaths != null && additionalLibPaths.Length > 0)
+ {
+ _commandLineArgs.Add("/libpath:\"" + string.Join(";", additionalLibPaths) + "\"");
+ }
+
return true;
}
public bool SetAddModules(string[] addModules)
{
+ if (addModules != null && addModules.Length > 0)
+ {
+ _commandLineArgs.Add("/addmodules:\"" + string.Join(";", addModules) + "\"");
+ }
+
return true;
}
public bool SetBaseAddress(string targetType, string baseAddress)
{
- // we don't capture emit options
+ SetTargetType(targetType);
+
+ if (!string.IsNullOrWhiteSpace(baseAddress))
+ {
+ _commandLineArgs.Add("/baseaddress:" + baseAddress);
+ }
+
return true;
}
public bool SetCodePage(int codePage)
{
- _codePage = codePage;
+ if (codePage != 0)
+ {
+ _commandLineArgs.Add("/codepage:" + codePage);
+ }
+
return true;
}
public bool SetDebugType(bool emitDebugInformation, string debugType)
{
- // ignore, just check for expected values for backwards compat
- return string.Equals(debugType, "none", StringComparison.OrdinalIgnoreCase) || string.Equals(debugType, "pdbonly", StringComparison.OrdinalIgnoreCase) || string.Equals(debugType, "full", StringComparison.OrdinalIgnoreCase);
+ if (emitDebugInformation)
+ {
+ if (string.Equals(debugType, "none", StringComparison.OrdinalIgnoreCase))
+ {
+ // ??
+ this.CommandLineArgs.Add("/debug");
+ return true;
+ }
+ else if (string.Equals(debugType, "pdbonly", StringComparison.OrdinalIgnoreCase))
+ {
+ this.CommandLineArgs.Add("/debug:pdbonly");
+ return true;
+ }
+ else if (string.Equals(debugType, "full", StringComparison.OrdinalIgnoreCase))
+ {
+ this.CommandLineArgs.Add("/debug:full");
+ return true;
+ }
+ }
+
+ return false;
}
public bool SetDefineConstants(string defineConstants)
{
- _options.DefineConstants = defineConstants;
+ if (!string.IsNullOrWhiteSpace(defineConstants))
+ {
+ _commandLineArgs.Add("/define:" + defineConstants);
+ }
+
return true;
}
public bool SetDelaySign(bool delaySign)
{
- _options.DelaySign = Tuple.Create(delaySign, false);
+ if (delaySign)
+ {
+ _commandLineArgs.Add("/delaysign");
+ }
+
return true;
}
public bool SetDisabledWarnings(string disabledWarnings)
{
- SetWarnings(disabledWarnings, ReportDiagnostic.Suppress);
+ if (!string.IsNullOrWhiteSpace(disabledWarnings))
+ {
+ _commandLineArgs.Add("/nowarn:" + disabledWarnings);
+ }
+
return true;
}
public bool SetDocumentationFile(string documentationFile)
{
- _options.DocumentationFile = documentationFile;
+ if (!string.IsNullOrWhiteSpace(documentationFile))
+ {
+ _emitDocComments = true;
+ _docCommentFile = documentationFile;
+ }
+
return true;
}
public bool SetErrorReport(string errorReport)
{
- // ??
+ if (!string.IsNullOrWhiteSpace(errorReport))
+ {
+ _commandLineArgs.Add("/errorreport:" + errorReport.ToLower());
+ }
+
return true;
}
public bool SetFileAlignment(int fileAlignment)
{
- // we don't capture emit options
+ _commandLineArgs.Add("/filealign:" + fileAlignment);
return true;
}
public bool SetGenerateDocumentation(bool generateDocumentation)
{
+ if (generateDocumentation)
+ {
+ _emitDocComments = true;
+ }
+
return true;
}
- public bool SetImports(Microsoft.Build.Framework.ITaskItem[] importsList)
+ public bool SetImports(ITaskItem[] importsList)
{
if (importsList != null)
{
- _options.GlobalImports.AddRange(importsList.Select(item => item.ItemSpec.Trim()));
+ _commandLineArgs.Add("/imports:" + string.Join(",", importsList.Select(item => item.ItemSpec.Trim())));
}
+
return true;
}
public bool SetKeyContainer(string keyContainer)
{
- _options.KeyContainer = keyContainer;
+ if (!string.IsNullOrWhiteSpace(keyContainer))
+ {
+ _commandLineArgs.Add("/keycontainer:\"" + keyContainer + "\"");
+ }
+
return true;
}
public bool SetKeyFile(string keyFile)
{
- _options.KeyFile = keyFile;
+ if (!string.IsNullOrWhiteSpace(keyFile))
+ {
+ //keyFile = FileUtilities.ResolveRelativePath(keyFile, this.ProjectDirectory);
+ _commandLineArgs.Add("/keyfile:\"" + keyFile + "\"");
+ }
+
return true;
}
- public bool SetLinkResources(Microsoft.Build.Framework.ITaskItem[] linkResources)
+ public bool SetLinkResources(ITaskItem[] linkResources)
{
- // ??
+ if (linkResources != null && linkResources.Length > 0)
+ {
+ foreach (var lr in linkResources)
+ {
+ _commandLineArgs.Add("/linkresource:\"" + _projectFile.GetDocumentFilePath(lr) + "\"");
+ }
+ }
+
return true;
}
public bool SetMainEntryPoint(string mainEntryPoint)
{
- _options.MainEntryPoint = mainEntryPoint;
+ if (!string.IsNullOrWhiteSpace(mainEntryPoint))
+ {
+ _commandLineArgs.Add("/main:\"" + mainEntryPoint + "\"");
+ }
+
return true;
}
public bool SetNoConfig(bool noConfig)
{
+ if (noConfig)
+ {
+ _commandLineArgs.Add("/noconfig");
+ }
+
return true;
}
public bool SetNoStandardLib(bool noStandardLib)
{
- _noStandardLib = noStandardLib;
+ if (noStandardLib)
+ {
+ _commandLineArgs.Add("/nostdlib");
+ }
+
return true;
}
public bool SetNoWarnings(bool noWarnings)
{
- _options.NoWarnings = noWarnings;
+ if (noWarnings)
+ {
+ _commandLineArgs.Add("/nowarn");
+ }
+
return true;
}
public bool SetOptimize(bool optimize)
{
- _options.Optimize = optimize;
+ if (optimize)
+ {
+ _commandLineArgs.Add("/optimize");
+ }
+
return true;
}
public bool SetOptionCompare(string optionCompare)
{
- _options.OptionCompare = optionCompare;
- return true;
+ if (string.Equals("binary", optionCompare, StringComparison.OrdinalIgnoreCase))
+ {
+ _commandLineArgs.Add("/optioncompare:binary");
+ return true;
+ }
+ else if (string.Equals("text", optionCompare, StringComparison.OrdinalIgnoreCase))
+ {
+ _commandLineArgs.Add("/optioncompare:text");
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
public bool SetOptionExplicit(bool optionExplicit)
{
- _options.OptionExplicit = optionExplicit;
+ // default is on/true
+ if (!optionExplicit)
+ {
+ _commandLineArgs.Add("/optionexplicit-");
+ }
+
return true;
}
- public bool SetOptionStrict(bool _optionStrict)
+ public bool SetOptionStrict(bool optionStrict)
{
- _options.OptionStrict = _optionStrict ? "On" : "Custom";
+ if (optionStrict)
+ {
+ _commandLineArgs.Add("/optionstrict");
+ }
+
return true;
}
public bool SetOptionStrictType(string optionStrictType)
{
- if (!string.IsNullOrEmpty(optionStrictType))
+ if (string.Equals("custom", optionStrictType, StringComparison.OrdinalIgnoreCase))
{
- _options.OptionStrict = optionStrictType;
+ _commandLineArgs.Add("/optionstrict:custom");
+ return true;
+ }
+ else
+ {
+ return false;
}
- return true;
}
public bool SetOutputAssembly(string outputAssembly)
{
_outputFileName = Path.GetFileName(outputAssembly);
+ _commandLineArgs.Add("/out:\"" + outputAssembly + "\"");
return true;
}
- public bool SetPlatform(string _platform)
+ public bool SetPlatform(string platform)
{
- _options.Platform = _platform;
+ _platform = platform;
return true;
}
- public bool SetPlatformWith32BitPreference(string _platform)
+ public bool SetPlatformWith32BitPreference(string platform)
{
- _options.PlatformWith32BitPreference = _platform;
+ SetPlatform(platform);
return true;
}
- public bool SetReferences(Microsoft.Build.Framework.ITaskItem[] references)
+ public bool SetReferences(ITaskItem[] references)
{
- _references = references ?? SpecializedCollections.EmptyEnumerable();
+ if (references != null && references.Length > 0)
+ {
+ foreach (var current in references)
+ {
+ if (!_projectFile.IsProjectReferenceOutputAssembly(current))
+ {
+ _commandLineArgs.Add("/reference:\"" + _projectFile.GetDocumentFilePath(current) + "\"");
+ }
+ }
+ }
+
return true;
}
- public bool SetAnalyzers(MSB.Framework.ITaskItem[] analyzerReferences)
+ public bool SetAnalyzers(ITaskItem[] analyzerReferences)
{
- _analyzerReferences = analyzerReferences ?? SpecializedCollections.EmptyEnumerable();
+ if (analyzerReferences != null && analyzerReferences.Length > 0)
+ {
+ foreach (var current in analyzerReferences)
+ {
+ _commandLineArgs.Add("/analyzer:\"" + _projectFile.GetDocumentFilePath(current) + "\"");
+ }
+ }
+
return true;
}
- public bool SetAdditionalFiles(MSB.Framework.ITaskItem[] additionalFiles)
+ public bool SetAdditionalFiles(ITaskItem[] additionalFiles)
{
- _additionalFiles = additionalFiles ?? SpecializedCollections.EmptyEnumerable();
+ if (additionalFiles != null)
+ {
+ _additionalFiles = additionalFiles;
+
+ foreach (var af in additionalFiles)
+ {
+ _commandLineArgs.Add("/additionalfile:\"" + _projectFile.GetDocumentFilePath(af) + "\"");
+ }
+ }
+
return true;
}
public bool SetRemoveIntegerChecks(bool removeIntegerChecks)
{
- _options.CheckForOverflowUnderflow = !removeIntegerChecks;
+ if (removeIntegerChecks)
+ {
+ _commandLineArgs.Add("/removeintchecks");
+ }
+
return true;
}
- public bool SetResources(Microsoft.Build.Framework.ITaskItem[] resources)
+ public bool SetResources(ITaskItem[] resources)
{
+ if (resources != null && resources.Length > 0)
+ {
+ foreach (var r in resources)
+ {
+ _commandLineArgs.Add("/resource:\"" + _projectFile.GetDocumentFilePath(r) + "\"");
+ }
+ }
+
return true;
}
- public bool SetResponseFiles(Microsoft.Build.Framework.ITaskItem[] responseFiles)
+ public bool SetResponseFiles(ITaskItem[] responseFiles)
{
+ if (responseFiles != null && responseFiles.Length > 0)
+ {
+ foreach (var rf in responseFiles)
+ {
+ _commandLineArgs.Add("@\"" + _projectFile.GetDocumentFilePath(rf) + "\"");
+ }
+ }
+
return true;
}
public bool SetRootNamespace(string rootNamespace)
{
- _options.RootNamespace = rootNamespace;
+ if (!string.IsNullOrWhiteSpace(rootNamespace))
+ {
+ _commandLineArgs.Add("/rootnamespace:\"" + rootNamespace + "\"");
+ }
+
return true;
}
public bool SetSdkPath(string sdkPath)
{
- _sdkPath = sdkPath;
+ if (!string.IsNullOrWhiteSpace(sdkPath))
+ {
+ _commandLineArgs.Add("/sdkpath:\"" + sdkPath + "\"");
+ }
+
return true;
}
- public bool SetSources(Microsoft.Build.Framework.ITaskItem[] sources)
+ public bool SetSources(ITaskItem[] sources)
{
- _sources = sources ?? SpecializedCollections.EmptyEnumerable();
+ if (sources != null)
+ {
+ _sources = sources;
+ }
+
return true;
}
public bool SetTargetCompactFramework(bool targetCompactFramework)
{
- _targetCompactFramework = targetCompactFramework;
+ if (targetCompactFramework)
+ {
+ _commandLineArgs.Add("/netcf");
+ }
+
return true;
}
public bool SetTargetType(string targetType)
{
- if (!string.IsNullOrEmpty(targetType))
+ if (!string.IsNullOrWhiteSpace(targetType))
{
- OutputKind outputKind;
- if (VisualBasicProjectFile.TryGetOutputKind(targetType, out outputKind))
- {
- _options.OutputKind = outputKind;
- }
+ _targetType = targetType.ToLower();
}
+
return true;
}
public bool SetRuleSet(string ruleSetFile)
{
- _options.RuleSetFile = ruleSetFile;
+ if (!string.IsNullOrWhiteSpace(ruleSetFile))
+ {
+ _commandLineArgs.Add("/ruleset:\"" + ruleSetFile + "\"");
+ }
+
return true;
}
public bool SetTreatWarningsAsErrors(bool treatWarningsAsErrors)
{
- _options.WarningsAsErrors = treatWarningsAsErrors;
+ if (treatWarningsAsErrors)
+ {
+ _commandLineArgs.Add("/warnaserror");
+ }
+
return true;
}
public bool SetWarningsAsErrors(string warningsAsErrors)
{
- SetWarnings(warningsAsErrors, ReportDiagnostic.Error);
+ if (!string.IsNullOrWhiteSpace(warningsAsErrors))
+ {
+ _commandLineArgs.Add("/warnaserror+:" + warningsAsErrors);
+ }
+
return true;
}
- private static readonly char[] s_warningSeparators = { ';', ',' };
-
- private void SetWarnings(string warnings, ReportDiagnostic reportStyle)
+ public bool SetWarningsNotAsErrors(string warningsNotAsErrors)
{
- if (!string.IsNullOrEmpty(warnings))
+ if (!string.IsNullOrWhiteSpace(warningsNotAsErrors))
{
- foreach (var warning in warnings.Split(s_warningSeparators, StringSplitOptions.None))
- {
- int warningId = 0;
- if (Int32.TryParse(warning, out warningId))
- {
- _warnings["BC" + warningId.ToString("0000")] = reportStyle;
- }
- else
- {
- _warnings[warning] = reportStyle;
- }
- }
+ _commandLineArgs.Add("/warnaserror-:" + warningsNotAsErrors);
}
- }
- public bool SetWarningsNotAsErrors(string warningsNotAsErrors)
- {
- SetWarnings(warningsNotAsErrors, ReportDiagnostic.Warn);
return true;
}
public bool SetWin32Icon(string win32Icon)
{
+ if (!string.IsNullOrWhiteSpace(win32Icon))
+ {
+ _commandLineArgs.Add("/win32icon:\"" + win32Icon + "\"");
+ }
+
return true;
}
public bool SetWin32Resource(string win32Resource)
{
+ if (!string.IsNullOrWhiteSpace(win32Resource))
+ {
+ _commandLineArgs.Add("/win32resource:\"" + win32Resource + "\"");
+ }
+
return true;
}
public bool SetModuleAssemblyName(string moduleAssemblyName)
{
+ if (!string.IsNullOrWhiteSpace(moduleAssemblyName))
+ {
+ _commandLineArgs.Add("/moduleassemblyname:\"" + moduleAssemblyName + "\"");
+ }
+
return true;
}
public bool SetOptionInfer(bool optionInfer)
{
- _options.OptionInfer = optionInfer;
+ if (optionInfer)
+ {
+ _commandLineArgs.Add("/optioninfer");
+ }
+
return true;
}
public bool SetWin32Manifest(string win32Manifest)
{
- return true;
- }
+ if (!string.IsNullOrWhiteSpace(win32Manifest))
+ {
+ _commandLineArgs.Add("/win32manifest:\"" + win32Manifest + "\"");
+ }
- public bool SetLanguageVersion(string _languageVersion)
- {
- _options.LanguageVersion = _languageVersion;
return true;
}
- public bool SetVBRuntime(string VBRuntime)
+ public bool SetLanguageVersion(string languageVersion)
{
- _vbRuntime = VBRuntime;
- _options.VBRuntime = VBRuntime;
- return true;
- }
+ if (!string.IsNullOrWhiteSpace(languageVersion))
+ {
+ _commandLineArgs.Add("/languageversion:" + languageVersion);
+ }
- public int CompileAsync(out IntPtr buildSucceededEvent, out IntPtr buildFailedEvent)
- {
- buildSucceededEvent = IntPtr.Zero;
- buildFailedEvent = IntPtr.Zero;
- return 0;
+ return true;
}
- public int EndCompile(bool buildSuccess)
+ public bool SetVBRuntime(string vbRuntime)
{
- return 0;
- }
+ if (!string.IsNullOrEmpty(vbRuntime))
+ {
+ if (string.Equals("Default", vbRuntime, StringComparison.OrdinalIgnoreCase))
+ {
+ _commandLineArgs.Add("/vbruntime+");
+ }
+ else if (string.Equals("Embed", vbRuntime, StringComparison.OrdinalIgnoreCase))
+ {
+ _commandLineArgs.Add("/vbruntime*");
+ }
+ else if (string.Equals("None", vbRuntime, StringComparison.OrdinalIgnoreCase))
+ {
+ _commandLineArgs.Add("/vbruntime-");
+ }
+ else
+ {
+ _commandLineArgs.Add("/vbruntime:\"" + vbRuntime + "\"");
+ }
+ }
- public Microsoft.Build.Tasks.Hosting.IVbcHostObjectFreeThreaded GetFreeThreadedHostObject()
- {
- return null;
+ return true;
}
public bool SetHighEntropyVA(bool highEntropyVA)
{
- // we don't capture emit options
+ if (highEntropyVA)
+ {
+ _commandLineArgs.Add("/highentropyva");
+ }
+
return true;
}
public bool SetSubsystemVersion(string subsystemVersion)
{
- // we don't capture emit options
- return true;
- }
+ if (!string.IsNullOrWhiteSpace(subsystemVersion))
+ {
+ _commandLineArgs.Add("/subsystemversion:" + subsystemVersion);
+ }
- public bool Compile1()
- {
- return false;
- }
- bool Microsoft.Build.Tasks.Hosting.IVbcHostObjectFreeThreaded.Compile()
- {
- return Compile1();
+ return true;
}
}
}
diff --git a/src/Workspaces/Core/Desktop/Workspace/MSBuild/VisualBasic/VisualBasicProjectFileLoaderFactory.cs b/src/Workspaces/Core/Desktop/Workspace/MSBuild/VisualBasic/VisualBasicProjectFileLoaderFactory.cs
index 99e574148fe2943a50d0a0506bb13c3dd2533566..c50945e3d4c40450ad5fdc87d22edbca4dc6d449 100644
--- a/src/Workspaces/Core/Desktop/Workspace/MSBuild/VisualBasic/VisualBasicProjectFileLoaderFactory.cs
+++ b/src/Workspaces/Core/Desktop/Workspace/MSBuild/VisualBasic/VisualBasicProjectFileLoaderFactory.cs
@@ -14,7 +14,7 @@ internal class VisualBasicProjectFileLoaderFactory : ILanguageServiceFactory
{
public ILanguageService CreateLanguageService(HostLanguageServices languageServices)
{
- return new VisualBasicProjectFileLoader(languageServices.WorkspaceServices);
+ return new VisualBasicProjectFileLoader();
}
}
}
\ No newline at end of file
diff --git a/src/Workspaces/Core/Portable/HostBuild.cs b/src/Workspaces/Core/Portable/HostBuild.cs
deleted file mode 100644
index 40d03261ef0608abed249f795a890c4bd2ebd1c1..0000000000000000000000000000000000000000
--- a/src/Workspaces/Core/Portable/HostBuild.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Host;
-
-namespace Microsoft.CodeAnalysis
-{
- internal sealed class HostBuildOptions
- {
- public string ProjectDirectory { get; set; }
- public string OutputDirectory { get; set; }
- public string DefineConstants { get; set; }
- public string DocumentationFile { get; set; }
- public string LanguageVersion { get; set; }
- public string PlatformWith32BitPreference { get; set; }
- public string ApplicationConfiguration { get; set; }
- public string KeyContainer { get; set; }
- public string KeyFile { get; set; }
- public string MainEntryPoint { get; set; }
- public string ModuleAssemblyName { get; set; }
- public string Platform { get; set; }
- public string RuleSetFile { get; set; }
- public string OptionCompare { get; set; }
- public string OptionStrict { get; set; }
- public string RootNamespace { get; set; }
- public string VBRuntime { get; set; }
- public bool? AllowUnsafeBlocks { get; set; }
- public bool? CheckForOverflowUnderflow { get; set; }
- public bool? Optimize { get; set; }
- public bool? WarningsAsErrors { get; set; }
- public bool? NoWarnings { get; set; }
- public bool? OptionExplicit { get; set; }
- public bool? OptionInfer { get; set; }
- public int? WarningLevel { get; set; }
- public OutputKind? OutputKind { get; set; }
- public Tuple DelaySign { get; set; }
- public List GlobalImports { get; set; }
- public Dictionary Warnings { get; set; }
-
- internal HostBuildOptions()
- {
- Warnings = new Dictionary();
- GlobalImports = new List();
- }
- }
-
- internal sealed class HostBuildData
- {
- internal readonly ParseOptions ParseOptions;
-
- internal readonly CompilationOptions CompilationOptions;
-
- internal HostBuildData(ParseOptions parseOptions, CompilationOptions compilationOptions)
- {
- ParseOptions = parseOptions;
- CompilationOptions = compilationOptions;
- }
- }
-
- internal interface IHostBuildDataFactory : ILanguageService
- {
- HostBuildData Create(HostBuildOptions options);
- }
-}
diff --git a/src/Workspaces/Core/Portable/Workspace/Host/CommandLineArgumentsFactory/ICommandLineArgumentsFactoryService.cs b/src/Workspaces/Core/Portable/Workspace/Host/CommandLine/ICommandLineParserService.cs
similarity index 52%
rename from src/Workspaces/Core/Portable/Workspace/Host/CommandLineArgumentsFactory/ICommandLineArgumentsFactoryService.cs
rename to src/Workspaces/Core/Portable/Workspace/Host/CommandLine/ICommandLineParserService.cs
index adf93cb4a7b71c7a8ea9a666fcfc63b45d941504..f6589b4a10f9437741c25fb762867874b33b8670 100644
--- a/src/Workspaces/Core/Portable/Workspace/Host/CommandLineArgumentsFactory/ICommandLineArgumentsFactoryService.cs
+++ b/src/Workspaces/Core/Portable/Workspace/Host/CommandLine/ICommandLineParserService.cs
@@ -4,8 +4,8 @@
namespace Microsoft.CodeAnalysis.Host
{
- internal interface ICommandLineArgumentsFactoryService : ILanguageService
+ internal interface ICommandLineParserService : ILanguageService
{
- CommandLineArguments CreateCommandLineArguments(IEnumerable arguments, string baseDirectory, bool isInteractive, string sdkDirectory);
+ CommandLineArguments Parse(IEnumerable arguments, string baseDirectory, bool isInteractive, string sdkDirectory);
}
}
diff --git a/src/Workspaces/Core/Portable/Workspaces.csproj b/src/Workspaces/Core/Portable/Workspaces.csproj
index ac6289ff0925a621ebfa56daadae819c084ad523..4367b888db82e4417568b2bc223f9e57fdf22a03 100644
--- a/src/Workspaces/Core/Portable/Workspaces.csproj
+++ b/src/Workspaces/Core/Portable/Workspaces.csproj
@@ -406,7 +406,6 @@
-
@@ -580,7 +579,7 @@
-
+
diff --git a/src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs b/src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
index f21814420acfa29be9d395e68cb737796327dfcb..f805c7744200b4afd8fc07eaac0cee6edf38ef66 100644
--- a/src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
+++ b/src/Workspaces/CoreTest/WorkspaceTests/MSBuildWorkspaceTests.cs
@@ -1563,6 +1563,13 @@ public void TestCompilationOptions_VisualBasic_OptionStrict_On()
public void TestCompilationOptions_VisualBasic_OptionStrict_Off()
{
CreateVBFilesWith("OptionStrict", "Off");
+ AssertVBOptions(Microsoft.CodeAnalysis.VisualBasic.OptionStrict.Off, options => options.OptionStrict);
+ }
+
+ [Fact, Trait(Traits.Feature, Traits.Features.Workspace)]
+ public void TestCompilationOptions_VisualBasic_OptionStrict_Custom()
+ {
+ CreateVBFilesWith("OptionStrict", "Custom");
AssertVBOptions(Microsoft.CodeAnalysis.VisualBasic.OptionStrict.Custom, options => options.OptionStrict);
}
diff --git a/src/Workspaces/VisualBasic/Portable/BasicWorkspace.vbproj b/src/Workspaces/VisualBasic/Portable/BasicWorkspace.vbproj
index 38b0bef4fcab3c391ae05ec361b844becf093efa..7f99d682b01a33c4bf1cccfe1240dcfa08fbe968 100644
--- a/src/Workspaces/VisualBasic/Portable/BasicWorkspace.vbproj
+++ b/src/Workspaces/VisualBasic/Portable/BasicWorkspace.vbproj
@@ -200,7 +200,7 @@
-
+
diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicCommandLineParserService.vb b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicCommandLineParserService.vb
new file mode 100644
index 0000000000000000000000000000000000000000..644c9bf786cd4fdf1cc9c267e3cd8afc1011003f
--- /dev/null
+++ b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicCommandLineParserService.vb
@@ -0,0 +1,31 @@
+' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+Imports System.Collections.Immutable
+Imports System.Composition
+Imports System.Linq
+Imports System.Runtime.InteropServices
+Imports System.Threading
+Imports Microsoft.CodeAnalysis.Host
+Imports Microsoft.CodeAnalysis.Host.Mef
+Imports Microsoft.CodeAnalysis.LanguageServices
+Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
+Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
+Imports Roslyn.Utilities
+
+Namespace Microsoft.CodeAnalysis.VisualBasic
+
+
+ Friend Class VisualBasicCommandLineArgumentsFactoryService
+ Implements ICommandLineParserService
+
+ Public Function Parse(arguments As IEnumerable(Of String), baseDirectory As String, isInteractive As Boolean, sdkDirectory As String) As CommandLineArguments Implements ICommandLineParserService.Parse
+#If SCRIPTING Then
+ Dim parser = If(isInteractive, VisualBasicCommandLineParser.Interactive, VisualBasicCommandLineParser.Default)
+#Else
+ Dim parser = VisualBasicCommandLineParser.Default
+#End If
+ Return parser.Parse(arguments, baseDirectory, sdkDirectory)
+ End Function
+ End Class
+End Namespace
+
diff --git a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicHostBuildDataFactory.vb b/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicHostBuildDataFactory.vb
deleted file mode 100644
index f26deece51861becd1577116f77e01ea4fbd9252..0000000000000000000000000000000000000000
--- a/src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicHostBuildDataFactory.vb
+++ /dev/null
@@ -1,188 +0,0 @@
-' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-Imports System.Collections.Immutable
-Imports System.Composition
-Imports System.Linq
-Imports System.Runtime.InteropServices
-Imports System.Threading
-Imports Microsoft.CodeAnalysis.Host
-Imports Microsoft.CodeAnalysis.Host.Mef
-Imports Microsoft.CodeAnalysis.LanguageServices
-Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
-Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
-Imports Roslyn.Utilities
-
-Namespace Microsoft.CodeAnalysis.VisualBasic
-
-
- Friend Class VisualBasicCommandLineArgumentsFactoryService
- Implements ICommandLineArgumentsFactoryService
-
- Public Function CreateCommandLineArguments(arguments As IEnumerable(Of String), baseDirectory As String, isInteractive As Boolean, sdkDirectory As String) As CommandLineArguments Implements ICommandLineArgumentsFactoryService.CreateCommandLineArguments
- Dim parser = If(isInteractive, VisualBasicCommandLineParser.Interactive, VisualBasicCommandLineParser.Default)
- Return parser.Parse(arguments, baseDirectory, sdkDirectory)
- End Function
- End Class
-
-
-
- Friend Class VisualBasicHostBuildDataFactory
- Implements IHostBuildDataFactory
-
- Public Function Create(options As HostBuildOptions) As HostBuildData Implements IHostBuildDataFactory.Create
-
- Dim parseOptions = VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Parse)
- Dim compilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication,
- xmlReferenceResolver:=New XmlFileResolver(options.ProjectDirectory),
- sourceReferenceResolver:=New SourceFileResolver(ImmutableArray(Of String).Empty, options.ProjectDirectory),
- metadataReferenceResolver:=New AssemblyReferenceResolver(
- New MetadataFileReferenceResolver(ImmutableArray(Of String).Empty, options.ProjectDirectory),
- MetadataFileReferenceProvider.Default),
- strongNameProvider:=New DesktopStrongNameProvider(ImmutableArray.Create(Of String)(options.ProjectDirectory, options.OutputDirectory)),
- assemblyIdentityComparer:=DesktopAssemblyIdentityComparer.Default)
-
- If Not String.IsNullOrEmpty(options.PlatformWith32BitPreference) Then
- Dim plat As Platform
- If [Enum].TryParse(options.PlatformWith32BitPreference, True, plat) Then
- Dim outputKind = compilationOptions.OutputKind
- If plat = Platform.AnyCpu AndAlso outputKind <> OutputKind.DynamicallyLinkedLibrary AndAlso outputKind <> OutputKind.NetModule AndAlso outputKind <> OutputKind.WindowsRuntimeMetadata Then
- plat = Platform.AnyCpu32BitPreferred
- End If
- compilationOptions = compilationOptions.WithPlatform(plat)
- End If
- End If
-
- Dim warnings = New Dictionary(Of String, ReportDiagnostic)()
-
- If options.OutputKind.HasValue Then
- Dim _outputKind = options.OutputKind.Value
- compilationOptions = compilationOptions.WithOutputKind(_outputKind)
- If compilationOptions.Platform = Platform.AnyCpu32BitPreferred AndAlso
- (_outputKind = OutputKind.DynamicallyLinkedLibrary Or _outputKind = OutputKind.NetModule Or _outputKind = OutputKind.WindowsRuntimeMetadata) Then
- compilationOptions = compilationOptions.WithPlatform(Platform.AnyCpu)
- End If
- End If
-
- If Not String.IsNullOrEmpty(options.DefineConstants) Then
- Dim errors As IEnumerable(Of Diagnostic) = Nothing
- parseOptions = parseOptions.WithPreprocessorSymbols(VisualBasicCommandLineParser.ParseConditionalCompilationSymbols(options.DefineConstants, errors))
- End If
-
- If options.DelaySign IsNot Nothing Then
- compilationOptions = compilationOptions.WithDelaySign(options.DelaySign.Item1)
- End If
-
- If Not String.IsNullOrEmpty(options.DocumentationFile) Then
- parseOptions = parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)
- Else
- parseOptions = parseOptions.WithDocumentationMode(DocumentationMode.Parse)
- End If
-
- If options.GlobalImports.Count > 0 Then
- Dim e = options.GlobalImports.Select(Function(item) GlobalImport.Parse(item)).AsImmutable()
- compilationOptions = compilationOptions.WithGlobalImports(e)
- End If
-
- If Not String.IsNullOrEmpty(options.KeyContainer) Then
- compilationOptions = compilationOptions.WithCryptoKeyContainer(options.KeyContainer)
- End If
-
- If Not String.IsNullOrEmpty(options.KeyFile) Then
- compilationOptions = compilationOptions.WithCryptoKeyFile(options.KeyFile)
- End If
-
- If Not String.IsNullOrEmpty(options.MainEntryPoint) AndAlso options.MainEntryPoint <> "Sub Main" Then
- compilationOptions = compilationOptions.WithMainTypeName(options.MainEntryPoint)
- End If
-
- If options.NoWarnings.HasValue Then
- compilationOptions = compilationOptions.WithGeneralDiagnosticOption(If(options.NoWarnings.Value, ReportDiagnostic.Suppress, ReportDiagnostic.Warn))
- End If
-
- If options.Optimize.HasValue Then
- compilationOptions = compilationOptions.WithOptimizationLevel(If(options.Optimize, OptimizationLevel.Release, OptimizationLevel.Debug))
- End If
-
- If Not String.IsNullOrEmpty(options.OptionCompare) Then
- compilationOptions = compilationOptions.WithOptionCompareText(options.OptionCompare = "Text")
- End If
-
- If options.OptionExplicit.HasValue Then
- compilationOptions = compilationOptions.WithOptionExplicit(options.OptionExplicit.Value)
- End If
-
- If Not String.IsNullOrEmpty(options.OptionStrict) Then
- Dim _optionStrict As OptionStrict = OptionStrict.Custom
- If TryGetOptionStrict(options.OptionStrict, _optionStrict) Then
- compilationOptions = compilationOptions.WithOptionStrict(_optionStrict)
- End If
- End If
-
- If Not String.IsNullOrEmpty(options.Platform) Then
- Dim plat As Platform
- If [Enum].TryParse(options.Platform, plat) Then
- compilationOptions = compilationOptions.WithPlatform(plat)
- End If
- End If
-
- If options.CheckForOverflowUnderflow.HasValue Then
- compilationOptions = compilationOptions.WithOverflowChecks(options.CheckForOverflowUnderflow.Value)
- End If
-
- If Not String.IsNullOrEmpty(options.RootNamespace) Then
- compilationOptions = compilationOptions.WithRootNamespace(options.RootNamespace)
- End If
-
- If Not String.IsNullOrEmpty(options.RuleSetFile) Then
- Dim fullPath = FileUtilities.ResolveRelativePath(options.RuleSetFile, options.ProjectDirectory)
-
- Dim specificDiagnosticOptions As Dictionary(Of String, ReportDiagnostic) = Nothing
- Dim generalDiagnosticOption = RuleSet.GetDiagnosticOptionsFromRulesetFile(fullPath, specificDiagnosticOptions)
- compilationOptions = compilationOptions.WithGeneralDiagnosticOption(generalDiagnosticOption)
- warnings.AddRange(specificDiagnosticOptions)
- End If
-
- If options.WarningsAsErrors.HasValue Then
- compilationOptions = compilationOptions.WithGeneralDiagnosticOption(If(options.WarningsAsErrors.Value, ReportDiagnostic.Error, ReportDiagnostic.Warn))
- End If
-
- If options.OptionInfer.HasValue Then
- compilationOptions = compilationOptions.WithOptionInfer(options.OptionInfer.Value)
- End If
-
- If options.VBRuntime = "Embed" Then
- compilationOptions = compilationOptions.WithEmbedVbCoreRuntime(True)
- End If
-
- If Not String.IsNullOrEmpty(options.LanguageVersion) Then
- Dim version As Integer
- If Int32.TryParse(options.LanguageVersion, version) Then
- Dim lv As LanguageVersion = CType(version, LanguageVersion)
- If [Enum].IsDefined(GetType(LanguageVersion), lv) Then
- parseOptions = parseOptions.WithLanguageVersion(lv)
- End If
- End If
- End If
-
- parseOptions = parseOptions.WithPreprocessorSymbols(AddPredefinedPreprocessorSymbols(compilationOptions.OutputKind, parseOptions.PreprocessorSymbols))
- compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(warnings)
- Return New HostBuildData(parseOptions, compilationOptions)
- End Function
-
- Private Shared Function TryGetOptionStrict(text As String, ByRef optionStrictType As OptionStrict) As Boolean
- If text = "On" Then
- optionStrictType = OptionStrict.On
- Return True
- ElseIf text = "Off" OrElse text = "Custom" Then
- optionStrictType = OptionStrict.Custom
- Return True
- Else
- Return False
- End If
- End Function
-
-
- End Class
-
-End Namespace
-