Remove the dependency on System.ValueTuple (#63)
* Add an option to get tuple data via reflection. * Removed non-relfection-based way of getting information about the tuples. * Make methods static back. * Remove the nuget dependency to System.ValueTuple
This commit is contained in:
committed by
Ben Adams
parent
7381924470
commit
125e373b45
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Attributes.Jobs;
|
||||
@@ -14,5 +15,26 @@ namespace Ben.Demystifier.Benchmarks
|
||||
|
||||
[Benchmark(Description = "Demystify().ToString()")]
|
||||
public string Demystify() => new Exception().Demystify().ToString();
|
||||
|
||||
[Benchmark(Description = "(left, right).ToString()")]
|
||||
public string ToStringForTupleBased() => GetException(() => ReturnsTuple()).ToString();
|
||||
|
||||
[Benchmark(Description = "(left, right).Demystify().ToString()")]
|
||||
public string ToDemystifyForTupleBased() => GetException(() => ReturnsTuple()).Demystify().ToString();
|
||||
|
||||
private static Exception GetException(Action action)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
throw new InvalidOperationException("Should not be reachable.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<(int left, int right)> ReturnsTuple() => throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user