@@ -1395,6 +1395,68 @@ public void ItemPredecessorToItem()
1395
1395
Assert . Equal ( null , metadatum . Predecessor . Predecessor ) ;
1396
1396
}
1397
1397
1398
+ [ Fact ]
1399
+ public void ItemPredecessorToItemWithCaseChange ( )
1400
+ {
1401
+ string content = ObjectModelHelpers . CleanupFileContents ( @"
1402
+ <Project xmlns='msbuildnamespace' >
1403
+ <ItemGroup>
1404
+ <item_with_lowercase_name Include='h1'>
1405
+ <m>1</m>
1406
+ </item_with_lowercase_name>
1407
+ <i Include='@(ITEM_WITH_LOWERCASE_NAME)'>
1408
+ <m>2;%(m)</m>
1409
+ </i>
1410
+ </ItemGroup>
1411
+ </Project>" ) ;
1412
+
1413
+ Project project = new Project ( XmlReader . Create ( new StringReader ( content ) ) ) ;
1414
+
1415
+ ProjectMetadataElement metadataElementFromProjectRootElement =
1416
+ project . Xml . Items . First ( ) . Metadata . First ( ) ;
1417
+
1418
+ Assert . Collection ( project . GetItems ( "i" ) , item =>
1419
+ {
1420
+ ProjectMetadata metadatum = item . GetMetadata ( "m" ) ;
1421
+
1422
+ Assert . Equal ( "2;1" , metadatum . EvaluatedValue ) ;
1423
+ Assert . Equal ( "1" , metadatum . Predecessor . EvaluatedValue ) ;
1424
+ Assert . Same ( metadataElementFromProjectRootElement , metadatum . Predecessor . Xml ) ;
1425
+
1426
+ Assert . Null ( metadatum . Predecessor . Predecessor ) ;
1427
+ } ) ;
1428
+ }
1429
+
1430
+ /// <summary>
1431
+ /// Should be removed when escape hatch for #1751 is removed
1432
+ /// </summary>
1433
+ [ Fact ]
1434
+ public void ItemPredecessorToItemWithCaseChangeAndEscapeHatch ( )
1435
+ {
1436
+ using ( new Helpers . TemporaryEnvironment ( "MSBUILDUSECASESENSITIVEITEMNAMES" , "1" ) )
1437
+ {
1438
+ string content = ObjectModelHelpers . CleanupFileContents ( @"
1439
+ <Project xmlns='msbuildnamespace' >
1440
+ <ItemGroup>
1441
+ <item_with_lowercase_name Include='h1'>
1442
+ <m>1</m>
1443
+ </item_with_lowercase_name>
1444
+ <i Include='@(ITEM_WITH_LOWERCASE_NAME)'>
1445
+ <m>2;%(m)</m>
1446
+ </i>
1447
+ </ItemGroup>
1448
+ </Project>" ) ;
1449
+
1450
+ Project project = new Project ( XmlReader . Create ( new StringReader ( content ) ) ) ;
1451
+
1452
+ ProjectMetadataElement metadataElementFromProjectRootElement =
1453
+ project . Xml . Items . First ( ) . Metadata . First ( ) ;
1454
+
1455
+ // empty because of the case mismatch
1456
+ Assert . Collection ( project . GetItems ( "i" ) ) ;
1457
+ }
1458
+ }
1459
+
1398
1460
/// <summary>
1399
1461
/// Predecessor of item is item via transform
1400
1462
/// </summary>
@@ -1421,6 +1483,58 @@ public void ItemPredecessorToItemViaTransform()
1421
1483
Assert . Equal ( null , metadatum . Predecessor ) ;
1422
1484
}
1423
1485
1486
+ [ Fact ]
1487
+ public void ItemPredecessorToItemViaTransformWithCaseChange ( )
1488
+ {
1489
+ string content = ObjectModelHelpers . CleanupFileContents ( @"
1490
+ <Project xmlns='msbuildnamespace' >
1491
+ <ItemGroup>
1492
+ <ITEM_WITH_UPPERCASE_NAME Include='h1'>
1493
+ <m>1</m>
1494
+ </ITEM_WITH_UPPERCASE_NAME>
1495
+ <i Include=""@(item_with_uppercase_name->'%(identity)')"">
1496
+ <m>2;%(m)</m>
1497
+ </i>
1498
+ </ItemGroup>
1499
+ </Project>" ) ;
1500
+
1501
+
1502
+ Project project = new Project ( XmlReader . Create ( new StringReader ( content ) ) ) ;
1503
+
1504
+ Assert . Collection ( project . GetItems ( "i" ) , item =>
1505
+ {
1506
+ Assert . Equal ( "h1" , item . EvaluatedInclude ) ;
1507
+ } ) ;
1508
+ }
1509
+
1510
+ /// <summary>
1511
+ /// Should be removed when escape hatch for #1751 is removed
1512
+ /// </summary>
1513
+ [ Fact ]
1514
+ public void ItemPredecessorToItemViaTransformWithCaseChangeWithEscapeHatch ( )
1515
+ {
1516
+ using ( new Helpers . TemporaryEnvironment ( "MSBUILDUSECASESENSITIVEITEMNAMES" , "1" ) )
1517
+ {
1518
+ string content = ObjectModelHelpers . CleanupFileContents ( @"
1519
+ <Project xmlns='msbuildnamespace' >
1520
+ <ItemGroup>
1521
+ <ITEM_WITH_UPPERCASE_NAME Include='h1'>
1522
+ <m>1</m>
1523
+ </ITEM_WITH_UPPERCASE_NAME>
1524
+ <i Include=""@(item_with_uppercase_name->'%(identity)')"">
1525
+ <m>2;%(m)</m>
1526
+ </i>
1527
+ </ItemGroup>
1528
+ </Project>" ) ;
1529
+
1530
+
1531
+ Project project = new Project ( XmlReader . Create ( new StringReader ( content ) ) ) ;
1532
+
1533
+ // Should be empty because of the case mismatch
1534
+ Assert . Collection ( project . GetItems ( "i" ) ) ;
1535
+ }
1536
+ }
1537
+
1424
1538
/// <summary>
1425
1539
/// Item predecessors and imports
1426
1540
/// </summary>
0 commit comments