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

enable nullable in benchmarks #1001

Merged
merged 2 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Polly.Benchmarks/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public MemoryCacheProvider(IMemoryCache memoryCache)
_cache = memoryCache;
}

public (bool, object) TryGet(string key)
public (bool, object?) TryGet(string key)
{
bool cacheHit = _cache.TryGetValue(key, out var value);
return (cacheHit, value);
Expand Down Expand Up @@ -96,7 +96,7 @@ public void Put(string key, object value, Ttl ttl)
_cache.Set(key, value, options);
}

public Task<(bool, object)> TryGetAsync(string key, CancellationToken cancellationToken, bool continueOnCapturedContext)
public Task<(bool, object?)> TryGetAsync(string key, CancellationToken cancellationToken, bool continueOnCapturedContext)
{
return Task.FromResult(TryGet(key));
}
Expand Down
1 change: 1 addition & 0 deletions src/Polly.Benchmarks/Polly.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<LangVersion>latest</LangVersion>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.3" />
Expand Down
22 changes: 12 additions & 10 deletions src/Polly.Benchmarks/Workloads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ internal static async Task ActionInfiniteAsync(CancellationToken cancellationTok
}
}

internal static T Func<T>() => default;
internal static T Func<T>()
where T : struct
=> default;

internal static Task<T> FuncAsync<T>() => Task.FromResult<T>(default);
internal static Task<T> FuncAsync<T>()
where T : struct
=> Task.FromResult<T>(default);

internal static Task<T> FuncAsync<T>(CancellationToken cancellationToken) => Task.FromResult<T>(default);
internal static Task<T> FuncAsync<T>(CancellationToken cancellationToken)
where T : struct
=> Task.FromResult<T>(default);

internal static TResult FuncThrows<TResult, TException>()
where TException : Exception, new()
{
throw new TException();
}
=> throw new TException();

internal static Task<TResult> FuncThrowsAsync<TResult, TException>()
where TException : Exception, new()
{
throw new TException();
}
}
=> throw new TException();
}