@@ -930,6 +930,65 @@ public void AppliesContentNegotiationRules_ToAllRelatedAssetEndpoints()
930
930
] ) ;
931
931
}
932
932
933
+ [ Fact ]
934
+ public void AppliesContentNegotiationRules_DoesNotFailWithCollectionModifiedException ( )
935
+ {
936
+ // This test reproduces the bug where shared lists were being modified during enumeration
937
+ var errorMessages = new List < string > ( ) ;
938
+ var buildEngine = new Mock < IBuildEngine > ( ) ;
939
+ buildEngine . Setup ( e => e . LogErrorEvent ( It . IsAny < BuildErrorEventArgs > ( ) ) )
940
+ . Callback < BuildErrorEventArgs > ( args => errorMessages . Add ( args . Message ) ) ;
941
+
942
+ var task = new ApplyCompressionNegotiation
943
+ {
944
+ BuildEngine = buildEngine . Object ,
945
+ CandidateAssets =
946
+ [
947
+ CreateCandidate (
948
+ Path . Combine ( "wwwroot" , "candidate.js" ) ,
949
+ "MyPackage" ,
950
+ "Discovered" ,
951
+ "candidate.js" ,
952
+ "All" ,
953
+ "All" ,
954
+ "original-fingerprint" ,
955
+ "original" ,
956
+ fileLength : 20
957
+ ) ,
958
+ CreateCandidate (
959
+ Path . Combine ( "compressed" , "candidate.js.gz" ) ,
960
+ "MyPackage" ,
961
+ "Discovered" ,
962
+ "candidate.js" ,
963
+ "All" ,
964
+ "All" ,
965
+ "compressed-fingerprint" ,
966
+ "compressed" ,
967
+ Path . Combine ( "wwwroot" , "candidate.js" ) ,
968
+ "Content-Encoding" ,
969
+ "gzip" ,
970
+ 9
971
+ )
972
+ ] ,
973
+ CandidateEndpoints =
974
+ [
975
+ CreateCandidateEndpoint (
976
+ "candidate.js" ,
977
+ Path . Combine ( "wwwroot" , "candidate.js" ) ,
978
+ CreateHeaders ( "text/javascript" , [ ( "Content-Length" , "20" ) , ( "Cache-Control" , "max-age=3600" ) , ( "ETag" , "\" original-etag\" " ) , ( "Last-Modified" , "Wed, 01 Jan 2020 00:00:00 GMT" ) ] ) ) ,
979
+
980
+ CreateCandidateEndpoint (
981
+ "candidate.js.gz" ,
982
+ Path . Combine ( "compressed" , "candidate.js.gz" ) ,
983
+ CreateHeaders ( "text/javascript" , [ ( "Content-Length" , "9" ) , ( "Cache-Control" , "max-age=3600" ) , ( "ETag" , "\" compressed-etag\" " ) , ( "Last-Modified" , "Wed, 01 Jan 2020 00:00:00 GMT" ) ] ) )
984
+ ] ,
985
+ } ;
986
+
987
+ // Act & Assert - This should not throw a CollectionModifiedException
988
+ var result = task . Execute ( ) ;
989
+ result . Should ( ) . Be ( true ) ;
990
+ }
991
+
933
992
[ Fact ]
934
993
public void AppliesContentNegotiationRules_IgnoresAlreadyProcessedEndpoints ( )
935
994
{
0 commit comments