本文整理汇总了C#中Microsoft.Build.BackEnd.BuildRequestEntry类的典型用法代码示例。如果您正苦于以下问题:C# BuildRequestEntry类的具体用法?C# BuildRequestEntry怎么用?C# BuildRequestEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildRequestEntry类属于Microsoft.Build.BackEnd命名空间,在下文中一共展示了BuildRequestEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
LoggingServiceFactory loggingFactory = new LoggingServiceFactory(LoggerMode.Synchronous, 1);
_loggingService = loggingFactory.CreateInstance(BuildComponentType.LoggingService) as LoggingService;
_customLogger = new MyCustomLogger();
_mockHost = new MockHost();
_mockHost.LoggingService = _loggingService;
_loggingService.RegisterLogger(_customLogger);
_elementLocation = ElementLocation.Create("MockFile", 5, 5);
BuildRequest buildRequest = new BuildRequest(1 /* submissionId */, 1, 1, new List<string>(), null, BuildEventContext.Invalid, null);
BuildRequestConfiguration configuration = new BuildRequestConfiguration(1, new BuildRequestData("Nothing", new Dictionary<string, string>(), "4.0", new string[0], null), "2.0");
configuration.Project = new ProjectInstance(ProjectRootElement.Create());
BuildRequestEntry entry = new BuildRequestEntry(buildRequest, configuration);
BuildResult buildResult = new BuildResult(buildRequest, false);
buildResult.AddResultsForTarget("Build", new TargetResult(new TaskItem[] { new TaskItem("IamSuper", configuration.ProjectFullPath) }, TestUtilities.GetSkippedResult()));
_mockRequestCallback = new MockIRequestBuilderCallback(new BuildResult[] { buildResult });
entry.Builder = (IRequestBuilder)_mockRequestCallback;
_taskHost = new TaskHost(_mockHost, entry, _elementLocation, null /*Dont care about the callback either unless doing a build*/);
_taskHost.LoggingContext = new TaskLoggingContext(_loggingService, BuildEventContext.Invalid);
}
示例2: TestSimpleBuildRequest
public void TestSimpleBuildRequest()
{
BuildRequestConfiguration configuration = CreateTestProject(1);
try
{
TestTargetBuilder targetBuilder = (TestTargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder);
IConfigCache configCache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache);
configCache.AddConfiguration(configuration);
BuildRequest request = CreateNewBuildRequest(1, new string[1] { "target1" });
BuildRequestEntry entry = new BuildRequestEntry(request, configuration);
BuildResult result = new BuildResult(request);
result.AddResultsForTarget("target1", GetEmptySuccessfulTargetResult());
targetBuilder.SetResultsToReturn(result);
_requestBuilder.BuildRequest(GetNodeLoggingContext(), entry);
WaitForEvent(_buildRequestCompletedEvent, "Build Request Completed");
Assert.Equal(BuildRequestEntryState.Complete, entry.State);
Assert.Equal(entry, _buildRequestCompleted_Entry);
Assert.Equal(BuildResultCode.Success, _buildRequestCompleted_Entry.Result.OverallResult);
}
finally
{
DeleteTestProject(configuration);
}
}
示例3: TestConstructorNullTarget
public void TestConstructorNullTarget()
{
ProjectInstance project = CreateTestProject(true /* Returns enabled */);
BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
BuildRequestEntry requestEntry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[] { "foo" }), config);
Lookup lookup = new Lookup(new ItemDictionary<ProjectItemInstance>(project.Items), new PropertyDictionary<ProjectPropertyInstance>(project.Properties), null);
TargetEntry entry = new TargetEntry(requestEntry, this, null, lookup, null, _host, false);
}
示例4: TestConstructorBad
public void TestConstructorBad()
{
Assert.Throws<ArgumentNullException>(() =>
{
BuildRequestEntry entry = new BuildRequestEntry(null, null);
}
);
}
示例5: TestConstructorGood
public void TestConstructorGood()
{
BuildRequest request = CreateNewBuildRequest(1, new string[0] { });
BuildRequestData data = new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null);
BuildRequestConfiguration config = new BuildRequestConfiguration(1, data, "2.0");
BuildRequestEntry entry = new BuildRequestEntry(request, config);
Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
Assert.AreEqual(entry.Request, request);
}
示例6: BuildTargets
/// <summary>
/// Builds the specified targets of an entry. The cancel event should only be set to true if we are planning
/// on simulating execution time when a target is built
/// </summary>
public Task<BuildResult> BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, string[] targetNames, Lookup baseLookup, CancellationToken cancellationToken)
{
_requestEntry = entry;
_projectLoggingContext = loggingContext;
_requestCallBack = callback;
_testDefinition = _testDataProvider[entry.Request.ConfigurationId];
_cancellationToken = cancellationToken;
BuildResult result = GenerateResults(targetNames);
return Task<BuildResult>.FromResult(result);
}
示例7: BuildRequest
public void BuildRequest(NodeLoggingContext context, BuildRequestEntry entry)
{
Assert.Null(_builderThread); // "Received BuildRequest while one was in progress"
_continueEvent = new AutoResetEvent(false);
_cancelEvent = new AutoResetEvent(false);
_entry = entry;
entry.Continue();
_builderThread = new Thread(BuilderThreadProc);
_builderThread.Start();
}
示例8: TestSimpleStateProgression
public void TestSimpleStateProgression()
{
// Start in Ready
BuildRequest request = CreateNewBuildRequest(1, new string[1] { "foo" });
BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
BuildRequestEntry entry = new BuildRequestEntry(request, config);
Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
Assert.AreEqual(entry.Request, request);
Assert.IsNull(entry.Result);
// Move to active. Should not be any results yet.
IDictionary<int, BuildResult> results = entry.Continue();
Assert.AreEqual(entry.State, BuildRequestEntryState.Active);
Assert.IsNull(entry.Result);
Assert.IsNull(results);
// Wait for results, move to waiting.
BuildRequest waitingRequest = CreateNewBuildRequest(2, new string[1] { "bar" });
entry.WaitForResult(waitingRequest);
Assert.AreEqual(entry.State, BuildRequestEntryState.Waiting);
Assert.AreEqual(entry.Request, request);
Assert.IsNull(entry.Result);
// Provide the results, move to ready.
BuildResult requiredResult = new BuildResult(waitingRequest);
requiredResult.AddResultsForTarget("bar", TestUtilities.GetEmptySucceedingTargetResult());
entry.ReportResult(requiredResult);
Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
Assert.AreEqual(entry.Request, request);
Assert.IsNull(entry.Result);
// Continue the build, move to active.
results = entry.Continue();
Assert.AreEqual(entry.State, BuildRequestEntryState.Active);
Assert.IsNull(entry.Result);
Assert.AreEqual(results.Count, 1);
Assert.IsTrue(results.ContainsKey(requiredResult.NodeRequestId));
Assert.AreEqual(results[requiredResult.NodeRequestId], requiredResult);
// Complete the build, move to completed.
BuildResult result = new BuildResult(request);
result.AddResultsForTarget("foo", TestUtilities.GetEmptySucceedingTargetResult());
entry.Complete(result);
Assert.AreEqual(entry.State, BuildRequestEntryState.Complete);
Assert.IsNotNull(entry.Result);
Assert.AreEqual(entry.Result, result);
}
示例9: TestNoReadyToComplete
public void TestNoReadyToComplete()
{
BuildRequest request = CreateNewBuildRequest(1, new string[1] { "foo" });
BuildRequestData data1 = new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null);
BuildRequestConfiguration config = new BuildRequestConfiguration(1, data1, "2.0");
BuildRequestEntry entry = new BuildRequestEntry(request, config);
Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
BuildResult requiredResult = new BuildResult(request);
requiredResult.AddResultsForTarget("foo", TestUtilities.GetEmptySucceedingTargetResult());
entry.Complete(requiredResult);
}
示例10: TestMixedWaitingRequests
public void TestMixedWaitingRequests()
{
BuildRequest request = CreateNewBuildRequest(1, new string[1] { "foo" });
BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
BuildRequestEntry entry = new BuildRequestEntry(request, config);
Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
entry.Continue();
Assert.AreEqual(entry.State, BuildRequestEntryState.Active);
BuildRequest waitingRequest1 = CreateNewBuildRequest(2, new string[1] { "bar" });
entry.WaitForResult(waitingRequest1);
Assert.AreEqual(entry.State, BuildRequestEntryState.Waiting);
BuildRequest waitingRequest2 = CreateNewBuildRequest(-1, new string[1] { "xor" });
entry.WaitForResult(waitingRequest2);
Assert.AreEqual(entry.State, BuildRequestEntryState.Waiting);
Assert.IsNull(entry.GetRequestsToIssueIfReady(), "Entry should not be ready to issue because there are unresolved configurations");
entry.ResolveConfigurationRequest(-1, 3);
Assert.AreEqual(entry.State, BuildRequestEntryState.Waiting);
BuildResult requiredResult1 = new BuildResult(waitingRequest1);
requiredResult1.AddResultsForTarget("bar", TestUtilities.GetEmptySucceedingTargetResult());
entry.ReportResult(requiredResult1);
Assert.AreEqual(entry.State, BuildRequestEntryState.Waiting);
BuildResult requiredResult2 = new BuildResult(waitingRequest2);
requiredResult2.AddResultsForTarget("xor", TestUtilities.GetEmptySucceedingTargetResult());
entry.ReportResult(requiredResult2);
Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
}
示例11: TestNoReadyToWaiting
public void TestNoReadyToWaiting()
{
BuildRequest request = CreateNewBuildRequest(1, new string[1] { "foo" });
BuildRequestData data1 = new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null);
BuildRequestConfiguration config = new BuildRequestConfiguration(1, data1, "2.0");
BuildRequestEntry entry = new BuildRequestEntry(request, config);
Assert.AreEqual(entry.State, BuildRequestEntryState.Ready);
BuildRequest waitingRequest1 = CreateNewBuildRequest(2, new string[1] { "bar" });
entry.WaitForResult(waitingRequest1);
}
示例12: TestSimpleBuild
public void TestSimpleBuild()
{
ProjectInstance project = CreateTestProject();
// The Empty target has no inputs or outputs.
TargetBuilder builder = (TargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder);
IConfigCache cache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache);
BuildRequestEntry entry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[] { "Empty" }), cache[1]);
BuildResult result = builder.BuildTargets(GetProjectLoggingContext(entry), entry, this, entry.Request.Targets.ToArray(), CreateStandardLookup(project), CancellationToken.None).Result;
Assert.True(result.HasResultsForTarget("Empty"));
Assert.Equal(TargetResultCode.Success, result["Empty"].ResultCode);
Assert.Equal(0, result["Empty"].Items.Length);
}
示例13: TestComplexOrdering2
public void TestComplexOrdering2()
{
string projectBody = @"
<Target Name='BuildDep'>
<BuildDepTask/>
</Target>
<Target Name='BeforeDepDep'>
<BeforeDepDepTask/>
</Target>
<Target Name='BeforeBeforeDep' BeforeTargets='BeforeDep'>
<BeforeBeforeDepTask/>
</Target>
<Target Name='AfterBeforeBeforeDep' AfterTargets='BeforeBeforeDep'>
<AfterBeforeBeforeDepTask/>
</Target>
<Target Name='BeforeDep' DependsOnTargets='BeforeDepDep'>
<BeforeDepTask/>
</Target>
<Target Name='Before' DependsOnTargets='BeforeDep' BeforeTargets='Build'>
<BeforeTask/>
</Target>
<Target Name='AfterBeforeDepDep'>
<AfterBeforeDepDepTask/>
</Target>
<Target Name='AfterBeforeDep' DependsOnTargets='AfterBeforeDepDep'>
<AfterBeforeDepTask/>
</Target>
<Target Name='AfterBefore' DependsOnTargets='AfterBeforeDep' AfterTargets='Before'>
<AfterBeforeTask/>
</Target>
<Target Name='Build' DependsOnTargets='BuildDep'>
<BuildTask/>
</Target>
";
ProjectInstance project = CreateTestProject(projectBody);
TargetBuilder builder = (TargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder);
IConfigCache cache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache);
BuildRequestEntry entry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[] { "Build" }), cache[1]);
BuildResult result = builder.BuildTargets(GetProjectLoggingContext(entry), entry, this, entry.Request.Targets.ToArray(), CreateStandardLookup(project), CancellationToken.None).Result;
AssertTaskExecutionOrder(new string[] { "BuildDepTask", "BeforeDepDepTask", "BeforeBeforeDepTask", "AfterBeforeBeforeDepTask", "BeforeDepTask", "BeforeTask", "AfterBeforeDepDepTask", "AfterBeforeDepTask", "AfterBeforeTask", "BuildTask" });
}
示例14: TestConstructorBad
public void TestConstructorBad()
{
BuildRequestEntry entry = new BuildRequestEntry(null, null);
}
示例15: MockIRequestBuilderCallback_OnBuildRequestCompleted
/// <summary>
/// Not Implemented
/// </summary>
private void MockIRequestBuilderCallback_OnBuildRequestCompleted(BuildRequestEntry completedEntry)
{
throw new NotImplementedException();
}