-
-
Notifications
You must be signed in to change notification settings - Fork 969
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
Fix #1715 #2184
base: master
Are you sure you want to change the base?
Fix #1715 #2184
Conversation
I'm OK with removing quotes, but it's a breaking change that can cause problems for BenchmarkDotNet users who parse the output of Exporters. If we introduce this change, we should provide a way to rollback to the previous behavior. |
Done. Instead of extending [assembly: RevertOldBehaviourForBenchmarkName] The attribute seems more elegant for this. |
Option 1it will work like this: //BenchmarkConverter.cs
//type is benchmark type
BenchmarkRunInfo MethodsToBenchmarksWithFullConfig(Type type, ...)
{
bool revertOldBehaviour = type.Assembly.GetCustomAttributes().OfType<RevertOldBehaviourForBenchmarkName>();
var targets = GetTargets(..., revertOldBehaviour);
} cons:
[Edit] Option 2Instead, we can make cons
ChangelogMaybe it makes sense to add a "breaking change" paragraph to the changelog? Users will notice this breaking change when they break their CI or erase benchmark history (because the name is changed). The [Edit2] |
I was thinking about an approach inspired by the .NET Runtime knobs. We can introduce @adamsitnik @YegorStepanov what do you think about such a design? |
I like it. Will be done. Does it make sense to add the public class Knob
{
public const string QuoteBenchmarkNamesWithSpecialChars = "...";
}
[Knob(Knob.QuoteBenchmarkNamesWithSpecialChars, true)] |
@YegorStepanov, I was thinking about something like this: public abstract class Knob<T>
{
public string Key { get; }
public T DefaultValue { get; }
protected Knob(string key, T defaultValue)
{
Key = key;
DefaultValue = defaultValue;
}
protected abstract T Parse(string value);
public T GetValue(IConfig config)
{
string value = config.GetKnobValue(Key) ?? Environment.GetEnvironmentVariable("BDN_" + Key);
return Parse(value);
}
}
public class BoolKnob : Knob<bool>
{
public BoolKnob(string key, bool defaultValue) : base(key, defaultValue) { }
protected override bool Parse(string value) =>
value?.ToLowerInvariant() switch
{
"0" or "f" or "false" => false,
"1" or "t" or "true" => true,
_ => DefaultValue
};
}
public class Knobs
{
public const string QuoteBenchmarkNamesWithSpecialCharsKey = "QuoteBenchmarkNamesWithSpecialChars";
public BoolKnob QuoteBenchmarkNamesWithSpecialChars = new (QuoteBenchmarkNamesWithSpecialCharsKey, false);
} P.S. Let's wait for an opinion by @adamsitnik before we start to implement this. |
fix #1715