Skip to content

Commit c1a742b

Browse files
authored
Made the obsolete methods return a valid type - just in case. (#135)
* 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.
1 parent fb7217f commit c1a742b

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

src/FuncSharp/Collections/IEnumerableExtensions_Emptiness.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static Option<INonEmptyEnumerable<T>> AsNonEmpty<T>(this IEnumerable<T> s
2525
[Obsolete("This is already a NonEmptyEnumerable.", error: true)]
2626
public static Option<INonEmptyEnumerable<T>> AsNonEmpty<T>(this INonEmptyEnumerable<T> source)
2727
{
28-
throw new NotImplementedException();
28+
return Option.Valued(source);
2929
}
3030

3131
public static bool NonEmpty<T>(this IEnumerable<T> e)

src/FuncSharp/Collections/IEnumerableExtensions_Generic.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,20 @@ public static IReadOnlyList<T> AsReadOnlyList<T>(this List<T> source)
4545
return source;
4646
}
4747

48+
/// <summary>
49+
/// Returns the list in case it is a ReadOnlyList or creates a new ReadOnlyList from it.
50+
/// </summary>
51+
[DebuggerStepThrough]
52+
[Pure]
53+
public static IReadOnlyList<T> AsReadOnlyList<T>(this INonEmptyEnumerable<T> source)
54+
{
55+
return source;
56+
}
57+
4858
[Obsolete("This already is of type ReadOnlyList.", error: true)]
4959
public static IReadOnlyList<T> AsReadOnlyList<T>(this IReadOnlyList<T> source)
5060
{
51-
throw new NotImplementedException();
61+
return source;
5262
}
5363

5464
/// <summary>

src/FuncSharp/Collections/INonEmptyEnumerable.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,4 @@ public interface INonEmptyEnumerable<out T> : IReadOnlyList<T>
2525

2626
[Pure]
2727
INonEmptyEnumerable<TResult> SelectMany<TResult>(Func<T, INonEmptyEnumerable<TResult>> selector);
28-
29-
[Pure]
30-
IReadOnlyList<T> AsReadOnly();
3128
}

src/FuncSharp/Collections/NonEmptyEnumerable.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,6 @@ public INonEmptyEnumerable<TResult> SelectMany<TResult>(Func<T, INonEmptyEnumera
128128
return new NonEmptyEnumerable<TResult>(headResult.Head, headResult.Tail.Concat(Tail.SelectMany(selector)).ToArray());
129129
}
130130

131-
/// <summary>
132-
/// Returns the NonEmptyEnumerable typed as IReadOnlyList.
133-
/// </summary>
134-
[Pure]
135-
public IReadOnlyList<T> AsReadOnly()
136-
{
137-
return this;
138-
}
139-
140131
#region static Create methods
141132

142133
public static INonEmptyEnumerable<T> Create(T head, IEnumerable<T> tail)

src/FuncSharp/FuncSharp.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<PropertyGroup>
33
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
44
<NoWarn>CS1591</NoWarn>
5-
<Version>7.0.0</Version>
6-
<AssemblyVersion>7.0.0</AssemblyVersion>
7-
<FileVersion>7.0.0</FileVersion>
5+
<Version>7.0.1</Version>
6+
<AssemblyVersion>7.0.1</AssemblyVersion>
7+
<FileVersion>7.0.1</FileVersion>
88
<PackageId>FuncSharp</PackageId>
99
<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>
1010
<Authors>Mews, Honza Široký</Authors>
@@ -13,7 +13,7 @@
1313
<PackageProjectUrl>https://github.com/MewsSystems/FuncSharp</PackageProjectUrl>
1414
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1515
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
16-
<PackageReleaseNotes>Various UX improvements to extensions of all kinds.</PackageReleaseNotes>
16+
<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>
1717
<RepositoryType>git</RepositoryType>
1818
<RepositoryUrl>https://github.com/MewsSystems/FuncSharp</RepositoryUrl>
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

src/FuncSharp/Strings/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static Option<NonEmptyString> AsNonEmpty(this string s)
1818
[Obsolete("This is already a nonempty string", error: true)]
1919
public static Option<NonEmptyString> AsNonEmpty(this NonEmptyString s)
2020
{
21-
throw new NotImplementedException();
21+
return Option.Valued(s);
2222
}
2323

2424
[Pure]

0 commit comments

Comments
 (0)