ivaylokenov / AspNet.Mvc.TypedRouting

A collection of extension methods providing strongly typed routing and link generation for ASP.NET Core MVC projects.
https://mytestedasp.net/
MIT License
485 stars 36 forks source link

Unable to extract constants from static field accesses #36

Open andrewlock opened 5 years ago

andrewlock commented 5 years ago

I've been using this library without issue for some time, including in .NET Core 2.x apps, so thanks for that 🙂

However, I've just come across an issue with standard constants exposed as static fields like Guid.Empty and string.Empty. Basically, they are ignored during URL generation in ExpressionRouteHelper, in the MemberAccess branch:

https://github.com/ivaylokenov/AspNet.Mvc.TypedRouting/blob/2994a608364e4a110ec4e8d8eb4a26e5f2182564/src/AspNet.Mvc.TypedRouting/LinkGeneration/ExpressionRouteHelper.cs#L234-L246

As they're not a ConstantExpression, that branch returns null, no value is generated for the parameter, and link generation completely fails.

ivaylokenov commented 4 years ago

Hi, thank you for your issue. Since I am overwhelmed with my other project https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc, I did not have a lot of time to support this one. Will try to publish a new package during the weekend. Thank you for your patience!

Piedone commented 4 years ago

Would you be able to publish an updated package @ivaylokenov? Yours is a really great project and the best library for this purpose but not really usable with ASP.NET Core MVC 3.1.