Set interceptors property for validations source generator#48891
Set interceptors property for validations source generator#48891captainsafia merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the validation source generator configuration by switching the interceptors property name and adding tests to validate the generator activation based on the target framework.
- Renames the interceptors property from InterceptorsPreviewNamespaces to InterceptorsNamespaces.
- Introduces a new test verifying validations generator support for .NET 10 and above.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/Microsoft.NET.Build.Tests/GivenThatWeWantToUseAnalyzers.cs | Adds tests for validations generator and adjusts interceptors property name. |
| src/WebSdk/ProjectSystem/Targets/Microsoft.NET.Sdk.Web.ProjectSystem.targets | Updates property names and adds configuration for the validations generator. |
Comments suppressed due to low confidence (1)
test/Microsoft.NET.Build.Tests/GivenThatWeWantToUseAnalyzers.cs:88
- There is a naming inconsistency between the validations generator DLL ('Microsoft.AspNetCore.Http.ValidationsGenerator.dll') used in VerifyValidationsGeneratorIsUsed and the expected interceptor namespace ('Microsoft.AspNetCore.Http.Validation.Generated'). Consider aligning these names for clarity.
VerifyInterceptorsFeatureProperties(asset, expectEnabled, "Microsoft.AspNetCore.Http.Validation.Generated");
src/WebSdk/ProjectSystem/Targets/Microsoft.NET.Sdk.Web.ProjectSystem.targets
Outdated
Show resolved
Hide resolved
| <InterceptorsPreviewNamespaces Condition="'$(EnableRequestDelegateGenerator)' == 'true'">$(InterceptorsPreviewNamespaces);Microsoft.AspNetCore.Http.Generated</InterceptorsPreviewNamespaces> | ||
| <!-- Set the namespaces emitted by the ConfigurationBindingGenerator for interception when applicable. --> | ||
| <InterceptorsPreviewNamespaces Condition="'$(EnableConfigurationBindingGenerator)' == 'true'">$(InterceptorsPreviewNamespaces);Microsoft.Extensions.Configuration.Binder.SourceGeneration</InterceptorsPreviewNamespaces> | ||
| <!-- Set the namespaces emitted by the ValidationsGenerator for interception when applicable (.NET 10 and above). --> |
There was a problem hiding this comment.
Maybe better to use VersionGreaterThanOrEquals instead?
https://learn.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2022#msbuild-version-comparison-functions
There was a problem hiding this comment.
I could've sworn we ran into issues with the intrinsic functions that motivated us to use the default comparers but I can't track down the issue.
Actually, I tracked it down. The issue was with the IsTargetFrameworkCompatible function not the version number ones.
Closes dotnet/aspnetcore#61177.