ASP.NET Core 3 Support
See original GitHub issueASP.NET Core 3 preview 1 has several breaking changes that prevent FluentValidation from compiling:
ValidatorCache
has moved namespaces- The
RequireAttributeAdapter
class is no longer public
The namespace move for Edit: Looks like we can still use the same package for both as going forward the version of aspnetcore that will be used is tied to the ValidatorCache
means we can’t target 2.x and 3.x with the same build. We’ll either need to drop 2.x support or move to separate packages for supporting 2.x and 3.x.TargetFramework
, meaning that we can multi-target with conditional compilation.
The second issue should be resolved for preview 2 - RequireAttributeAdapter
has already been made public again in the repository (see https://github.com/aspnet/AspNetCore/pull/4493). Workaround for now is to check for AttributeAdapterBase<RequiredAttribute>
.
Will re-evaluate with preview 2.
To-do:
- Add multi-targetting and conditional compilation to handle the
ValidatorCache
namespace change - For Preview 1: Replace
RequiredAttributeAdapter
check withAttributeAdapterBase<RequiredAttribute>
- For preview 2: Put the
RequiredAttributeAdapter
check back again once it’s public - Update the aspnetcore test project to add a new target for
netcoreapp3
with appropriateFrameworkReference
- Investigate test failures Edit: This was a breaking change. The test project needs to explicitly import the Razor SDK so that views are compiled at build time. Relying on runtime view compilation no longer seems to work in test projects without the razor sdk.
- preview 4: Remove uses of
IHostingEnvironment
- preview 4: Investigate razor build failures yet again (edit: Razor sdk project now needs
<AddRazorSupportForMvc>True</AddRazorSupportForMvc>
. Web sdk projects don’t need this) - preview 4: Investigate routing issues in test project. Edit: Endpoint routing is incompatible with app.UseMvc(). Disabled endpoint routing for backwards compat with tests on other frameworks.
- For preview 5, investigate if
<DepsFileGenerationMode>old</DepsFileGenerationMode>
can be removed from the integration test project
Update 10 May: I’ve pushed FluentValidation.AspNetCore 8.5.0-preview1 to nuget. This supports ASP.NET Core 3 preview 5.
TODO for asp.net core 3 preview 7:
- Switch to System.Text.Json for serialization in integration tests.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:24 (13 by maintainers)
Top GitHub Comments
I’ve pushed FluentValidation.AspNetCore 8.5.0-preview1 to nuget. This supports ASP.NET Core 3 preview 5.
No breaking changes between asp.net core 3 preview4 and preview5 that affect FluentValidation. As this is starting to seem a bit more stable I’ll aim to push out a preview build at some point later this week.