本文整理汇总了C#中Microsoft.CodeAnalysis.CommandLineArguments类的典型用法代码示例。如果您正苦于以下问题:C# CommandLineArguments类的具体用法?C# CommandLineArguments怎么用?C# CommandLineArguments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandLineArguments类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了CommandLineArguments类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:xyh413,项目名称:roslyn,代码行数:12,代码来源:AbstractProject_Options.cs
示例2: SetArgumentsCore
private void SetArgumentsCore(string commandLine, CommandLineArguments commandLineArguments)
{
lock (_gate)
{
_lastParsedCompilerOptions = commandLine;
_lastParsedCommandLineArguments = commandLineArguments;
}
}
开发者ID:jkotas,项目名称:roslyn,代码行数:8,代码来源:AbstractProject_Options.cs
示例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);
}
}
开发者ID:orthoxerox,项目名称:roslyn,代码行数:9,代码来源:CPSProject_IWorkspaceProjectContext.cs
示例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);
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:CPSProject_IWorkspaceProjectContext.cs
示例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);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:17,代码来源:AbstractProject_Options.cs
示例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;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:17,代码来源:AbstractProject_Options.cs
示例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);
}
开发者ID:xyh413,项目名称:roslyn,代码行数:15,代码来源:CPSProjectFactory.cs
示例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;
}
开发者ID:AnthonyDGreen,项目名称:roslyn,代码行数:16,代码来源:AbstractRoslynProject.cs
示例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;
}
开发者ID:xyh413,项目名称:roslyn,代码行数:45,代码来源:AbstractProject_Options.cs
示例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);
}
开发者ID:xyh413,项目名称:roslyn,代码行数:21,代码来源:CPSProject.cs
示例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)
//.........这里部分代码省略.........
开发者ID:Rickinio,项目名称:roslyn,代码行数:101,代码来源:CSharpProjectShim.cs
示例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);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:20,代码来源:CSharpProjectShim.cs
示例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);
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:6,代码来源:CommonCompiler.cs
示例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;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:32,代码来源:CommonCompiler.cs
示例15: GetWin32Resources
protected Stream GetWin32Resources(CommandLineArguments arguments, Compilation compilation, out IEnumerable<DiagnosticInfo> errors)
{
return GetWin32ResourcesInternal(MessageProvider, arguments, compilation, out errors);
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:4,代码来源:CommonCompiler.cs
示例16: CreateCPSProject
// internal for testing purposes only.
internal static CPSProject CreateCPSProject(VisualStudioProjectTracker projectTracker, IServiceProvider serviceProvider, IVsHierarchy hierarchy, string projectDisplayName, string projectFilePath, string language, Guid projectGuid, string projectTypeGuid, CommandLineArguments commandLineArguments)
{
return new CPSProject(commandLineArguments, projectTracker, reportExternalErrorCreatorOpt: null, hierarchy: hierarchy, language: language,
serviceProvider: serviceProvider, visualStudioWorkspaceOpt: null, hostDiagnosticUpdateSourceOpt: null, projectDisplayName: projectDisplayName,
projectFilePath: projectFilePath, projectGuid: projectGuid, projectTypeGuid: projectTypeGuid);
}
开发者ID:xyh413,项目名称:roslyn,代码行数:7,代码来源:CPSProjectFactory.cs
示例17: CreateDeterminismKey
/// <summary>
/// The string returned from this function represents the inputs to the compiler which impact determinism. It is
/// meant to be inline with the specification here:
///
/// - https://github.com/dotnet/roslyn/blob/master/docs/compilers/Deterministic%20Inputs.md
///
/// Issue #8193 tracks filling this out to the full specification.
///
/// https://github.com/dotnet/roslyn/issues/8193
/// </summary>
private static string CreateDeterminismKey(CommandLineArguments args, string[] rawArgs, string baseDirectory, CommandLineParser parser)
{
List<Diagnostic> diagnostics = new List<Diagnostic>();
List<string> flattenedArgs = new List<string>();
parser.FlattenArgs(rawArgs, diagnostics, flattenedArgs, null, baseDirectory);
var builder = new StringBuilder();
var name = !string.IsNullOrEmpty(args.OutputFileName)
? Path.GetFileNameWithoutExtension(Path.GetFileName(args.OutputFileName))
: $"no-output-name-{Guid.NewGuid().ToString()}";
builder.AppendLine($"{name}");
builder.AppendLine($"Command Line:");
foreach (var current in flattenedArgs)
{
builder.AppendLine($"\t{current}");
}
builder.AppendLine("Source Files:");
var hash = new MD5CryptoServiceProvider();
foreach (var sourceFile in args.SourceFiles)
{
var sourceFileName = Path.GetFileName(sourceFile.Path);
string hashValue;
try
{
var bytes = PortableShim.File.ReadAllBytes(sourceFile.Path);
var hashBytes = hash.ComputeHash(bytes);
var data = BitConverter.ToString(hashBytes);
hashValue = data.Replace("-", "");
}
catch (Exception ex)
{
hashValue = $"Could not compute {ex.Message}";
}
builder.AppendLine($"\t{sourceFileName} - {hashValue}");
}
return builder.ToString();
}
开发者ID:rolfbjarne,项目名称:roslyn,代码行数:51,代码来源:CommonCompiler.cs
示例18: EmitDeterminismKey
private static void EmitDeterminismKey(CommandLineArguments args, string[] rawArgs, string baseDirectory, CommandLineParser parser)
{
var key = CreateDeterminismKey(args, rawArgs, baseDirectory, parser);
var filePath = Path.Combine(args.OutputDirectory, args.OutputFileName + ".key");
using (var stream = PortableShim.File.Create(filePath))
{
var bytes = Encoding.UTF8.GetBytes(key);
stream.Write(bytes, 0, bytes.Length);
}
}
开发者ID:rolfbjarne,项目名称:roslyn,代码行数:10,代码来源:CommonCompiler.cs
示例19: SetCommandLineArguments
public void SetCommandLineArguments(CommandLineArguments commandLineArguments)
{
SetArgumentsAndUpdateOptions(commandLineArguments);
// If outputPath has changed, then invoke SetOutputPathAndRelatedData to update the project tracker bin path for this project.
if (commandLineArguments.OutputFileName != null && commandLineArguments.OutputDirectory != null)
{
var newOutputPath = PathUtilities.CombinePathsUnchecked(commandLineArguments.OutputDirectory, commandLineArguments.OutputFileName);
SetOutputPathAndRelatedData(newOutputPath, hasSameBinAndObjOutputPaths: true);
}
}
开发者ID:xyh413,项目名称:roslyn,代码行数:11,代码来源:CPSProject_IProjectContext.cs
示例20: GetEmbedddedSourcePaths
private static IReadOnlySet<string> GetEmbedddedSourcePaths(CommandLineArguments arguments)
{
if (arguments.EmbeddedFiles.IsEmpty)
{
return SpecializedCollections.EmptyReadOnlySet<string>();
}
// Note that we require an exact match between source and embedded file paths (case-sensitive
// and without normalization). If two files are the same but spelled differently, they will
// be handled as separate files, meaning the embedding pass will read the content a second
// time. This can also lead to more than one document entry in the PDB for the same document
// if the PDB document de-duping policy in emit (normalize + case-sensitive in C#,
// normalize + case-insensitive in VB) is not enough to converge them.
var set = new HashSet<string>(arguments.EmbeddedFiles.Select(f => f.Path));
set.IntersectWith(arguments.SourceFiles.Select(f => f.Path));
return SpecializedCollections.StronglyTypedReadOnlySet(set);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:17,代码来源:CommonCompiler.cs
注:本文中的Microsoft.CodeAnalysis.CommandLineArguments类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论