本文整理汇总了C#中LoadState.Add方法的典型用法代码示例。如果您正苦于以下问题:C# LoadState.Add方法的具体用法?C# LoadState.Add怎么用?C# LoadState.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoadState
的用法示例。
在下文中一共展示了LoadState.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadProjectAsync
private async Task<ProjectId> LoadProjectAsync(string projectFilePath, IProjectFileLoader loader, bool preferMetadata, LoadState loadedProjects, CancellationToken cancellationToken)
{
Debug.Assert(projectFilePath != null);
Debug.Assert(loader != null);
var projectId = loadedProjects.GetOrCreateProjectId(projectFilePath);
var projectName = Path.GetFileNameWithoutExtension(projectFilePath);
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))
{
version = VersionStamp.Create(File.GetLastWriteTimeUtc(projectFilePath));
}
else
{
version = VersionStamp.Create();
}
// translate information from command line args
var commandLineParser = _workspace.Services.GetLanguageServices(loader.Language).GetService<ICommandLineParserService>();
var metadataService = _workspace.Services.GetService<IMetadataService>();
var analyzerService = _workspace.Services.GetService<IAnalyzerService>();
var commandLineArgs = commandLineParser.Parse(
arguments: projectFileInfo.CommandLineArgs,
baseDirectory: projectDirectory,
isInteractive: false,
sdkDirectory: RuntimeEnvironment.GetRuntimeDirectory());
// we only support file paths in /r command line arguments
var resolver = new WorkspaceMetadataFileReferenceResolver(metadataService, new RelativePathResolver(commandLineArgs.ReferencePaths, commandLineArgs.BaseDirectory));
var metadataReferences = commandLineArgs.ResolveMetadataReferences(resolver);
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();
var additionalDocFileInfos = projectFileInfo.AdditionalDocuments.ToImmutableArrayOrEmpty();
// check for duplicate documents
var allDocFileInfos = docFileInfos.AddRange(additionalDocFileInfos);
CheckDocuments(allDocFileInfos, projectFilePath, projectId);
var docs = new List<DocumentInfo>();
foreach (var docFileInfo in docFileInfos)
{
string name;
ImmutableArray<string> folders;
GetDocumentNameAndFolders(docFileInfo.LogicalPath, out name, out folders);
docs.Add(DocumentInfo.Create(
DocumentId.CreateNewId(projectId, debugName: docFileInfo.FilePath),
name,
folders,
projectFile.GetSourceCodeKind(docFileInfo.FilePath),
new FileTextLoader(docFileInfo.FilePath, defaultEncoding),
docFileInfo.FilePath,
docFileInfo.IsGenerated));
}
var additionalDocs = new List<DocumentInfo>();
foreach (var docFileInfo in additionalDocFileInfos)
{
string name;
ImmutableArray<string> folders;
GetDocumentNameAndFolders(docFileInfo.LogicalPath, out name, out folders);
additionalDocs.Add(DocumentInfo.Create(
DocumentId.CreateNewId(projectId, debugName: docFileInfo.FilePath),
name,
folders,
SourceCodeKind.Regular,
new FileTextLoader(docFileInfo.FilePath, defaultEncoding),
docFileInfo.FilePath,
docFileInfo.IsGenerated));
}
// project references
var resolvedReferences = await ResolveProjectReferencesAsync(
projectId, projectFilePath, projectFileInfo.ProjectReferences, preferMetadata, loadedProjects, cancellationToken).ConfigureAwait(false);
// add metadata references for project refs converted to metadata refs
metadataReferences = metadataReferences.Concat(resolvedReferences.MetadataReferences);
//.........这里部分代码省略.........