本文整理汇总了C#中ProjectReference类的典型用法代码示例。如果您正苦于以下问题:C# ProjectReference类的具体用法?C# ProjectReference怎么用?C# ProjectReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectReference类属于命名空间,在下文中一共展示了ProjectReference类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddMissingReferenceCodeAction
public AddMissingReferenceCodeAction(Project project, string title, ProjectReference projectReferenceToAdd, AssemblyIdentity missingAssemblyIdentity)
{
_project = project;
Title = title;
_projectReferenceToAdd = projectReferenceToAdd;
_missingAssemblyIdentity = missingAssemblyIdentity;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:AddMissingReferenceCodeAction.cs
示例2: AddReferenceAsync
public Task AddReferenceAsync(ProjectReference reference, CancellationToken cancellationToken = default(CancellationToken))
{
if (reference == null) {
return MakeExceptionTask(new ArgumentNullException("reference"));
}
EnsureInstanceDb();
switch (reference.Kind) {
case ProjectReferenceKind.ExtensionModule:
if (_references == null) {
_references = new HashSet<ProjectReference>();
}
_references.Add(reference);
string filename;
try {
filename = Path.GetFileNameWithoutExtension(reference.Name);
} catch (Exception e) {
return MakeExceptionTask(e);
}
return _typeDb.LoadExtensionModuleAsync(_factory,
filename,
reference.Name,
cancellationToken).ContinueWith(RaiseModulesChanged);
}
return Task.Factory.StartNew(EmptyTask);
}
开发者ID:borota,项目名称:JTVS,代码行数:29,代码来源:CJInterpreter.cs
示例3: Report
public ReferenceIntegrityCheckReport Report(ProjectReference reference)
{
const string identity = "ContainsReferencedProjectsCheck";
if (this.IsSatisfiedBy(reference))
{
return ReferenceIntegrityCheckReport.Ok(identity, reference);
}
ReportMessage message;
if (!ContainsInSolution(this.projectsInSolution, reference))
{
string solutionName = this.projectsInSolution.First().Referrer;
message = ReportMessage.Error("The solution '{0}' doesn't contain project '{1}'.", solutionName, reference.Name);
return ReferenceIntegrityCheckReport.NotOk(message, identity, reference);
}
ProjectReference[] projectReferences = this.parser.ParseProjectReferences(reference.FullPath);
string missingReferenceNames = string.Join(", ", projectReferences
.Where(r => !ContainsInSolution(this.projectsInSolution ,r))
.Select(r => r.Name));
message = ReportMessage.Error("The solution '{0}' doesn't contain '{1}', but '{2}' requires it to be.",
reference.Referrer, missingReferenceNames,
reference.Name);
return ReferenceIntegrityCheckReport.NotOk(message, identity, reference);
}
开发者ID:CHECK24,项目名称:c24.Deputy,代码行数:30,代码来源:ProjectReferenceExistsInSolutionCheck.cs
示例4: ProjectReferenceQuestion
public void ProjectReferenceQuestion()
{
var optionValue = new ProjectReference( "ProjPath", new Guid( "76606c7b-5bf1-497c-9b0f-9695a6a8788d" ), "ProjectName", new XElement( "ProjectReference" ) );
var option = new UserQuestionLiteralWithDescriptionOption<ProjectReference>( "A", "Option A", optionValue, "WasNull" );
Assert.That( option.GetQuestionText(), Is.EqualTo( "(A) Option A:\r\nName: ProjectName\r\nKey: 76606c7b-5bf1-497c-9b0f-9695a6a8788d\r\nPath: ProjPath\r\n" ) );
Assert.That( option.GetValue(), Is.EqualTo( optionValue ) );
}
开发者ID:configit-open-source,项目名称:csmerge,代码行数:7,代码来源:UserQuestionTest.cs
示例5: TryGetReference
internal static bool TryGetReference(
Solution solution, ProjectReference projectReference, Compilation finalOrDeclarationCompilation, VersionStamp version, out MetadataReference reference)
{
// if we have one from snapshot cache, use it. it will make sure same compilation will get same metadata reference always.
MetadataOnlyReferenceSet referenceSet;
if (s_snapshotCache.TryGetValue(finalOrDeclarationCompilation, out referenceSet))
{
reference = referenceSet.GetMetadataReference(finalOrDeclarationCompilation, projectReference.Aliases, projectReference.EmbedInteropTypes);
return true;
}
// okay, now use version based cache that can live multiple compilation as long as there is no semantic changes.
// get one for the branch
if (TryGetReferenceFromBranch(solution.BranchId, projectReference, finalOrDeclarationCompilation, version, out reference))
{
return true;
}
// see whether we can use primary branch one
var primaryBranchId = solution.Workspace.PrimaryBranchId;
if (solution.BranchId != primaryBranchId &&
TryGetReferenceFromBranch(primaryBranchId, projectReference, finalOrDeclarationCompilation, version, out reference))
{
return true;
}
// noop, we don't have any
reference = null;
return false;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:31,代码来源:MetadataOnlyReference.cs
示例6: LoadProject
public override void LoadProject (IProgressMonitor monitor, SolutionEntityItem item, MSBuildProject msproject)
{
base.LoadProject (monitor, item, msproject);
var dnp = item as DotNetProject;
if (dnp == null)
return;
// Convert .projitems imports into project references
foreach (var sp in msproject.Imports.Where (im => im.Label == "Shared" && im.Project.EndsWith (".projitems"))) {
var projitemsFile = sp.Project;
if (!string.IsNullOrEmpty (projitemsFile)) {
projitemsFile = MSBuildProjectService.FromMSBuildPath (item.ItemDirectory, projitemsFile);
projitemsFile = Path.Combine (Path.GetDirectoryName (msproject.FileName), projitemsFile);
if (File.Exists (projitemsFile)) {
MSBuildSerializer iser = Handler.CreateSerializer ();
iser.SerializationContext.BaseFile = projitemsFile;
iser.SerializationContext.ProgressMonitor = monitor;
MSBuildProject p = new MSBuildProject ();
p.Load (projitemsFile);
Handler.LoadProjectItems (p, iser, ProjectItemFlags.Hidden | ProjectItemFlags.DontPersist);
var r = new ProjectReference (ReferenceType.Project, Path.GetFileNameWithoutExtension (projitemsFile));
r.Flags = ProjectItemFlags.DontPersist;
r.SetItemsProjectPath (projitemsFile);
dnp.References.Add (r);
}
}
}
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:30,代码来源:SharedAssetsProjectMSBuildExtension.cs
示例7: SerializableProjectReference
private SerializableProjectReference(SerializationInfo info, StreamingContext context)
{
var projectId = ((SerializableProjectId)info.GetValue("projectId", typeof(SerializableProjectId))).ProjectId;
var aliases = ImmutableArray.Create((string[])info.GetValue("aliases", typeof(string[])));
var embedInteropTypes = info.GetBoolean("embedInteropTypes");
_projectReference = new ProjectReference(projectId, aliases, embedInteropTypes);
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:8,代码来源:SerializableProjectReference.cs
示例8: GetOrBuildReference
internal static MetadataReference GetOrBuildReference(
Solution solution,
ProjectReference projectReference,
Compilation finalCompilation,
VersionStamp version,
CancellationToken cancellationToken)
{
MetadataReference reference;
if (TryGetReference(solution, projectReference, finalCompilation, version, out reference))
{
return reference;
}
// okay, we don't have one. so create one now.
// first, prepare image
// * NOTE * image is cancellable, do not create it inside of conditional weak table.
var service = solution.Workspace.Services.GetService<ITemporaryStorageService>();
var image = MetadataOnlyImage.Create(service, finalCompilation, cancellationToken);
if (image.IsEmpty)
{
// unfortunately, we couldn't create one. do best effort
if (TryGetReference(solution, projectReference, finalCompilation, VersionStamp.Default, out reference))
{
// we have one from previous compilation!!, it might be out-of-date big time, but better than nothing.
// re-use it
return reference;
}
}
// okay, proceed with whatever image we have
// now, remove existing set
var mapFromBranch = s_cache.GetValue(solution.BranchId, s_createReferenceSetMap);
mapFromBranch.Remove(projectReference.ProjectId);
// create new one
var newReferenceSet = new MetadataOnlyReferenceSet(version, image);
var referenceSet = s_snapshotCache.GetValue(finalCompilation, _ => newReferenceSet);
if (newReferenceSet != referenceSet)
{
// someone else has beaten us.
// let image go eagerly. otherwise, finalizer in temporary storage will take care of it
image.Cleanup();
// return new reference
return referenceSet.GetMetadataReference(finalCompilation, projectReference.Aliases, projectReference.EmbedInteropTypes);
}
// record it to version based cache as well. snapshot cache always has a higher priority. we don't need to check returned set here
// since snapshot based cache will take care of same compilation for us.
mapFromBranch.GetValue(projectReference.ProjectId, _ => referenceSet);
// return new reference
return referenceSet.GetMetadataReference(finalCompilation, projectReference.Aliases, projectReference.EmbedInteropTypes);
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:56,代码来源:MetadataOnlyReference.cs
示例9: creating_a_project_references_from_a_project_copies_attributes
public void creating_a_project_references_from_a_project_copies_attributes()
{
var sourceProject = new CsProjFile(@"Solution1\harness\SlickGridHarness.csproj");
var targetProject = new CsProjFile(@"Solution1\docs\FubuMVC.SlickGrid.Docs.csproj");
var projectReference = new ProjectReference(targetProject, sourceProject);
projectReference.Include.ShouldEqual(@"..\harness\SlickGridHarness.csproj");
projectReference.ProjectGuid.ShouldEqual(sourceProject.ProjectGuid);
projectReference.ProjectName.ShouldEqual(sourceProject.ProjectName);
}
开发者ID:awelburn,项目名称:FubuCsProjFile,代码行数:10,代码来源:ProjectReferenceTester.cs
示例10: Given_a_project_with_a_reference_for_a_project_not_existing_in_solution
public Given_a_project_with_a_reference_for_a_project_not_existing_in_solution()
{
var projectsInSolution = new[] { ProjectReferenceTestSample.ReferenceFromSolutionToProjectWithoutReferences, ProjectReferenceTestSample.ReferenceFromSolutionToProjectWithReferences };
var parserMock = new Mock<IProjectParser>();
parserMock
.Setup(p => p.ParseProjectReferences(ProjectReferenceTestSample.ReferenceFromSolutionToProjectWithReferences.FullPath))
.Returns(new[] { ProjectReferenceTestSample.ReferenceFromProjectToAProjectWithSameName });
this.check = new ProjectReferenceExistsInSolutionCheck(projectsInSolution, parserMock.Object);
this.reference = ProjectReferenceTestSample.ReferenceFromSolutionToProjectWithReferences;
}
开发者ID:CHECK24,项目名称:c24.Deputy,代码行数:11,代码来源:ProjectReferenceExistsInSolutionCheck_Tests.cs
示例11: ReadAssembly
private AssemblyDefinition ReadAssembly(ProjectReference projectReference)
{
AssemblyDefinition assemblyDefinition = null;
if (!m_cache.TryGetValue(projectReference, out assemblyDefinition))
{
assemblyDefinition = ReadAssembly(
projectReference.Location, Path.GetDirectoryName(projectReference.Location));
if (assemblyDefinition != null)
m_cache[projectReference] = assemblyDefinition;
}
return assemblyDefinition;
}
开发者ID:MishaUliutin,项目名称:RemoveUnusedRef,代码行数:12,代码来源:ImportedTypeWorker.cs
示例12: Given_a_reference_with_path_which_does_not_exist
public Given_a_reference_with_path_which_does_not_exist()
{
this.reference = new ProjectReference
{
Name = "what",
Path = "what.csproj",
Referrer = "project",
SourceType = ReferenceSourceType.Project
};
this.check = new SolutionIntegrityCheck(
new MockFileSystem(new Dictionary<string, MockFileData>
{
{ "any.csproj", new MockFileData(String.Empty) }
}), new ProjectReference[0], Mock.Of<IProjectParser>());
}
开发者ID:CHECK24,项目名称:c24.Deputy,代码行数:16,代码来源:SolutionIntegrityCheck_Tests.cs
示例13: IsEquals
private static bool IsEquals(AssemblyNameReference name, ProjectReference projectReference)
{
var result =
string.
Equals(name.Name, projectReference.Name, StringComparison.InvariantCultureIgnoreCase) &&
string.
Equals(name.Culture, projectReference.Culture, StringComparison.InvariantCultureIgnoreCase);
if (result)
{
var token = (name.PublicKeyToken == null || name.PublicKeyToken.Length == 0)
? string.Empty
: Helper.PublicKeyTokenConvertFrom(name.PublicKeyToken);
result = string.
Equals(token, projectReference.PublicKeyToken, StringComparison.InvariantCultureIgnoreCase);
}
return result;
}
开发者ID:MishaUliutin,项目名称:RemoveUnusedRef,代码行数:17,代码来源:ProjectAssemblyResolver.cs
示例14: Given_a_project_with_a_reference_which_does_not_exist_in_solution
public Given_a_project_with_a_reference_which_does_not_exist_in_solution()
{
var projectsInSolution = new[] { ProjectReferenceTestSample.ReferenceFromSolutionToProjectWithReferences };
var parserMock = new Mock<IProjectParser>();
parserMock
.Setup(p => p.ParseProjectReferences(ProjectReferenceTestSample.ReferenceFromSolutionToProjectWithReferences.FullPath))
.Returns(new[] { ProjectReferenceTestSample.ReferenceFromProjectToAProjectWithSameName });
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "testB.csproj")), new MockFileData(String.Empty)}
});
this.reference = ProjectReferenceTestSample.ReferenceFromSolutionToProjectWithReferences;
this.check = new SolutionIntegrityCheck(fileSystem, projectsInSolution, parserMock.Object);
}
开发者ID:CHECK24,项目名称:c24.Deputy,代码行数:17,代码来源:SolutionIntegrityCheck_Tests.cs
示例15: AddMetadataReferenceAndTryConvertingToProjectReferenceIfPossible
protected int AddMetadataReferenceAndTryConvertingToProjectReferenceIfPossible(string filePath, MetadataReferenceProperties properties)
{
AssertIsForeground();
// If this file is coming from a project, then we should convert it to a project reference instead
if (this.CanConvertToProjectReferences && ProjectTracker.TryGetProjectByBinPath(filePath, out var project))
{
var projectReference = new ProjectReference(project.Id, properties.Aliases, properties.EmbedInteropTypes);
if (CanAddProjectReference(projectReference))
{
AddProjectReference(projectReference);
AddMetadataFileNameToConvertedProjectReference(filePath, projectReference);
return VSConstants.S_OK;
}
}
// regardless whether the file exists or not, we still record it. one of reason
// we do that is some cross language p2p references might be resolved
// after they are already reported as metadata references. since we use bin path
// as a way to discover them, if we don't previously record the reference ourselves,
// cross p2p references won't be resolved as p2p references when we finally have
// all required information.
//
// it looks like
// 1. project system sometimes won't guarantee build dependency for intellisense build
// if it is cross language dependency
// 2. output path of referenced cross language project might be changed to right one
// once it is already added as a metadata reference.
//
// but this has one consequence. even if a user adds a project in the solution as
// a metadata reference explicitly, that dll will be automatically converted back to p2p
// reference.
//
// unfortunately there is no way to prevent this using information we have since,
// at this point, we don't know whether it is a metadata reference added because
// we don't have enough information yet for p2p reference or user explicitly added it
// as a metadata reference.
AddMetadataReferenceCore(this.MetadataReferenceProvider.CreateMetadataReference(this, filePath, properties));
// here, we change behavior compared to old C# language service. regardless of file being exist or not,
// we will always return S_OK. this is to support cross language p2p reference better.
//
// this should make project system to cache all cross language p2p references regardless
// whether it actually exist in disk or not.
// (see Roslyn bug 7315 for history - http://vstfdevdiv:8080/DevDiv_Projects/Roslyn/_workitems?_a=edit&id=7315)
//
// after this point, Roslyn will take care of non-exist metadata reference.
//
// But, this doesn't sovle the issue where actual metadata reference
// (not cross language p2p reference) is missing at the time project is opened.
//
// in that case, msbuild filter those actual metadata references out, so project system doesn't know
// path to the reference. since it doesn't know where dll is, it can't (or currently doesn't)
// setup file change notification either to find out when dll becomes available.
//
// at this point, user has 2 ways to recover missing metadata reference once it becomes available.
//
// one way is explicitly clicking that missing reference from solution explorer reference node.
// the other is building the project. at that point, project system will refresh references
// which will discover new dll and connect to us. once it is connected, we will take care of it.
return VSConstants.S_OK;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:62,代码来源:AbstractProject.cs
示例16: TryProjectConversionForIntroducedOutputPath
internal void TryProjectConversionForIntroducedOutputPath(string binPath, AbstractProject projectToReference)
{
AssertIsForeground();
if (this.CanConvertToProjectReferences)
{
// We should not already have references for this, since we're only introducing the path for the first time
Contract.ThrowIfTrue(HasMetadataFileNameToConvertedProjectReference(binPath));
var metadataReference = TryGetCurrentMetadataReference(binPath);
if (metadataReference != null)
{
var projectReference = new ProjectReference(
projectToReference.Id,
metadataReference.Properties.Aliases,
metadataReference.Properties.EmbedInteropTypes);
if (CanAddProjectReference(projectReference))
{
RemoveMetadataReferenceCore(metadataReference, disposeReference: true);
AddProjectReference(projectReference);
AddMetadataFileNameToConvertedProjectReference(binPath, projectReference);
}
}
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:27,代码来源:AbstractProject.cs
示例17: AddProjectReference
// Internal for unit testing
internal void AddProjectReference(ProjectReference projectReference)
{
AssertIsForeground();
// dev11 is sometimes calling us multiple times for the same data
if (!CanAddProjectReference(projectReference))
{
return;
}
lock (_gate)
{
// always manipulate current state after workspace is told so it will correctly observe the initial state
_projectReferences.Add(projectReference);
}
if (_pushingChangesToWorkspaceHosts)
{
// This project is already pushed to listening workspace hosts, but it's possible that our target
// project hasn't been yet. Get the dependent project into the workspace as well.
var targetProject = this.ProjectTracker.GetProject(projectReference.ProjectId);
this.ProjectTracker.StartPushingToWorkspaceAndNotifyOfOpenDocuments(SpecializedCollections.SingletonEnumerable(targetProject));
this.ProjectTracker.NotifyWorkspaceHosts(host => host.OnProjectReferenceAdded(this.Id, projectReference));
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:27,代码来源:AbstractProject.cs
示例18: UpdateMetadataFileNameToConvertedProjectReference
private void UpdateMetadataFileNameToConvertedProjectReference(string filePath, ProjectReference projectReference)
{
lock (_gate)
{
_metadataFileNameToConvertedProjectReference[filePath] = projectReference;
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:AbstractProject.cs
示例19: TryGetMetadataFileNameToConvertedProjectReference
private bool TryGetMetadataFileNameToConvertedProjectReference(string filePath, out ProjectReference projectReference)
{
lock (_gate)
{
return _metadataFileNameToConvertedProjectReference.TryGetValue(filePath, out projectReference);
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:AbstractProject.cs
示例20: AddMetadataFileNameToConvertedProjectReference
private void AddMetadataFileNameToConvertedProjectReference(string filePath, ProjectReference projectReference)
{
lock (_gate)
{
_metadataFileNameToConvertedProjectReference.Add(filePath, projectReference);
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:AbstractProject.cs
注:本文中的ProjectReference类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论