本文整理汇总了C#中Microsoft.CodeAnalysis.CommandLineArguments类的典型用法代码示例。如果您正苦于以下问题:C# CommandLineArguments类的具体用法?C# CommandLineArguments怎么用?C# CommandLineArguments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandLineArguments类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了CommandLineArguments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateParseOptions
/// <summary>
/// Creates new parse options from parsed command line arguments (with overridden default DocumentationMode).
/// It is expected that derived types which need to add more specific options will fetch the base options and override those options.
/// </summary>
protected virtual ParseOptions CreateParseOptions(CommandLineArguments commandLineArguments)
{
Contract.ThrowIfNull(commandLineArguments);
// Override the default documentation mode.
var documentationMode = commandLineArguments.DocumentationPath != null ? DocumentationMode.Diagnose : DocumentationMode.Parse;
return commandLineArguments.ParseOptions.WithDocumentationMode(documentationMode);
}
示例2: SetArgumentsCore
private void SetArgumentsCore(string commandLine, CommandLineArguments commandLineArguments)
{
lock (_gate)
{
_lastParsedCompilerOptions = commandLine;
_lastParsedCommandLineArguments = commandLineArguments;
}
}
示例3: PostSetOptions
private void PostSetOptions(CommandLineArguments commandLineArguments)
{
// Invoke SetOutputPathAndRelatedData to update the project obj output path.
if (commandLineArguments.OutputFileName != null && commandLineArguments.OutputDirectory != null)
{
var objOutputPath = PathUtilities.CombinePathsUnchecked(commandLineArguments.OutputDirectory, commandLineArguments.OutputFileName);
SetObjOutputPathAndRelatedData(objOutputPath);
}
}
示例4: PostSetCommandLineArguments
private void PostSetCommandLineArguments(CommandLineArguments commandLineArguments)
{
// Invoke SetOutputPathAndRelatedData to update the project tracker bin path for this project, if required.
if (commandLineArguments.OutputFileName != null && commandLineArguments.OutputDirectory != null)
{
var newOutputPath = PathUtilities.CombinePathsUnchecked(commandLineArguments.OutputDirectory, commandLineArguments.OutputFileName);
SetOutputPathAndRelatedData(newOutputPath, hasSameBinAndObjOutputPaths: true);
}
}
示例5: ResetArgumentsAndUpdateOptions
/// <summary>
/// Resets the last parsed command line and updates options with the same command line.
/// </summary>
/// <remarks>
/// Use this method when options can go stale due to side effects, even though the command line is identical.
/// For example, changes to contents of a ruleset file needs to force update the options for the same command line.
/// </remarks>
protected CommandLineArguments ResetArgumentsAndUpdateOptions()
{
// Clear last parsed command line.
var savedLastParsedCompilerOptions = _lastParsedCompilerOptions;
_lastParsedCompilerOptions = null;
_lastParsedCommandLineArguments = null;
// Now set arguments and update options with the saved command line.
return SetArgumentsAndUpdateOptions(savedLastParsedCompilerOptions);
}
示例6: SetArguments
/// <summary>
/// If the command line has changed from the last parsed command line, then it parses it and sets new command line arguments.
/// </summary>
/// <param name="commandlineForOptions"></param>
/// <returns></returns>
protected CommandLineArguments SetArguments(string commandlineForOptions)
{
if (!string.Equals(_lastParsedCompilerOptions, commandlineForOptions, StringComparison.OrdinalIgnoreCase))
{
// Command line options have changed, so update options with new parsed CommandLineArguments.
var splitArguments = CommandLineParser.SplitCommandLineIntoArguments(commandlineForOptions, removeHashComments: false);
_lastParsedCommandLineArguments = CommandLineParserService?.Parse(splitArguments, this.ContainingDirectoryPathOpt, isInteractive: false, sdkDirectory: null);
_lastParsedCompilerOptions = commandlineForOptions;
}
return _lastParsedCommandLineArguments;
}
示例7: CPSProject
IProjectContext IProjectContextFactory.CreateProjectContext(
string languageName,
string projectDisplayName,
string projectFilePath,
Guid projectGuid,
string projectTypeGuid,
IVsHierarchy hierarchy,
CommandLineArguments commandLineArguments)
{
Contract.ThrowIfNull(hierarchy);
Func<ProjectId, IVsReportExternalErrors> getExternalErrorReporter = id => GetExternalErrorReporter(id, languageName);
return new CPSProject(commandLineArguments, _projectTracker, getExternalErrorReporter, projectDisplayName, projectFilePath,
projectGuid, projectTypeGuid, hierarchy, languageName, _serviceProvider, _visualStudioWorkspace, _hostDiagnosticUpdateSource);
}
示例8: ParseCommandLineArguments
int ICompilerOptionsHostObject.SetCompilerOptions(string compilerOptions, out bool supported)
{
if (!string.Equals(_lastParsedCompilerOptions, compilerOptions))
{
var splitArguments = CommandLineParser.SplitCommandLineIntoArguments(compilerOptions, removeHashComments: false);
_lastParsedCommandLineArguments = ParseCommandLineArguments(splitArguments);
_lastParsedCompilerOptions = compilerOptions;
UpdateOptions();
}
supported = true;
return VSConstants.S_OK;
}
示例9: CreateCompilationOptions
/// <summary>
/// Creates new compilation options from parsed command line arguments, with additional workspace specific options appended.
/// It is expected that derived types which need to add more specific options will fetch the base options and override those options.
/// </summary>
protected virtual CompilationOptions CreateCompilationOptions(CommandLineArguments commandLineArguments, ParseOptions newParseOptions)
{
Contract.ThrowIfNull(commandLineArguments);
// Get options from command line arguments.
var options = commandLineArguments.CompilationOptions;
// Now set the default workspace options (these are not set by the command line parser).
string projectDirectory = this.ContainingDirectoryPathOpt;
// TODO: #r support, should it include bin path?
var referenceSearchPaths = ImmutableArray<string>.Empty;
// TODO: #load support
var sourceSearchPaths = ImmutableArray<string>.Empty;
MetadataReferenceResolver referenceResolver;
if (Workspace != null)
{
referenceResolver = new WorkspaceMetadataFileReferenceResolver(
Workspace.CurrentSolution.Services.MetadataService,
new RelativePathResolver(referenceSearchPaths, projectDirectory));
}
else
{
// can only happen in tests
referenceResolver = null;
}
// Explicitly disable concurrent build.
options = options.WithConcurrentBuild(concurrent: false);
// Set default resolvers.
options = options.WithMetadataReferenceResolver(referenceResolver)
.WithXmlReferenceResolver(new XmlFileResolver(projectDirectory))
.WithSourceReferenceResolver(new SourceFileResolver(sourceSearchPaths, projectDirectory))
.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default)
.WithStrongNameProvider(new DesktopStrongNameProvider(GetStrongNameKeyPaths()));
return options;
}
示例10: CPSProject
public CPSProject(
CommandLineArguments commandLineArguments,
VisualStudioProjectTracker projectTracker,
Func<ProjectId, IVsReportExternalErrors> reportExternalErrorCreatorOpt,
string projectDisplayName,
string projectFilePath,
Guid projectGuid,
string projectTypeGuid,
IVsHierarchy hierarchy,
string language,
IServiceProvider serviceProvider,
VisualStudioWorkspaceImpl visualStudioWorkspaceOpt,
HostDiagnosticUpdateSource hostDiagnosticUpdateSourceOpt)
: base(projectTracker, reportExternalErrorCreatorOpt, projectDisplayName, projectFilePath, projectGuid,
projectTypeGuid, hierarchy, language, serviceProvider, visualStudioWorkspaceOpt, hostDiagnosticUpdateSourceOpt)
{
// Set the initial options from the command line before we add the project to the project tracker.
SetCommandLineArguments(commandLineArguments);
projectTracker.AddProject(this);
}
示例11: CreateCompilationOptions
protected override CompilationOptions CreateCompilationOptions(CommandLineArguments commandLineArguments, ParseOptions newParseOptions)
{
// Get the base options from command line arguments + common workspace defaults.
var options = (CSharpCompilationOptions)base.CreateCompilationOptions(commandLineArguments, newParseOptions);
// Now override these with the options from our state.
IDictionary<string, ReportDiagnostic> ruleSetSpecificDiagnosticOptions = null;
// Get options from the ruleset file, if any, first. That way project-specific
// options can override them.
ReportDiagnostic? ruleSetGeneralDiagnosticOption = null;
if (this.RuleSetFile != null)
{
ruleSetGeneralDiagnosticOption = this.RuleSetFile.GetGeneralDiagnosticOption();
ruleSetSpecificDiagnosticOptions = new Dictionary<string, ReportDiagnostic>(this.RuleSetFile.GetSpecificDiagnosticOptions());
}
else
{
ruleSetSpecificDiagnosticOptions = new Dictionary<string, ReportDiagnostic>();
}
UpdateRuleSetError(this.RuleSetFile);
ReportDiagnostic generalDiagnosticOption;
var warningsAreErrors = GetNullableBooleanOption(CompilerOptions.OPTID_WARNINGSAREERRORS);
if (warningsAreErrors.HasValue)
{
generalDiagnosticOption = warningsAreErrors.Value ? ReportDiagnostic.Error : ReportDiagnostic.Default;
}
else if (ruleSetGeneralDiagnosticOption.HasValue)
{
generalDiagnosticOption = ruleSetGeneralDiagnosticOption.Value;
}
else
{
generalDiagnosticOption = ReportDiagnostic.Default;
}
// Start with the rule set options
IDictionary<string, ReportDiagnostic> diagnosticOptions = new Dictionary<string, ReportDiagnostic>(ruleSetSpecificDiagnosticOptions);
// Update the specific options based on the general settings
if (warningsAreErrors.HasValue && warningsAreErrors.Value == true)
{
foreach (var pair in ruleSetSpecificDiagnosticOptions)
{
if (pair.Value == ReportDiagnostic.Warn)
{
diagnosticOptions[pair.Key] = ReportDiagnostic.Error;
}
}
}
// Update the specific options based on the specific settings
foreach (var diagnosticID in ParseWarningCodes(CompilerOptions.OPTID_WARNASERRORLIST))
{
diagnosticOptions[diagnosticID] = ReportDiagnostic.Error;
}
foreach (var diagnosticID in ParseWarningCodes(CompilerOptions.OPTID_WARNNOTASERRORLIST))
{
ReportDiagnostic ruleSetOption;
if (ruleSetSpecificDiagnosticOptions.TryGetValue(diagnosticID, out ruleSetOption))
{
diagnosticOptions[diagnosticID] = ruleSetOption;
}
else
{
diagnosticOptions[diagnosticID] = ReportDiagnostic.Default;
}
}
foreach (var diagnosticID in ParseWarningCodes(CompilerOptions.OPTID_NOWARNLIST))
{
diagnosticOptions[diagnosticID] = ReportDiagnostic.Suppress;
}
Platform platform;
if (!Enum.TryParse(GetStringOption(CompilerOptions.OPTID_PLATFORM, ""), ignoreCase: true, result: out platform))
{
platform = Platform.AnyCpu;
}
int warningLevel;
if (!int.TryParse(GetStringOption(CompilerOptions.OPTID_WARNINGLEVEL, defaultValue: ""), out warningLevel))
{
warningLevel = 4;
}
// TODO: appConfigPath: GetFilePathOption(CompilerOptions.OPTID_FUSIONCONFIG), bug #869604
return options.WithAllowUnsafe(GetBooleanOption(CompilerOptions.OPTID_UNSAFE))
.WithOverflowChecks(GetBooleanOption(CompilerOptions.OPTID_CHECKED))
.WithCryptoKeyContainer(GetStringOption(CompilerOptions.OPTID_KEYNAME, defaultValue: null))
.WithCryptoKeyFile(GetFilePathRelativeOption(CompilerOptions.OPTID_KEYFILE))
.WithDelaySign(GetNullableBooleanOption(CompilerOptions.OPTID_DELAYSIGN))
.WithGeneralDiagnosticOption(generalDiagnosticOption)
.WithMainTypeName(_mainTypeName)
//.........这里部分代码省略.........
示例12: CreateParseOptions
protected override ParseOptions CreateParseOptions(CommandLineArguments commandLineArguments)
{
// Get the base parse options and override the defaults with the options from state.
var options = (CSharpParseOptions)base.CreateParseOptions(commandLineArguments);
var symbols = GetStringOption(CompilerOptions.OPTID_CCSYMBOLS, defaultValue: "").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
DocumentationMode documentationMode = DocumentationMode.Parse;
if (GetStringOption(CompilerOptions.OPTID_XML_DOCFILE, defaultValue: null) != null)
{
documentationMode = DocumentationMode.Diagnose;
}
var languageVersion = CompilationOptionsConversion.GetLanguageVersion(GetStringOption(CompilerOptions.OPTID_COMPATIBILITY, defaultValue: ""))
?? CSharpParseOptions.Default.LanguageVersion;
return options.WithKind(SourceCodeKind.Regular)
.WithLanguageVersion(languageVersion)
.WithPreprocessorSymbols(symbols.AsImmutable())
.WithDocumentationMode(documentationMode);
}
示例13: OpenManifestStream
private static Stream OpenManifestStream(CommonMessageProvider messageProvider, OutputKind outputKind, CommandLineArguments arguments, List<DiagnosticInfo> errorList)
{
return outputKind.IsNetModule()
? null
: OpenStream(messageProvider, arguments.Win32Manifest, arguments.BaseDirectory, messageProvider.ERR_CantOpenWin32Manifest, errorList);
}
示例14: GetWin32ResourcesInternal
// internal for testing
internal static Stream GetWin32ResourcesInternal(CommonMessageProvider messageProvider, CommandLineArguments arguments, Compilation compilation, out IEnumerable<DiagnosticInfo> errors)
{
List<DiagnosticInfo> errorList = new List<DiagnosticInfo>();
errors = errorList;
if (arguments.Win32ResourceFile != null)
{
return OpenStream(messageProvider, arguments.Win32ResourceFile, arguments.BaseDirectory, messageProvider.ERR_CantOpenWin32Resource, errorList);
}
using (Stream manifestStream = OpenManifestStream(messageProvider, compilation.Options.OutputKind, arguments, errorList))
{
using (Stream iconStream = OpenStream(messageProvider, arguments.Win32Icon, arguments.BaseDirectory, messageProvider.ERR_CantOpenWin32Icon, errorList))
{
try
{
return compilation.CreateDefaultWin32Resources(true, arguments.NoWin32Manifest, manifestStream, iconStream);
}
catch (ResourceException ex)
{
errorList.Add(new DiagnosticInfo(messageProvider, messageProvider.ERR_ErrorBuildingWin32Resource, ex.Message));
}
catch (OverflowException ex)
{
errorList.Add(new DiagnosticInfo(messageProvider, messageProvider.ERR_ErrorBuildingWin32Resource, ex.Message));
}
}
}
return null;
}
示例15: GetWin32Resources
protected Stream GetWin32Resources(CommandLineArguments arguments, Compilation compilation, out IEnumerable<DiagnosticInfo> errors)
{
return GetWin32ResourcesInternal(MessageProvider, arguments, compilation, out errors);
}