@@ -792,7 +792,9 @@ public void ProjectStartedNullBuildEventContext()
792792 Assert . Throws < InternalErrorException > ( ( ) =>
793793 {
794794 ProcessBuildEventHelper service = ( ProcessBuildEventHelper ) ProcessBuildEventHelper . CreateLoggingService ( LoggerMode . Synchronous , 1 ) ;
795- service . LogProjectStarted ( null , 1 , 2 , s_taskBuildEventContext , "ProjectFile" , "TargetNames" , null , null , s_targetBuildEventContext . EvaluationId , s_taskBuildEventContext . ProjectContextId ) ;
795+ var args = service . CreateProjectStartedForLocalProject ( s_taskBuildEventContext , 2 , "ProjectFile" , "TargetNames" , null , null , null , null ) ;
796+ args . BuildEventContext = null ; // Force null context for error test
797+ service . LogProjectStarted ( args ) ;
796798 } ) ;
797799 }
798800
@@ -806,7 +808,8 @@ public void ProjectStartedNullParentBuildEventContext()
806808 Assert . Throws < InternalErrorException > ( ( ) =>
807809 {
808810 ProcessBuildEventHelper service = ( ProcessBuildEventHelper ) ProcessBuildEventHelper . CreateLoggingService ( LoggerMode . Synchronous , 1 ) ;
809- service . LogProjectStarted ( s_taskBuildEventContext , 1 , 2 , null , "ProjectFile" , "TargetNames" , null , null , s_targetBuildEventContext . EvaluationId , s_taskBuildEventContext . ProjectContextId ) ;
811+ var args = service . CreateProjectStartedForLocalProject ( null , 2 , "ProjectFile" , "TargetNames" , null , null , null , null ) ;
812+ service . LogProjectStarted ( args ) ;
810813 } ) ;
811814 }
812815
@@ -841,7 +844,9 @@ public void ProjectStartedEventTests(string projectFile, string targetNames)
841844 BuildRequestConfiguration config = new BuildRequestConfiguration ( 2 , data , "4.0" ) ;
842845 cache . AddConfiguration ( config ) ;
843846
844- BuildEventContext context = service . LogProjectStarted ( s_taskBuildEventContext , 1 , 2 , s_taskBuildEventContext , projectFile , targetNames , null , null , s_targetBuildEventContext . EvaluationId , s_taskBuildEventContext . ProjectContextId ) ;
847+ var args = service . CreateProjectStartedForLocalProject ( s_taskBuildEventContext , 2 , projectFile , targetNames , null , null , null , null ) ;
848+ service . LogProjectStarted ( args ) ;
849+ BuildEventContext context = args . BuildEventContext ;
845850 BuildEventContext parentBuildEventContext = s_taskBuildEventContext ;
846851 VerifyProjectStartedEventArgs ( service , context . ProjectContextId , message , projectFile , targetNames , parentBuildEventContext , context ) ;
847852
@@ -873,17 +878,10 @@ public void ProjectStartedProvidedProjectContextId()
873878 projectCacheBuildEventContext . ProjectContextId . ShouldNotBe ( BuildEventContext . InvalidProjectContextId ) ;
874879
875880 BuildEventContext nodeBuildEventContext = BuildEventContext . CreateInitial ( 0 , Scheduler . InProcNodeId ) ;
876- BuildEventContext projectStartedBuildEventContext = service . LogProjectStarted (
877- nodeBuildEventContext ,
878- submissionId : SubmissionId ,
879- configurationId : ConfigurationId ,
880- parentBuildEventContext : BuildEventContext . Invalid ,
881- projectFile : ProjectFile ,
882- targetNames : "TargetNames" ,
883- properties : null ,
884- items : null ,
885- evaluationId : EvaluationId ,
886- projectContextId : projectCacheBuildEventContext . ProjectContextId ) ;
881+ var args = service . CreateProjectStartedForLocalProject ( BuildEventContext . Invalid , ConfigurationId , ProjectFile , "TargetNames" , null , null , null , null ) ;
882+ args . BuildEventContext = args . BuildEventContext . WithProjectContextId ( projectCacheBuildEventContext . ProjectContextId ) ; // Use provided project context ID
883+ service . LogProjectStarted ( args ) ;
884+ BuildEventContext projectStartedBuildEventContext = args . BuildEventContext ;
887885 projectStartedBuildEventContext . ProjectContextId . ShouldBe ( projectCacheBuildEventContext . ProjectContextId ) ;
888886 }
889887
@@ -907,62 +905,15 @@ public void ProjectStartedProvidedUnknownProjectContextIdInProcNode()
907905 BuildRequestConfiguration config = new BuildRequestConfiguration ( ConfigurationId , data , "4.0" ) ;
908906 cache . AddConfiguration ( config ) ;
909907
910- BuildEventContext nodeBuildEventContext = BuildEventContext . CreateInitial ( 0 , Scheduler . InProcNodeId ) ;
908+ BuildEventContext parentBuildEventContext = BuildEventContext . CreateInitial ( SubmissionId , Scheduler . InProcNodeId ) . WithEvaluationId ( EvaluationId ) ;
909+ BuildEventContext remoteBuildEventContextWithKnownBadContextOnCurrentNode = parentBuildEventContext . WithProjectContextId ( ProjectContextId ) ;
911910 Assert . Throws < InternalErrorException > ( ( ) =>
912911 {
913- service . LogProjectStarted (
914- nodeBuildEventContext ,
915- submissionId : SubmissionId ,
916- configurationId : ConfigurationId ,
917- parentBuildEventContext : BuildEventContext . Invalid ,
918- projectFile : ProjectFile ,
919- targetNames : "TargetNames" ,
920- properties : null ,
921- items : null ,
922- evaluationId : EvaluationId ,
923- projectContextId : ProjectContextId ) ;
912+ var args = service . CreateProjectStartedForCachedProject ( parentBuildEventContext , remoteBuildEventContextWithKnownBadContextOnCurrentNode , BuildEventContext . Invalid , null , ProjectFile , "TargetNames" , null ) ;
913+ service . LogProjectStarted ( args ) ;
924914 } ) ;
925915 }
926916
927- /// <summary>
928- /// Expect an unknown project context id to be accepted on an out-of-proc node.
929- /// </summary>
930- [ Fact ]
931- public void ProjectStartedProvidedUnknownProjectContextIdOutOfProcNode ( )
932- {
933- const int SubmissionId = 1 ;
934- const int EvaluationId = 2 ;
935- const int ConfigurationId = 3 ;
936- const string ProjectFile = "SomeProjectFile" ;
937- const int NodeId = 2 ;
938- const int ProjectContextId = 123 ;
939-
940- // Ensure we didn't pick the one bad const value
941- NodeId . ShouldNotBe ( Scheduler . InProcNodeId ) ;
942-
943- MockHost componentHost = new MockHost ( ) ;
944- ProcessBuildEventHelper service = ( ProcessBuildEventHelper ) ProcessBuildEventHelper . CreateLoggingService ( LoggerMode . Synchronous , 1 , componentHost ) ;
945- ConfigCache cache = ( ConfigCache ) componentHost . GetComponent ( BuildComponentType . ConfigCache ) ;
946-
947- BuildRequestData data = new BuildRequestData ( ProjectFile , new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase ) , "toolsVersion" , Array . Empty < string > ( ) , null ) ;
948- BuildRequestConfiguration config = new BuildRequestConfiguration ( ConfigurationId , data , "4.0" ) ;
949- cache . AddConfiguration ( config ) ;
950-
951- BuildEventContext nodeBuildEventContext = BuildEventContext . CreateInitial ( 0 , NodeId ) ;
952- BuildEventContext projectStartedBuildEventContext = service . LogProjectStarted (
953- nodeBuildEventContext ,
954- submissionId : SubmissionId ,
955- configurationId : ConfigurationId ,
956- parentBuildEventContext : BuildEventContext . Invalid ,
957- projectFile : ProjectFile ,
958- targetNames : "TargetNames" ,
959- properties : null ,
960- items : null ,
961- evaluationId : EvaluationId ,
962- projectContextId : ProjectContextId ) ;
963- projectStartedBuildEventContext . ProjectContextId . ShouldBe ( ProjectContextId ) ;
964- }
965-
966917 #endregion
967918
968919 #region ProjectFinished
@@ -1422,17 +1373,9 @@ private void TestProjectFinishedEvent(string projectFile, bool success)
14221373 cache . AddConfiguration ( config ) ;
14231374
14241375 // Now do it the right way -- with a matching ProjectStarted.
1425- BuildEventContext projectContext = service . LogProjectStarted (
1426- BuildEventContext . CreateInitial ( 0 , 1 ) ,
1427- 1 ,
1428- 2 ,
1429- s_taskBuildEventContext ,
1430- projectFile ,
1431- null ,
1432- null ,
1433- null ,
1434- s_taskBuildEventContext . EvaluationId ,
1435- s_taskBuildEventContext . ProjectContextId ) ;
1376+ var projectStartedArgs = service . CreateProjectStartedForLocalProject ( s_taskBuildEventContext , 2 , projectFile , null , null , null , null , null ) ;
1377+ service . LogProjectStarted ( projectStartedArgs ) ;
1378+ BuildEventContext projectContext = projectStartedArgs . BuildEventContext ;
14361379
14371380 service . LogProjectFinished ( projectContext , projectFile , success ) ;
14381381
0 commit comments