refactor: change the way action filter checks custom attribute in controller#3
refactor: change the way action filter checks custom attribute in controller#3mvdgun merged 4 commits intoSharpGrip:masterfrom alshuriga:refactor/attribute-check
Conversation
mvdgun
left a comment
There was a problem hiding this comment.
@alshuriga thanks for your contribution! I am seeing some binary files in your PR, perhaps some artifacts from your IDE? Could you remove those? I've marked those files for you.
.vs/FluentValidation.AutoValidation/FileContentIndex/0b76e120-00f5-4fdb-8a89-982690eeb349.vsidx
Outdated
Show resolved
Hide resolved
.vs/FluentValidation.AutoValidation/v17/TestStore/0/000.testlog
Outdated
Show resolved
Hide resolved
.vs/FluentValidation.AutoValidation/v17/TestStore/0/testlog.manifest
Outdated
Show resolved
Hide resolved
|
Looking back at the code I think the annotations on methods will break since it only retrieves annotations on the type. Did you test putting an annotation on a controller method? |
fixed action filter would'nt work in case of using FluentValidationAutoValidation attribute on a controller's action
thank you for noticing that, it works now for both controller and action annotation. |
|
@alshuriga I'm still debating whether this change will have a detrimental impact on performance since it uses reflection. Where possible I would like to avoid using reflection. I'm going to look into the |
Change the way action filter checks custom attribute in controller without using reflection
|
@mvdgun Yes, |
mvdgun
left a comment
There was a problem hiding this comment.
@alshuriga Looks like a great option! I have added some remarks.
FluentValidation.AutoValidation.Mvc/src/Filters/FluentValidationAutoValidationActionFilter.cs
Outdated
Show resolved
Hide resolved
FluentValidation.AutoValidation.Mvc/src/Filters/FluentValidationAutoValidationActionFilter.cs
Outdated
Show resolved
Hide resolved
FluentValidation.AutoValidation.Mvc/src/Filters/FluentValidationAutoValidationActionFilter.cs
Outdated
Show resolved
Hide resolved
added httpContext endpoint null check in action filter, removed empty lines
|
Closes #4 |
|
Merged, thanks for you contribution @alshuriga! |
I've changed the way of mvc action filter checking if controller has FluentValidationAutoValidation attribute.
Tested it in WeatherForecast (dotnet webapi template app) and it seems to work fine.