Skip to content

Move unified validation APIs to separate package #62071

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 22, 2025

This PR moves the validation APIs from the Http.Abstractions package to a new Microsoft.Extensions.Validation package to support using the unified resolver APIs in more scenarios.

The changes include:

  • Created new directory structure:

    • src/Validation/src for the core library
    • src/Validation/test/Microsoft.Extensions.Validation.Tests for tests
    • src/Validation/gen for the source generator
    • src/Validation/test/Microsoft.Extensions.Validation.ValidationsGenerator.Tests for generator tests
  • Moved validation source files and updated namespaces:

    • Changed from Microsoft.AspNetCore.Http.Validation to Microsoft.Extensions.Validation
    • Maintained the same API contracts and functionality
  • Added type forwarders to maintain backward compatibility:

    • Added forwarding for all validation types in Http.Abstractions
    • Added forwarding for the validations generator to the new implementation
  • Created appropriately structured project files with dependencies

  • Updated project references and configuration

This change supports better modularity by decoupling validation logic from the HTTP abstractions, allowing it to be used more broadly in other scenarios while maintaining backward compatibility.

Fixes #62070.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Move unified validation APIs to separate package Move unified validation APIs to separate package May 22, 2025
@Copilot Copilot AI requested a review from captainsafia May 22, 2025 16:22
Copilot finished work on behalf of captainsafia May 22, 2025 16:22
@captainsafia
Copy link
Member

@copilot Remove the type-forwards and delete the old versions of the code that you moved.

Copy link
Contributor Author

Copilot AI commented May 22, 2025

@copilot Remove the type-forwards and delete the old versions of the code that you moved.

I've removed all type forwards and deleted the original validation code files as requested in commit 93c627c. This included:

  1. Removing ForwardingValidationDirectives.cs from Http.Abstractions
  2. Removing all validation code files from Http.Abstractions/src/Validation/
  3. Removing ValidationsGeneratorForwarding.cs from Http.Extensions
  4. Removing all validation generator code from Http.Extensions/gen/Microsoft.AspNetCore.Http.ValidationsGenerator
  5. Updating the PublicAPI.Unshipped.txt file to remove validation API entries

Projects that previously referenced these validation types will now need to reference the new Microsoft.Extensions.Validation package directly.

Copilot finished work on behalf of captainsafia May 22, 2025 16:48
@captainsafia
Copy link
Member

@copilot Can you fix these build errors?

index a3842c5c9d..0acec8474d 100644
--- a/eng/ShippingAssemblies.props
+++ b/eng/ShippingAssemblies.props
@@ -33,8 +33,8 @@
     <AspNetCoreShippingAssembly Include="Microsoft.Extensions.Identity.Stores" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Connections.Abstractions" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Server.HttpSys" />
-    <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Server.IIS" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Server.IISIntegration" />
+    <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Server.IIS" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Server.Kestrel.Core" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Server.Kestrel" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes" />
@@ -77,8 +77,8 @@
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc.Formatters.Json" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc.Localization" />
-    <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc.Razor" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc.RazorPages" />
+    <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc.Razor" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc.TagHelpers" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc.ViewFeatures" />
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.Mvc" />
@@ -166,4 +166,3 @@
     <AspNetCoreShippingAssembly Include="Microsoft.AspNetCore.OpenApi" />
   </ItemGroup>
 </Project>
-
##[error]eng\TrimmableProjects.props(,): error : Generated code is not up to date in eng/TrimmableProjects.props. You might need to regenerate the reference assemblies or project list (see docs/ReferenceResolution.md)
error : Generated code is not up to date in eng/TrimmableProjects.props. You might need to regenerate the reference assemblies or project list (see docs/ReferenceResolution.md) [D:\a\_work\1\s\eng\TrimmableProjects.props]
diff --git a/eng/TrimmableProjects.props b/eng/TrimmableProjects.props
index 1ffaf18a83..fbbe6f0bc4 100644
--- a/eng/TrimmableProjects.props
+++ b/eng/TrimmableProjects.props
@@ -37,8 +37,8 @@
     <TrimmableProject Include="Microsoft.Extensions.Identity.Stores" />
     <TrimmableProject Include="Microsoft.AspNetCore.Connections.Abstractions" />
     <TrimmableProject Include="Microsoft.AspNetCore.Server.HttpSys" />
-    <TrimmableProject Include="Microsoft.AspNetCore.Server.IIS" />
     <TrimmableProject Include="Microsoft.AspNetCore.Server.IISIntegration" />
+    <TrimmableProject Include="Microsoft.AspNetCore.Server.IIS" />
     <TrimmableProject Include="Microsoft.AspNetCore.Server.Kestrel.Core" />
     <TrimmableProject Include="Microsoft.AspNetCore.Server.Kestrel" />
     <TrimmableProject Include="Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes" />
@@ -104,11 +104,11 @@
     <TrimmableProject Include="Microsoft.AspNetCore.Components.Forms" />
     <TrimmableProject Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" />
     <TrimmableProject Include="Microsoft.AspNetCore.Components.QuickGrid" />
-    <TrimmableProject Include="Microsoft.AspNetCore.Components.Web" />
     <TrimmableProject Include="Microsoft.Authentication.WebAssembly.Msal" />
     <TrimmableProject Include="Microsoft.JSInterop.WebAssembly" />
     <TrimmableProject Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" />
     <TrimmableProject Include="Microsoft.AspNetCore.Components.WebAssembly" />
+    <TrimmableProject Include="Microsoft.AspNetCore.Components.Web" />
     <TrimmableProject Include="Microsoft.Extensions.FileProviders.Embedded" />
     <TrimmableProject Include="Microsoft.Extensions.Localization.Abstractions" />
     <TrimmableProject Include="Microsoft.Extensions.ObjectPool" />
Checking for changes to API baseline files main
Found changes in 0 API baseline files

Summary:

   4 error(s)

error : Generated code is not up to date in eng/ProjectReferences.props. You might need to regenerate the reference assemblies or project list (see docs/ReferenceResolution.md) [D:\a\_work\1\s\eng\ProjectReferences.props]
error : Generated code is not up to date in eng/SharedFramework.Local.props. You might need to regenerate the reference assemblies or project list (see docs/ReferenceResolution.md) [D:\a\_work\1\s\eng\SharedFramework.Local.props]
error : Generated code is not up to date in eng/ShippingAssemblies.props. You might need to regenerate the reference assemblies or project list (see docs/ReferenceResolution.md) [D:\a\_work\1\s\eng\ShippingAssemblies.props]
error : Generated code is not up to date in eng/TrimmableProjects.props. You might need to regenerate the reference assemblies or project list (see docs/ReferenceResolution.md) [D:\a\_work\1\s\eng\TrimmableProjects.props]

Copy link
Contributor Author

Copilot AI commented May 27, 2025

@copilot Can you fix these build errors?

...

Fixed the build errors by running eng/scripts/GenerateProjectList.ps1 to regenerate the project list files. The script updated the generated .props files to include the new Microsoft.Extensions.Validation project. The restore operation now completes successfully. Commit: 2a11bc1

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of captainsafia May 27, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move unified validation APIs to separate package
2 participants