Skip to content
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

change the runtimes API #1277

Merged
merged 2 commits into from Oct 12, 2019
Merged

change the runtimes API #1277

merged 2 commits into from Oct 12, 2019

Conversation

adamsitnik
Copy link
Member

@AndreyAkinshin this fixes the things we have discussed yesterday at Dotnetos

  • Don't introduce NetCoreLatest and its friends
  • Rename TargetFrameworkJob -> SimpleJob (don't introduce JobAttribute in 0.12)
  • Rename TargetFrameworkMoniker -> RuntimeMoniker

When it comes to:

  • We make [ClrJob] are friends as obsolete without errors (warning only) and use InvalidConfig with nice message

I made it a warning as we talked but I've not introduced the concept of InvalidConfig.

What I did instead is to call the GetCurrentVersion method for every runtime.

public ClrJobAttribute() : base(Job.Default.With(ClrRuntime.GetCurrentVersion()))

If the host runtime == job runtime, then it's going to work fine (99% of the cases). If the runtimes are different: for example running as Full .NET Framework and trying to use [CoreJob] attribute, then GetCurrentVersion is going to throw:

throw new NotSupportedException("It's impossible to reliably detect the version of .NET Core if the process is not a .NET Core process!");

[TargetFrameworkJob(TargetFrameworkMoniker.Mono)]
[TargetFrameworkJob(TargetFrameworkMoniker.NetCoreApp21)]
[TargetFrameworkJob(TargetFrameworkMoniker.NetCoreApp30)]
[SimpleJob(runtimeMoniker: RuntimeMoniker.Net48)]
Copy link
Member

Choose a reason for hiding this comment

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

Don't like the runtimeMoniker prefix. Could we introduce a few additional SimpleJobAttribute ctor overloads with the RuntimeMoniker as the first ctor argument?

[Obsolete("Please use SimpleJobAttribute instead.", false)]
public class ClrJobAttribute : JobConfigBaseAttribute
{
public ClrJobAttribute() : base(Job.Default.With(ClrRuntime.GetCurrentVersion()))
Copy link
Member

Choose a reason for hiding this comment

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

👍


namespace BenchmarkDotNet.Attributes
{
[Obsolete("Please use DryJobAttribute instead. Use the ctor that requires RuntimeMoniker argument.", false)]
Copy link
Member

Choose a reason for hiding this comment

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

Instead of "Use the ctor that requires RuntimeMoniker argument", it will be better to write a code example that can be copy-pasted.

@AndreyAkinshin
Copy link
Member

@adamsitnik in general, it looks very good, thanks! I left just a few minor (but important) comments.

@adamsitnik
Copy link
Member Author

@AndreyAkinshin thanks for the review! I've pushed the fixes. Please let me know if there is any blocker for 0.11.6 from my side

@AndreyAkinshin AndreyAkinshin added this to the v0.11.6 milestone Oct 12, 2019
@AndreyAkinshin AndreyAkinshin merged commit da63e84 into master Oct 12, 2019
@AndreyAkinshin AndreyAkinshin deleted the runtimeApiChanges branch October 12, 2019 18:30
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.

None yet

2 participants