diff --git a/src/BenchmarkDotNet/Running/BenchmarkConverter.cs b/src/BenchmarkDotNet/Running/BenchmarkConverter.cs
index a83926d934..754cf9f9d1 100644
--- a/src/BenchmarkDotNet/Running/BenchmarkConverter.cs
+++ b/src/BenchmarkDotNet/Running/BenchmarkConverter.cs
@@ -21,7 +21,7 @@ public static partial class BenchmarkConverter
public static BenchmarkRunInfo TypeToBenchmarks(Type type, IConfig config = null)
{
if (type.IsGenericTypeDefinition)
- throw new ArgumentException($"{type.Name} is generic type definition, use BenchmarkSwitcher for it"); // for "open generic types" should be used BenchmarkSwitcher
+ throw new InvalidBenchmarkDeclarationException($"{type.Name} is generic type definition, use BenchmarkSwitcher for it"); // for "open generic types" should be used BenchmarkSwitcher
// We should check all methods including private to notify users about private methods with the [Benchmark] attribute
var benchmarkMethods = GetOrderedBenchmarkMethods(type.GetMethods(AllMethodsFlags));
diff --git a/src/BenchmarkDotNet/Running/BenchmarkRunnerDirty.cs b/src/BenchmarkDotNet/Running/BenchmarkRunnerDirty.cs
index 9f545164d2..0d51ae08a7 100644
--- a/src/BenchmarkDotNet/Running/BenchmarkRunnerDirty.cs
+++ b/src/BenchmarkDotNet/Running/BenchmarkRunnerDirty.cs
@@ -1,4 +1,5 @@
using System;
+using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -65,14 +66,22 @@ public static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)
return RunWithExceptionHandling(() => RunWithDirtyAssemblyResolveHelper(benchmarkRunInfos));
}
+ ///
+ /// Supported only on Full .NET Framework. Not recommended.
+ ///
[PublicAPI]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public static Summary RunUrl(string url, IConfig config = null)
{
using (DirtyAssemblyResolveHelper.Create())
return RunWithExceptionHandling(() => RunUrlWithDirtyAssemblyResolveHelper(url, config));
}
+ ///
+ /// Supported only on Full .NET Framework. Not recommended.
+ ///
[PublicAPI]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public static Summary RunSource(string source, IConfig config = null)
{
using (DirtyAssemblyResolveHelper.Create())
@@ -110,13 +119,13 @@ private static Summary[] RunWithDirtyAssemblyResolveHelper(BenchmarkRunInfo[] be
private static Summary RunUrlWithDirtyAssemblyResolveHelper(string url, IConfig config = null)
=> RuntimeInformation.IsFullFramework
? BenchmarkRunnerClean.Run(BenchmarkConverter.UrlToBenchmarks(url, config)).Single()
- : throw new NotSupportedException("Supported only on Full .NET Framework");
+ : throw new InvalidBenchmarkDeclarationException("Supported only on Full .NET Framework");
[MethodImpl(MethodImplOptions.NoInlining)]
private static Summary RunSourceWithDirtyAssemblyResolveHelper(string source, IConfig config = null)
=> RuntimeInformation.IsFullFramework
? BenchmarkRunnerClean.Run(BenchmarkConverter.SourceToBenchmarks(source, config)).Single()
- : throw new NotSupportedException("Supported only on Full .NET Framework");
+ : throw new InvalidBenchmarkDeclarationException("Supported only on Full .NET Framework");
private static Summary RunWithExceptionHandling(Func run)
{
diff --git a/src/BenchmarkDotNet/Running/ClassicBenchmarkConverter.cs b/src/BenchmarkDotNet/Running/ClassicBenchmarkConverter.cs
index 6e69e8b7c2..15e01156da 100644
--- a/src/BenchmarkDotNet/Running/ClassicBenchmarkConverter.cs
+++ b/src/BenchmarkDotNet/Running/ClassicBenchmarkConverter.cs
@@ -11,6 +11,7 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Loggers;
+using BenchmarkDotNet.Portability;
using Microsoft.CSharp;
namespace BenchmarkDotNet.Running
@@ -23,6 +24,9 @@ public static partial class BenchmarkConverter
public static BenchmarkRunInfo[] UrlToBenchmarks(string url, IConfig config = null)
{
+ if (!RuntimeInformation.IsFullFramework)
+ throw new NotSupportedException("Supported only on Full .NET Framework.");
+
var logger = HostEnvironmentInfo.FallbackLogger;
url = GetRawUrl(url);
@@ -63,6 +67,9 @@ public static BenchmarkRunInfo[] UrlToBenchmarks(string url, IConfig config = nu
public static BenchmarkRunInfo[] SourceToBenchmarks(string source, IConfig config = null)
{
+ if (!RuntimeInformation.IsFullFramework)
+ throw new NotSupportedException("Supported only on Full .NET Framework.");
+
string benchmarkContent = source;
CompilerResults compilerResults;
using (var cSharpCodeProvider = new CSharpCodeProvider()) {