aspnet / Mvc

[Archived] ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
5.62k stars 2.14k forks source link

Consider making RequiredAttributeAdapter public #8744

Closed pranavkm closed 5 years ago

pranavkm commented 5 years ago

FluentValidation uses the type: https://github.com/JeremySkinner/FluentValidation/blob/master/src/FluentValidation.AspNetCore/FluentValidationClientModelValidatorProvider.cs#L113. An alternative might be to consider changing FluentValidation to use IValidationAttributeAdapterProvider

pranavkm commented 5 years ago

cc @dougbu. This may tie in to https://github.com/aspnet/Mvc/issues/8730

cc @JeremySkinner

JeremySkinner commented 5 years ago

I need some way to explicitly identify required rules (for the purpose of being able to remove implicitly-added required validators that double up with what FluentValidation is doing) which is why I'm using RequiredAttributeAdapter here.

If this becomes internal, would I be able to use IValidationAttributeAdapterProvider to achieve the same thing? If needbe I can still check the type by looking for AttributeAdapterBase<RequiredAttribute> (or even reflection), although it would be nice not to have to make changes like this unless really needed. What's the reason for wanting to make this internal?

pranavkm commented 5 years ago

What's the reason for wanting to make this internal?

We made all of our pubternal types internal in 3.0. See https://github.com/aspnet/Mvc/issues/8689. I tried building your repo and there's a few usings that need to be cleaned up, but outside of RequiredAttributeAdapter everything just worked. Making the type public sounds like the least problematic thing to do here.