Skip to content

Conversation

kant2002
Copy link
Contributor

For now added either rd.xml or files which ends with .rd.xml
Rename rd.xml supplied by BDN to bdn_generated.rd.xml

Closes #1680

For now added either `rd.xml` or files which ends with `.rd.xml`
Rename `rd.xml` supplied by BDN to `bdn_generated.rd.xml`
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kant2002 big thanks for your contribution!

could you PTAL at the CI failures?

/home/runner/work/BenchmarkDotNet/BenchmarkDotNet/tests/BenchmarkDotNet.IntegrationTests/bin/Release/net5.0/0961d928-ba98-4cca-b6af-fc04c1f5807a/BenchmarkDotNet.Autogenerated.csproj(37,3): error MSB4067: The element <#text> beneath element <ItemGroup> is unrecognized.

you should be able to repro it locally by doing:

dotnet run -c Release -f net5.0 --project .\samples\BenchmarkDotNet.Samples\BenchmarkDotNet.Samples.csproj --filter '*Basic*' --job dry --runtimes nativeaot5.0 --keepFiles true

</ItemGroup>
<ItemGroup>
<RdXmlFile Include=""rd.xml"" />
{GetRdXmlFiles(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).Select(_ => $"<RdXmlFile Include=\"{_}\" />{Environment.NewLine}")}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit _ is typically used when the argument is ignored. In this case, we are using it.

Suggested change
{GetRdXmlFiles(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).Select(_ => $"<RdXmlFile Include=\"{_}\" />{Environment.NewLine}")}
{GetRdXmlFiles(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).Select(file => $"<RdXmlFile Include=\"{file}\" />{Environment.NewLine}")}

</ItemGroup>
<ItemGroup>
<RdXmlFile Include=""rd.xml"" />
{GetRdXmlFiles(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).Select(_ => $"<RdXmlFile Include=\"{_}\" />{Environment.NewLine}")}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{GetRdXmlFiles(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).Select(_ => $"<RdXmlFile Include=\"{_}\" />{Environment.NewLine}")}
{GetRdXmlFiles(buildPartition.RepresentativeBenchmarkCase.Descriptor.Type, logger).Select(file => $"<RdXmlFile Include=\"{file}\" />{Environment.NewLine}")}

Comment on lines +209 to +221
var projectFile = GetProjectFilePath(benchmarkTarget, logger);
var projectFileFolder = projectFile.DirectoryName;
yield return GeneratedRdXmlFileName;
var rdXml = Path.Combine(projectFileFolder, "rd.xml");
if (File.Exists(rdXml))
{
yield return rdXml;
}

foreach (var item in Directory.GetFiles(projectFileFolder, "*.rd.xml"))
{
yield return item;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like this could be simplified if we search for *rd.xm files:

Suggested change
var projectFile = GetProjectFilePath(benchmarkTarget, logger);
var projectFileFolder = projectFile.DirectoryName;
yield return GeneratedRdXmlFileName;
var rdXml = Path.Combine(projectFileFolder, "rd.xml");
if (File.Exists(rdXml))
{
yield return rdXml;
}
foreach (var item in Directory.GetFiles(projectFileFolder, "*.rd.xml"))
{
yield return item;
}
yield return GeneratedRdXmlFileName;
var projectFileFolder = GetProjectFilePath(benchmarkTarget, logger).DirectoryName;
foreach (var rdFile in Directory.GetFiles(projectFileFolder, "*rd.xml"))
{
yield return rdFile;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if somebody have library which ends with rd? or just XML files. For example Thunderbird.xml, that would be captured.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that neither *.rd.xml and *rd.xml are good filters, as users can call their files without rd prefix like nativeaot_rules.xml. But since it's a project with BenchmarkDotNet benchmarks we could just tell them that all that we support is rd.xml. @kant2002 what do you think?

@MichalStrehovsky what is your opinion on that? Are NativeAOT using names other than rd.xml for their RdXmlFile files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my experience projects in the wild was using either just rd.xml or I recentrly start push for separate files per library, to at least simplify mundane work. Naming convention which I propose is exaclly nuget_package.rd.xml. Also seems to be .NET Native Rd.xml also has approximately same convention, so that's why I choose that pattern.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*.rd.xml is the convention that most people are sticking with. I don't recall ever seeing an rd.xml file without that extension.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, big thanks @kant2002 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot override RD.xml for NativeAOT
4 participants