@@ -1561,6 +1561,111 @@ public void BaselineBenchmarkMethod3()
15611561 await RunAsync ( ) ;
15621562 }
15631563
1564+ [ Theory , CombinatorialData ]
1565+ public async Task Class_with_more_than_one_benchmark_method_marked_as_baseline_per_unique_category_with_unknown_values_should_not_trigger_diagnostic ( [ CombinatorialMemberData ( nameof ( ClassAbstractModifiersEnumerableLocal ) ) ] string abstractModifier ,
1566+ bool useConstantsFromOtherClass ,
1567+ bool useLocalConstants ,
1568+ [ CombinatorialMemberData ( nameof ( BenchmarkCategoryAttributeValuesContainerEnumerableLocal ) , true ) ] string valuesContainer ,
1569+ [ CombinatorialValues ( "dummy_literal" , "1" , "true" ) ] string invalidCategoryStringValue ,
1570+ bool useDuplicateInSameClass )
1571+ {
1572+ var baselineBenchmarkAttributeUsage = $ "[Benchmark(Baseline = { ( useLocalConstants ? "_xTrue" : useConstantsFromOtherClass ? "Constants.Value1" : "true" ) } )]";
1573+ var nonBaselineBenchmarkAttributeUsage = $ "[Benchmark(Baseline = { ( useLocalConstants ? "_xFalse" : useConstantsFromOtherClass ? "Constants.Value2" : "false" ) } )]";
1574+
1575+ var testCode = /* lang=c#-test */ $$ """
1576+ using BenchmarkDotNet.Attributes;
1577+
1578+ public class BenchmarkClass : BenchmarkClassAncestor1
1579+ {
1580+ {{ ( useLocalConstants ? $ """
1581+ private const bool _xTrue = { ( useConstantsFromOtherClass ? "Constants.Value1" : "true" ) } ;
1582+ private const bool _xFalse = { ( useConstantsFromOtherClass ? "Constants.Value2" : "false" ) } ;
1583+ """ : "" ) }}
1584+
1585+ [BenchmarkCategory({{ string . Format ( valuesContainer , $ """
1586+ null, { invalidCategoryStringValue } , null, "TEST", "test2"
1587+ """ ) }} )]
1588+ {{ baselineBenchmarkAttributeUsage }}
1589+ public void BaselineBenchmarkMethod1()
1590+ {
1591+
1592+ }
1593+
1594+ [BenchmarkCategory({{ string . Format ( valuesContainer , "null, null" ) }} )]
1595+ [BenchmarkCategory({{ string . Format ( valuesContainer , """
1596+ "test", null
1597+ """ ) }} )]
1598+ [BenchmarkCategory({{ string . Format ( valuesContainer , """
1599+ "test2"
1600+ """ ) }} )]
1601+ {{ ( useDuplicateInSameClass ? baselineBenchmarkAttributeUsage : "" ) }}
1602+ public void BaselineBenchmarkMethod2()
1603+ {
1604+
1605+ }
1606+
1607+ [BenchmarkCategory("Category1")]
1608+ {{ nonBaselineBenchmarkAttributeUsage }}
1609+ public void NonBaselineBenchmarkMethod1()
1610+ {
1611+
1612+ }
1613+
1614+ [BenchmarkCategory("Category1")]
1615+ public void DummyMethod()
1616+ {
1617+
1618+ }
1619+
1620+ [Benchmark]
1621+ public void NonBaselineBenchmarkMethod2()
1622+ {
1623+
1624+ }
1625+
1626+ {{ nonBaselineBenchmarkAttributeUsage }}
1627+ public void NonBaselineBenchmarkMethod3()
1628+ {
1629+
1630+ }
1631+ }
1632+ """ ;
1633+
1634+ var benchmarkClassAncestor1Document = /* lang=c#-test */ $$ """
1635+ public {{ abstractModifier }} class BenchmarkClassAncestor1 : BenchmarkClassAncestor2
1636+ {
1637+ }
1638+ """ ;
1639+
1640+ var benchmarkClassAncestor2Document = /* lang=c#-test */ $$ """
1641+ using BenchmarkDotNet.Attributes;
1642+
1643+ public {{ abstractModifier }} class BenchmarkClassAncestor2
1644+ {
1645+ {{ ( useLocalConstants ? $ "private const bool _xTrue = { ( useConstantsFromOtherClass ? "Constants.Value1" : "true" ) } ;" : "" ) }}
1646+
1647+ [BenchmarkCategory({{ string . Format ( valuesContainer , "null, null" ) }} )]
1648+ [BenchmarkCategory({{ string . Format ( valuesContainer , $ "{ invalidCategoryStringValue } , null") }} )]
1649+ [BenchmarkCategory({{ string . Format ( valuesContainer , """
1650+ "test2"
1651+ """ ) }} )]
1652+ {{ baselineBenchmarkAttributeUsage }}
1653+ public void BaselineBenchmarkMethod3()
1654+ {
1655+
1656+ }
1657+ }
1658+ """ ;
1659+
1660+ TestCode = testCode ;
1661+ ReferenceConstants ( ( "bool" , "true" ) , ( "bool" , "false" ) ) ;
1662+ AddSource ( benchmarkClassAncestor1Document ) ;
1663+ AddSource ( benchmarkClassAncestor2Document ) ;
1664+ DisableCompilerDiagnostics ( ) ;
1665+
1666+ await RunAsync ( ) ;
1667+ }
1668+
15641669 [ Theory , CombinatorialData ]
15651670 public async Task Class_with_more_than_one_benchmark_method_marked_as_baseline_per_unique_category_should_trigger_diagnostic ( [ CombinatorialMemberData ( nameof ( ClassAbstractModifiersEnumerableLocal ) ) ] string abstractModifier ,
15661671 bool useConstantsFromOtherClass ,
@@ -1591,7 +1696,6 @@ public void BaselineBenchmarkMethod1()
15911696
15921697 }
15931698
1594-
15951699 [BenchmarkCategory({{ string . Format ( valuesContainer , "null, null" ) }} )]
15961700 [BenchmarkCategory({{ string . Format ( valuesContainer , """
15971701 "test", null
0 commit comments