Skip to content

Commit 3904631

Browse files
Some minor fixes before new version release (#2686)
* Updated per feedback. Updated the ConfigParser TryParse method to take into account _s in net10.0 and beyond enum names, and updated the ConfigParserTests to take this update into account. * update Microsoft.CodeAnalysis.CSharp to 4.12.0 to stop referencing an old version of System.Collections.Immutable * add new test cases, don't remove existing ones --------- Co-authored-by: Parker Bibus <[email protected]>
1 parent 1aab1c0 commit 3904631

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

build/common.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2424

2525
<Nullable>annotations</Nullable>
26+
<!-- Lets supress the "System.Collections.Immutable 8.0.0 doesn't support netcoreapp3.1" warning -->
27+
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
2628
</PropertyGroup>
2729

2830
<ItemGroup>

src/BenchmarkDotNet/BenchmarkDotNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
<PackageReference Include="Perfolizer" Version="[0.4.0]" />
2323
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.8" PrivateAssets="contentfiles;analyzers" />
2424
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
25+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
2526
<!-- Do not update these packages, or else netcoreapp3.1 may no longer work -->
2627
<PackageReference Include="System.Management" Version="6.0.0" />
27-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
2828
</ItemGroup>
2929
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
3030
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />

src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,10 +774,17 @@ private static string GetCoreRunToolchainDisplayName(IReadOnlyList<FileInfo> pat
774774
internal static bool TryParse(string runtime, out RuntimeMoniker runtimeMoniker)
775775
{
776776
int index = runtime.IndexOf('-');
777+
if (index >= 0)
778+
{
779+
runtime = runtime.Substring(0, index);
780+
}
777781

778-
return index < 0
779-
? Enum.TryParse<RuntimeMoniker>(runtime.Replace(".", string.Empty), ignoreCase: true, out runtimeMoniker)
780-
: Enum.TryParse<RuntimeMoniker>(runtime.Substring(0, index).Replace(".", string.Empty), ignoreCase: true, out runtimeMoniker);
782+
// Monikers older than Net 10 don't use any version delimiter, newer monikers use _ delimiter.
783+
if (Enum.TryParse(runtime.Replace(".", string.Empty), ignoreCase: true, out runtimeMoniker))
784+
{
785+
return true;
786+
}
787+
return Enum.TryParse(runtime.Replace('.', '_'), ignoreCase: true, out runtimeMoniker);
781788
}
782789
}
783790
}

tests/BenchmarkDotNet.Tests/ConfigParserTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,17 @@ public void NetFrameworkMonikerParsedCorrectly(string tfm)
384384

385385
[Theory]
386386
[InlineData("net50")]
387+
[InlineData("net5.0")]
387388
[InlineData("net60")]
389+
[InlineData("net6.0")]
388390
[InlineData("net70")]
391+
[InlineData("net7.0")]
389392
[InlineData("net80")]
393+
[InlineData("net8.0")]
390394
[InlineData("net90")]
395+
[InlineData("net9.0")]
391396
[InlineData("net10_0")]
397+
[InlineData("net10.0")]
392398
public void NetMonikersAreRecognizedAsNetCoreMonikers(string tfm)
393399
{
394400
var config = ConfigParser.Parse(new[] { "-r", tfm }, new OutputLogger(Output)).config;

0 commit comments

Comments
 (0)