@@ -18,15 +18,6 @@ namespace Microsoft.Build.BackEnd
1818 /// </summary>
1919 internal class ResultsCache : IResultsCache
2020 {
21- /// <summary>
22- /// The presence of any of these flags affects build result for the specified request.
23- /// </summary>
24- private const BuildRequestDataFlags FlagsAffectingBuildResults =
25- BuildRequestDataFlags . ProvideProjectStateAfterBuild
26- | BuildRequestDataFlags . SkipNonexistentTargets
27- | BuildRequestDataFlags . IgnoreMissingEmptyAndInvalidImports
28- | BuildRequestDataFlags . FailOnUnresolvedSdk ;
29-
3021 /// <summary>
3122 /// The table of all build results. This table is indexed by configuration id and
3223 /// contains BuildResult objects which have all of the target information.
@@ -149,11 +140,10 @@ public BuildResult GetResultsForConfiguration(int configurationId)
149140
150141 /// <summary>
151142 /// Attempts to satisfy the request from the cache. The request can be satisfied only if:
152- /// 1. The passed BuildRequestDataFlags can not affect the result data.
153- /// 2. All specified targets in the request have successful results in the cache or if the sequence of target results
143+ /// 1. All specified targets in the request have successful results in the cache or if the sequence of target results
154144 /// includes 0 or more successful targets followed by at least one failed target.
155- /// 3 . All initial targets in the configuration for the request have non-skipped results in the cache.
156- /// 4 . If there are no specified targets, then all default targets in the request must have non-skipped results
145+ /// 2 . All initial targets in the configuration for the request have non-skipped results in the cache.
146+ /// 3 . If there are no specified targets, then all default targets in the request must have non-skipped results
157147 /// in the cache.
158148 /// </summary>
159149 /// <param name="request">The request whose results we should return.</param>
@@ -173,53 +163,47 @@ public ResultsCacheResponse SatisfyRequest(BuildRequest request, List<string> co
173163 {
174164 if ( _resultsByConfiguration . TryGetValue ( request . ConfigurationId , out BuildResult allResults ) )
175165 {
176- bool buildDataFlagsSatisfied = ChangeWaves . AreFeaturesEnabled ( ChangeWaves . Wave17_10 )
177- ? CheckBuildDataFlagsResults ( request . BuildRequestDataFlags , allResults . BuildRequestDataFlags ) : true ;
166+ // Check for targets explicitly specified.
167+ bool explicitTargetsSatisfied = CheckResults ( allResults , request . Targets , response . ExplicitTargetsToBuild , skippedResultsDoNotCauseCacheMiss ) ;
178168
179- if ( buildDataFlagsSatisfied )
169+ if ( explicitTargetsSatisfied )
180170 {
181- // Check for targets explicitly specified.
182- bool explicitTargetsSatisfied = CheckResults ( allResults , request . Targets , response . ExplicitTargetsToBuild , skippedResultsDoNotCauseCacheMiss ) ;
171+ // All of the explicit targets, if any, have been satisfied
172+ response . Type = ResultsCacheResponseType . Satisfied ;
183173
184- if ( explicitTargetsSatisfied )
174+ // Check for the initial targets. If we don't know what the initial targets are, we assume they are not satisfied.
175+ if ( configInitialTargets == null || ! CheckResults ( allResults , configInitialTargets , null , skippedResultsDoNotCauseCacheMiss ) )
185176 {
186- // All of the explicit targets, if any, have been satisfied
187- response . Type = ResultsCacheResponseType . Satisfied ;
177+ response . Type = ResultsCacheResponseType . NotSatisfied ;
178+ }
188179
189- // Check for the initial targets. If we don't know what the initial targets are, we assume they are not satisfied.
190- if ( configInitialTargets == null || ! CheckResults ( allResults , configInitialTargets , null , skippedResultsDoNotCauseCacheMiss ) )
180+ // We could still be missing implicit targets, so check those...
181+ if ( request . Targets . Count == 0 )
182+ {
183+ // Check for the default target, if necessary. If we don't know what the default targets are, we
184+ // assume they are not satisfied.
185+ if ( configDefaultTargets == null || ! CheckResults ( allResults , configDefaultTargets , null , skippedResultsDoNotCauseCacheMiss ) )
191186 {
192187 response . Type = ResultsCacheResponseType . NotSatisfied ;
193188 }
189+ }
194190
195- // We could still be missing implicit targets, so check those...
196- if ( request . Targets . Count == 0 )
191+ // Now report those results requested, if they are satisfied.
192+ if ( response . Type == ResultsCacheResponseType . Satisfied )
193+ {
194+ List < string > targetsToAddResultsFor = new List < string > ( configInitialTargets ) ;
195+
196+ // Now report either the explicit targets or the default targets
197+ if ( request . Targets . Count > 0 )
197198 {
198- // Check for the default target, if necessary. If we don't know what the default targets are, we
199- // assume they are not satisfied.
200- if ( configDefaultTargets == null || ! CheckResults ( allResults , configDefaultTargets , null , skippedResultsDoNotCauseCacheMiss ) )
201- {
202- response . Type = ResultsCacheResponseType . NotSatisfied ;
203- }
199+ targetsToAddResultsFor . AddRange ( request . Targets ) ;
204200 }
205-
206- // Now report those results requested, if they are satisfied.
207- if ( response . Type == ResultsCacheResponseType . Satisfied )
201+ else
208202 {
209- List < string > targetsToAddResultsFor = new List < string > ( configInitialTargets ) ;
210-
211- // Now report either the explicit targets or the default targets
212- if ( request . Targets . Count > 0 )
213- {
214- targetsToAddResultsFor . AddRange ( request . Targets ) ;
215- }
216- else
217- {
218- targetsToAddResultsFor . AddRange ( configDefaultTargets ) ;
219- }
220-
221- response . Results = new BuildResult ( request , allResults , targetsToAddResultsFor . ToArray ( ) , null ) ;
203+ targetsToAddResultsFor . AddRange ( configDefaultTargets ) ;
222204 }
205+
206+ response . Results = new BuildResult ( request , allResults , targetsToAddResultsFor . ToArray ( ) , null ) ;
223207 }
224208 }
225209 }
@@ -344,20 +328,6 @@ private static bool CheckResults(BuildResult result, List<string> targets, HashS
344328 return returnValue ;
345329 }
346330
347- /// <summary>
348- /// Checks results for the specified build flags.
349- /// </summary>
350- /// <param name="buildRequestDataFlags">The current request build flags.</param>
351- /// <param name="buildResultDataFlags">The existing build result data flags.</param>
352- /// <returns>False if there is any difference in the data flags that can cause missed build data, true otherwise.</returns>
353- private static bool CheckBuildDataFlagsResults ( BuildRequestDataFlags buildRequestDataFlags , BuildRequestDataFlags buildResultDataFlags ) =>
354-
355- // Even if both buildRequestDataFlags and buildResultDataFlags have ProvideSubsetOfStateAfterBuild flag,
356- // the underlying RequestedProjectState may have different user filters defined.
357- // It is more reliable to ignore the cached value.
358- ! buildRequestDataFlags . HasFlag ( BuildRequestDataFlags . ProvideSubsetOfStateAfterBuild )
359- && ( buildRequestDataFlags & FlagsAffectingBuildResults ) == ( buildResultDataFlags & FlagsAffectingBuildResults ) ;
360-
361331 public IEnumerator < BuildResult > GetEnumerator ( )
362332 {
363333 return _resultsByConfiguration . Values . GetEnumerator ( ) ;
0 commit comments