You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public Result<Thing, string> GetThing()
{
bool success = false;
var thing = new Thing();
if(!success)
return "";
return thing;
}
Compiles
public Result<IEnumerable<Thing>, string> GetThingsList()
{
bool success = false;
List<Thing> things = new List<Thing>() { new Thing() };
if(!success)
return "";
return things;
}
Compiles
public Result<IEnumerable<Thing>, string> GetThingsIEnumerable()
{
bool success = false;
IEnumerable<Thing> things = new List<Thing>() { new Thing() };
if(!success)
return "";
return things;
}
Does not compile - Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'CSharpFunctionalExtensions.Result<System.Collections.Generic.IEnumerable, string>'
It seems as if it does not work correctly for anything that is an Interface ie IEnumerable, IList, ICollection.
Workaround
public Result<IEnumerable<Thing>, string> GetThingsIEnumerable()
{
bool success = false;
IEnumerable<Thing> things = new List<Thing>() { new Thing() };
if(!success)
return "";
return Result.Success<IEnumerable<Thing>, string>(things);
}
The text was updated successfully, but these errors were encountered:
martinbryant
changed the title
Implicit return for Result does not allow IEnumerable<T> - must be concrete type ie List<T>
Implicit return for Result does not allow Interface<T> - must be concrete type ie List<T> not IEnumerable<T>
Oct 28, 2021
Example
Compiles
Compiles
Does not compile - Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'CSharpFunctionalExtensions.Result<System.Collections.Generic.IEnumerable, string>'
It seems as if it does not work correctly for anything that is an Interface ie IEnumerable, IList, ICollection.
Workaround
The text was updated successfully, but these errors were encountered: