Skip to content

Commit

Permalink
Drop .NET 8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
BarionLP authored Nov 18, 2024
1 parent 65efc05 commit a54b7ac
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 9 deletions.
2 changes: 1 addition & 1 deletion src/Ametrin.Optional.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<IsAotCompatible>true</IsAotCompatible>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
2 changes: 0 additions & 2 deletions src/Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public static class DictionaryExtensions
public static Option<TValue> TryGetValue<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) where TKey : notnull
=> dictionary.TryGetValue(key, out var result) ? result : default(Option<TValue>);

#if NET9_0_OR_GREATER
public static Option<TValue> TryGetValue<TKey, TValue, TAlternate>(this Dictionary<TKey, TValue>.AlternateLookup<TAlternate> lookup, TAlternate key)
where TKey : notnull
where TAlternate : notnull, allows ref struct
Expand All @@ -17,5 +16,4 @@ public static Option<TValue> TryGetValue<TKey, TValue, TAlternate>(this FrozenDi
where TKey : notnull
where TAlternate : notnull, allows ref struct
=> lookup.TryGetValue(key, out var result) ? result : default(Option<TValue>);
#endif
}
6 changes: 0 additions & 6 deletions src/Operations/Or.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@ namespace Ametrin.Optional;

partial struct Option<TValue>
{
#if NET9_0_OR_GREATER
[OverloadResolutionPriority(1)] // to allow 'Or(default)' which would normally be ambigious
#endif
public TValue Or(TValue other) => _hasValue ? _value : other;
public TValue Or(Func<TValue> factory) => _hasValue ? _value! : factory();
public TValue OrThrow() => _hasValue ? _value : throw new NullReferenceException("Option is Error state");
}

partial struct Result<TValue>
{
#if NET9_0_OR_GREATER
[OverloadResolutionPriority(1)]
#endif
public TValue Or(TValue other) => _hasValue ? _value : other;
public TValue Or(Func<Exception, TValue> factory) => _hasValue ? _value : factory(_error);
public TValue OrThrow() => _hasValue ? _value : throw new NullReferenceException("Result is Error state", _error);
}

partial struct Result<TValue, TError>
{
#if NET9_0_OR_GREATER
[OverloadResolutionPriority(1)]
#endif
public TValue Or(TValue other) => _hasValue ? _value! : other;
public TValue Or(Func<TError, TValue> factory) => _hasValue ? _value! : factory(_error);
public TValue OrThrow() => _hasValue ? _value! : throw new NullReferenceException($"Result is Error state: {_error}");
Expand Down

0 comments on commit a54b7ac

Please sign in to comment.