Skip to content

Commit

Permalink
Made the obsolete methods return a valid type - just in case. (#135)
Browse files Browse the repository at this point in the history
* Made the obsolete methods return a valid type - just in case.
Also removed AsReadOnly on INonEmptyEnumerable and rather introduced a special overload of AsReadOnlyList.

* Improved release notes.
  • Loading branch information
KaliCZ authored Aug 27, 2023
1 parent fb7217f commit c1a742b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static Option<INonEmptyEnumerable<T>> AsNonEmpty<T>(this IEnumerable<T> s
[Obsolete("This is already a NonEmptyEnumerable.", error: true)]
public static Option<INonEmptyEnumerable<T>> AsNonEmpty<T>(this INonEmptyEnumerable<T> source)
{
throw new NotImplementedException();
return Option.Valued(source);
}

public static bool NonEmpty<T>(this IEnumerable<T> e)
Expand Down
12 changes: 11 additions & 1 deletion src/FuncSharp/Collections/IEnumerableExtensions_Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,20 @@ public static IReadOnlyList<T> AsReadOnlyList<T>(this List<T> source)
return source;
}

/// <summary>
/// Returns the list in case it is a ReadOnlyList or creates a new ReadOnlyList from it.
/// </summary>
[DebuggerStepThrough]
[Pure]
public static IReadOnlyList<T> AsReadOnlyList<T>(this INonEmptyEnumerable<T> source)
{
return source;
}

[Obsolete("This already is of type ReadOnlyList.", error: true)]
public static IReadOnlyList<T> AsReadOnlyList<T>(this IReadOnlyList<T> source)
{
throw new NotImplementedException();
return source;
}

/// <summary>
Expand Down
3 changes: 0 additions & 3 deletions src/FuncSharp/Collections/INonEmptyEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,4 @@ public interface INonEmptyEnumerable<out T> : IReadOnlyList<T>

[Pure]
INonEmptyEnumerable<TResult> SelectMany<TResult>(Func<T, INonEmptyEnumerable<TResult>> selector);

[Pure]
IReadOnlyList<T> AsReadOnly();
}
9 changes: 0 additions & 9 deletions src/FuncSharp/Collections/NonEmptyEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,6 @@ public INonEmptyEnumerable<TResult> SelectMany<TResult>(Func<T, INonEmptyEnumera
return new NonEmptyEnumerable<TResult>(headResult.Head, headResult.Tail.Concat(Tail.SelectMany(selector)).ToArray());
}

/// <summary>
/// Returns the NonEmptyEnumerable typed as IReadOnlyList.
/// </summary>
[Pure]
public IReadOnlyList<T> AsReadOnly()
{
return this;
}

#region static Create methods

public static INonEmptyEnumerable<T> Create(T head, IEnumerable<T> tail)
Expand Down
8 changes: 4 additions & 4 deletions src/FuncSharp/FuncSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>CS1591</NoWarn>
<Version>7.0.0</Version>
<AssemblyVersion>7.0.0</AssemblyVersion>
<FileVersion>7.0.0</FileVersion>
<Version>7.0.1</Version>
<AssemblyVersion>7.0.1</AssemblyVersion>
<FileVersion>7.0.1</FileVersion>
<PackageId>FuncSharp</PackageId>
<Description>A C# library with main purpose to reduce boilerplate code and avoid bugs thanks to stronger typing. Utilizes many concepts from functional programming languages that are also applicable in C#. Originally written by Honza Široký.</Description>
<Authors>Mews, Honza Široký</Authors>
Expand All @@ -13,7 +13,7 @@
<PackageProjectUrl>https://github.com/MewsSystems/FuncSharp</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>Various UX improvements to extensions of all kinds.</PackageReleaseNotes>
<PackageReleaseNotes>IOption interface is gone. Option is a struct, Try is a struct. Various types have been introduced such as NonEmptyString, NonEmptyEnumerable, PositiveInt etc. A lot of extensions reworked.</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/MewsSystems/FuncSharp</RepositoryUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/FuncSharp/Strings/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static Option<NonEmptyString> AsNonEmpty(this string s)
[Obsolete("This is already a nonempty string", error: true)]
public static Option<NonEmptyString> AsNonEmpty(this NonEmptyString s)
{
throw new NotImplementedException();
return Option.Valued(s);
}

[Pure]
Expand Down

0 comments on commit c1a742b

Please sign in to comment.