-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Issue with implicit conversion of ActionResult<T> #7981
Comments
This is a C# language restriction. From the C# 6 spec:
And
[emphasis added] |
Oh, I see. What's really disturbing is that such a conversion works when using the generic method when T is the interface type:
|
The type being returned, not var returnedValue = new List<string>();
ActionResult<IEnumerable<string>> r = returnedValue; Unfortunately, there's not much we could do here since it's a language restriction. For var returnedValue = new Enumerable.Empty<string>();
var r = new ActionResult<IEnumerable<string>>(returnedValue); |
Pardon me for reopening a closed issue, but wouldn't the suggested workaround to use "ToList" cause an overhead? |
@bragma as a general guidance, I'd recommend profiling your application if you think a particular piece of code has a performance overhead. It's difficult to make a blanket statement that says doing |
I'm encountering a bug with ASPNet Core 2.1 whether it is with .Net Framework or .Net Core.
When using the implicit conversion of ActionResult, this works :
This works :
This does not compile (but according to me, it should) :
However, this compile :
It seems that the implicit conversion does not work with interfaces.
Not sure if this bug belongs to this repo, or another ?
The text was updated successfully, but these errors were encountered: