本文整理汇总了C#中LoadState.ProjectAlreadyReferencesProject方法的典型用法代码示例。如果您正苦于以下问题:C# LoadState.ProjectAlreadyReferencesProject方法的具体用法?C# LoadState.ProjectAlreadyReferencesProject怎么用?C# LoadState.ProjectAlreadyReferencesProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoadState
的用法示例。
在下文中一共展示了LoadState.ProjectAlreadyReferencesProject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveProjectReferencesAsync
private async Task<ResolvedReferences> ResolveProjectReferencesAsync(
ProjectId thisProjectId,
string thisProjectPath,
IReadOnlyList<ProjectFileReference> projectFileReferences,
bool preferMetadata,
LoadState loadedProjects,
CancellationToken cancellationToken)
{
var resolvedReferences = new ResolvedReferences();
var reportMode = this.SkipUnrecognizedProjects ? ReportMode.Log : ReportMode.Throw;
foreach (var projectFileReference in projectFileReferences)
{
string fullPath;
if (TryGetAbsoluteProjectPath(projectFileReference.Path, Path.GetDirectoryName(thisProjectPath), reportMode, out fullPath))
{
// if the project is already loaded, then just reference the one we have
var existingProjectId = loadedProjects.GetProjectId(fullPath);
if (existingProjectId != null)
{
resolvedReferences.ProjectReferences.Add(new ProjectReference(existingProjectId, projectFileReference.Aliases));
continue;
}
IProjectFileLoader loader;
TryGetLoaderFromProjectPath(fullPath, ReportMode.Ignore, out loader);
// get metadata if preferred or if loader is unknown
if (preferMetadata || loader == null)
{
var projectMetadata = await this.GetProjectMetadata(fullPath, projectFileReference.Aliases, _properties, cancellationToken).ConfigureAwait(false);
if (projectMetadata != null)
{
resolvedReferences.MetadataReferences.Add(projectMetadata);
continue;
}
}
// must load, so we really need loader
if (TryGetLoaderFromProjectPath(fullPath, reportMode, out loader))
{
// load the project
var projectId = await this.GetOrLoadProjectAsync(fullPath, loader, preferMetadata, loadedProjects, cancellationToken).ConfigureAwait(false);
// If that other project already has a reference on us, this will cause a circularity.
// This check doesn't need to be in the "already loaded" path above, since in any circularity this path
// must be taken at least once.
if (loadedProjects.ProjectAlreadyReferencesProject(projectId, targetProject: thisProjectId))
{
// We'll try to make this metadata if we can
var projectMetadata = await this.GetProjectMetadata(fullPath, projectFileReference.Aliases, _properties, cancellationToken).ConfigureAwait(false);
if (projectMetadata != null)
{
resolvedReferences.MetadataReferences.Add(projectMetadata);
}
continue;
}
else
{
resolvedReferences.ProjectReferences.Add(new ProjectReference(projectId, projectFileReference.Aliases));
continue;
}
}
}
else
{
fullPath = projectFileReference.Path;
}
// cannot find metadata and project cannot be loaded, so leave a project reference to a non-existent project.
var id = loadedProjects.GetOrCreateProjectId(fullPath);
resolvedReferences.ProjectReferences.Add(new ProjectReference(id, projectFileReference.Aliases));
}
return resolvedReferences;
}