Skip to content

Commit

Permalink
Some minor fixes before new version release (#2686)
Browse files Browse the repository at this point in the history
* 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 <parkerbibus@microsoft.com>
  • Loading branch information
adamsitnik and LoopedBard3 authored Jan 7, 2025
1 parent 1aab1c0 commit 3904631
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

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

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/BenchmarkDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<PackageReference Include="Perfolizer" Version="[0.4.0]" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.8" PrivateAssets="contentfiles;analyzers" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<!-- Do not update these packages, or else netcoreapp3.1 may no longer work -->
<PackageReference Include="System.Management" Version="6.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
Expand Down
13 changes: 10 additions & 3 deletions src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,17 @@ private static string GetCoreRunToolchainDisplayName(IReadOnlyList<FileInfo> pat
internal static bool TryParse(string runtime, out RuntimeMoniker runtimeMoniker)
{
int index = runtime.IndexOf('-');
if (index >= 0)
{
runtime = runtime.Substring(0, index);
}

return index < 0
? Enum.TryParse<RuntimeMoniker>(runtime.Replace(".", string.Empty), ignoreCase: true, out runtimeMoniker)
: Enum.TryParse<RuntimeMoniker>(runtime.Substring(0, index).Replace(".", string.Empty), ignoreCase: true, out runtimeMoniker);
// Monikers older than Net 10 don't use any version delimiter, newer monikers use _ delimiter.
if (Enum.TryParse(runtime.Replace(".", string.Empty), ignoreCase: true, out runtimeMoniker))
{
return true;
}
return Enum.TryParse(runtime.Replace('.', '_'), ignoreCase: true, out runtimeMoniker);
}
}
}
6 changes: 6 additions & 0 deletions tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,17 @@ public void NetFrameworkMonikerParsedCorrectly(string tfm)

[Theory]
[InlineData("net50")]
[InlineData("net5.0")]
[InlineData("net60")]
[InlineData("net6.0")]
[InlineData("net70")]
[InlineData("net7.0")]
[InlineData("net80")]
[InlineData("net8.0")]
[InlineData("net90")]
[InlineData("net9.0")]
[InlineData("net10_0")]
[InlineData("net10.0")]
public void NetMonikersAreRecognizedAsNetCoreMonikers(string tfm)
{
var config = ConfigParser.Parse(new[] { "-r", tfm }, new OutputLogger(Output)).config;
Expand Down

0 comments on commit 3904631

Please sign in to comment.