Skip to content

Commit

Permalink
Fixed some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelGerr committed Nov 11, 2023
1 parent 565d947 commit fd838b2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,18 @@ private static void DemoForNonValidatableEnum(ILogger logger)

var returnValue = productType.Switch(ProductType.Groceries, static () => "Switch with Func<T>: Groceries",
ProductType.Housewares, static () => "Switch with Func<T>: Housewares");
logger.Information(returnValue);
logger.Information("{ReturnValue}", returnValue);

returnValue = productType.Switch(logger,
ProductType.Groceries, static _ => "Switch with Func<T>: Groceries",
ProductType.Housewares, static _ => "Switch with Func<T>: Housewares");

logger.Information(returnValue);
logger.Information("{ReturnValue}", returnValue);

returnValue = productType.Map(ProductType.Groceries, "Map: Groceries",
ProductType.Housewares, "Map: Housewares");

logger.Information(returnValue);
logger.Information("{ReturnValue}", returnValue);

var parsed = ProductType.TryParse("Groceries", null, out var parsedProductType);
logger.Information("Success: {Success} Parsed: {Parsed}", parsed, parsedProductType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static bool TryReadKey(
return false;
}

var formatter = options.Resolver.GetFormatterWithVerify<TKey>();
var formatter = options.Resolver.GetFormatterWithVerify<TKey?>();
key = formatter.Deserialize(ref reader, options);

return key is not null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Serialize(ref MessagePackWriter writer, T? value, MessagePackSeriali
if (reader.TryReadNil())
return default;

var formatter = options.Resolver.GetFormatterWithVerify<TKey>();
var formatter = options.Resolver.GetFormatterWithVerify<TKey?>();
var key = formatter.Deserialize(ref reader, options);

if (key is null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
using System.Collections.Generic;
using System.Linq;

#nullable enable

namespace Thinktecture.Runtime.Tests.ReadOnlyCollectionExtensions;

public class ToReadOnlyCollection
{
[Fact]
public void Should_throw_if_items_is_null()
{
0.Invoking(_ => ((IReadOnlyCollection<int>)null)!.ToReadOnlyCollection(i => _))
.Should().Throw<ArgumentNullException>();
FluentActions.Invoking(() => ((IReadOnlyCollection<int>)null!).ToReadOnlyCollection(i => i))
.Should().Throw<ArgumentNullException>();
}

[Fact]
public void Should_throw_if_count_is_negative()
{
Array.Empty<int>().Invoking(e => e.ToReadOnlyCollection((Func<int, int>)null))
Array.Empty<int>().Invoking(e => e.ToReadOnlyCollection((Func<int, int>?)null!))
.Should().Throw<ArgumentException>();
}

Expand Down

0 comments on commit fd838b2

Please sign in to comment.