-
-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for user-supplied project file detection #2684
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
39791f7
Add support for user-supplied project file detection
Genbox 94aa84c
Make ProjectLocator fall back to other locators if enabled
Genbox b7b2130
Implement most of the suggestion
Genbox fd4bb75
Use fallback logic instead
Genbox 4d84092
Add a few docs and use default code style
Genbox 33ab1dd
Include file locator paths in exception message
Genbox 4479071
Update src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs
Genbox fcd632e
Create integration test
Genbox 4802d24
Support .NET Framework csproj tool chain as well
Genbox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using BenchmarkDotNet.Loggers; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace BenchmarkDotNet.Locators; | ||
|
||
public class FileLocatorArgs | ||
{ | ||
public FileLocatorArgs(BenchmarkCase benchmarkCase, ILogger logger) | ||
{ | ||
BenchmarkCase = benchmarkCase; | ||
Logger = logger; | ||
} | ||
|
||
public BenchmarkCase BenchmarkCase { get; } | ||
public ILogger Logger { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace BenchmarkDotNet.Locators; | ||
|
||
public enum FileLocatorType | ||
{ | ||
Project | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.IO; | ||
|
||
namespace BenchmarkDotNet.Locators; | ||
|
||
/// <summary> | ||
/// Locators can be used to extend the default behavior of finding files | ||
/// </summary> | ||
public interface IFileLocator | ||
{ | ||
/// <summary> | ||
/// The type of locator | ||
/// </summary> | ||
FileLocatorType LocatorType { get; } | ||
|
||
/// <summary> | ||
/// Tries to locate a file | ||
/// </summary> | ||
/// <param name="fileLocatorArgs">The arguments such as benchmark and logger</param> | ||
/// <param name="fileInfo">The file is provided by the implementation</param> | ||
/// <returns>True when a file was successfully found, False otherwise.</returns> | ||
bool TryLocate(FileLocatorArgs fileLocatorArgs, out FileInfo fileInfo); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/BenchmarkDotNet.IntegrationTests.FileLocators/AssemblyNameIsSetBenchmarks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using BenchmarkDotNet.Attributes; | ||
|
||
namespace BenchmarkDotNet.IntegrationTests.FileLocators | ||
{ | ||
public class AssemblyNameIsSetBenchmarks | ||
{ | ||
[Benchmark] | ||
public string Benchmark() | ||
{ | ||
return "This will only run when a FileLocator is set due to <AssemblyName> in the csproj"; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting the breaking change to a public API.