-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: change the way action filter checks custom attribute in controller #3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.