Fix excplicit cast of HashSet<string> to IReadOnlyCollection<string> to

allow tests to succeed in machines with only 4.5.1.
This commit is contained in:
Pranav K 2015-04-28 17:41:19 -07:00
parent 89ebce0289
commit 8188f593ad
1 changed files with 3 additions and 1 deletions

View File

@ -852,7 +852,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
return (IReadOnlyCollection<string>)currentValues;
// HashSet<> implements IReadOnlyCollection<> as of 4.6, but does not for 4.5.1. If the runtime cast succeeds,
// avoid creating a new collection.
return (currentValues as IReadOnlyCollection<string>) ?? currentValues.ToArray();
}
internal static string EvalString(ViewContext viewContext, string key, string format)