Skip to content

Conversation

@ericstj
Copy link
Member

@ericstj ericstj commented Nov 7, 2025

Fixes #6954, #5629

Microsoft Reviewers: Open in CodeFlow

@ericstj ericstj requested a review from a team as a code owner November 7, 2025 23:48
Copilot AI review requested due to automatic review settings November 7, 2025 23:48
@ericstj ericstj requested review from a team as code owners November 7, 2025 23:48
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Nov 7, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the custom JsonSchemaExporter polyfill implementation that was previously used to provide JSON schema export functionality for pre-.NET 9 targets. The changes indicate a shift to relying on the built-in .NET 9+ JsonSchemaExporter instead of maintaining a custom polyfill.

Key changes:

  • Removes the entire JsonSchemaExporter polyfill implementation from src/Shared/JsonSchemaExporter/
  • Removes JsonSchemaExporter test infrastructure and test data from test/Shared/
  • Removes tests that validated the polyfill against the test battery in Microsoft.Extensions.AI.Abstractions.Tests
  • Updates AI-related projects to use ForceLatestDotnetVersions property to ensure they get .NET 9/10 package versions
  • Simplifies project files by removing conditional package references for non-.NETCoreApp targets
  • Removes the InjectJsonSchemaExporterOnLegacy MSBuild property and injection logic
  • Updates AIJsonSchemaCreateContext to remove conditional compilation that handled polyfill vs native implementation differences
  • Adds workaround for .NET Framework package pruning issue

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/Shared/Shared.Tests.csproj Removes TESTS_JSON_SCHEMA_EXPORTER_POLYFILL compiler constant
test/Shared/JsonSchemaExporter/*.cs Deletes polyfill test infrastructure including TestTypes, TestData, SchemaTestHelpers, and test classes
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Utilities/AIJsonUtilitiesTests.cs Removes tests that validated against JsonSchemaExporter test battery; removes unused imports
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/*.csproj Removes shared test file references for JsonSchemaExporter
src/Shared/JsonSchemaExporter/** Deletes entire polyfill implementation including README, core exporter, reflection helpers, schema model, nullability context, and options
src/Libraries/Microsoft.Extensions.DataIngestion*/*.csproj Adds ForceLatestDotnetVersions property to use .NET 9/10 package versions
src/Libraries/Microsoft.Extensions.AI*/*.csproj Adds ForceLatestDotnetVersions; removes conditional package references; removes trailing whitespace
src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaCreateContext.cs Removes #if NET9_0_OR_GREATER conditionals as polyfill is no longer needed
src/Libraries/Microsoft.Extensions.AI.Abstractions/*.csproj Removes InjectJsonSchemaExporterOnLegacy property; removes conditional package references
eng/MSBuild/LegacySupport.props Removes JsonSchemaExporter injection logic for legacy targets
Directory.Build.targets Adds workaround to disable package pruning for .NET Framework targets
Comments suppressed due to low confidence (1)

src/Libraries/Microsoft.Extensions.AI/Microsoft.Extensions.AI.csproj:55

  • The removal of the condition '$(TargetFrameworkIdentifier)' != '.NETCoreApp' from these package references means they will now be included for all target frameworks including .NET 9+. For .NET 9+, System.Text.Json, System.Diagnostics.DiagnosticSource, and System.Threading.Channels are inbox assemblies. Consider retaining the condition or using Condition=\"'$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0'\" to avoid unnecessary package references for modern .NET versions.
  <ItemGroup>
    <PackageReference Include="System.Diagnostics.DiagnosticSource" />
    <PackageReference Include="System.Text.Json" />
    <PackageReference Include="System.Threading.Channels" />
  </ItemGroup>

@stephentoub
Copy link
Member

stephentoub commented Nov 8, 2025

Presumably this also closes #5629?

@stephentoub
Copy link
Member

I think there are other ifdefs that can be updated now, like

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from infra side. If we want this for 10, it will need to be backported against the internal internal/release/10.0 branch

Copy link
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice; thanks, @ericstj!

I think there are other ifdefs that can be updated now...

OK with me if we send that in a follow-up PR that we don't backport to net10, but I defer to you, @ericstj, if you want to fold that in or not.

@ericstj
Copy link
Member Author

ericstj commented Nov 8, 2025

I fixed @stephentoub suggestion and audited all instances of NET*_OR_GREATER

@ericstj
Copy link
Member Author

ericstj commented Nov 8, 2025

Looks like I need to remove the trimming suppression as well.

@ericstj ericstj enabled auto-merge (squash) November 8, 2025 02:01
@ericstj ericstj merged commit e5f8d83 into dotnet:main Nov 8, 2025
6 checks passed
joperezr pushed a commit to joperezr/extensions that referenced this pull request Nov 11, 2025
* Make MEAI packages use 10.0 runtime packages

* Add back MEAI.Abstractions JsonSchemaExporter tests

* Address feedback

* Remove unneeded trimming suppression
joperezr pushed a commit to joperezr/extensions that referenced this pull request Nov 11, 2025
The following PRs are included in this backport:

- [MEDI] start producing NuGet packages (dotnet/extensions/dotnet#7016)
- Update version numbers in AI changelogs (dotnet/extensions/dotnet#7008)
- [MEDI] Don't stop document processing on enricher error (dotnet/extensions/dotnet#7005)
- [MEDI] add PackageTags (dotnet/extensions/dotnet#7022)
- Add MarkItDownMcpReader for MCP server support (dotnet/extensions/dotnet#7025)
- Image generation tool (dotnet/extensions/dotnet#6749)
- Make MEAI packages use 10.0 runtime packages (dotnet/extensions/dotnet#7028)

----
#### AI description  (iteration 1)
#### PR Classification
This pull request backports multiple MEAI library updates, including new image generation features, refactoring of data ingestion enrichers, removal of legacy exporter code, and updated OpenTelemetry instrumentation.

#### PR Summary
The changes integrate new image generation tool support into chat clients with corresponding types and integration tests, refactor data ingestion enrichers to use a unified `EnricherOptions` abstraction with batching, and remove outdated JSON schema exporter and nullability helper files while updating OpenTelemetry metrics and project metadata.
- `src/Libraries/Microsoft.Extensions.AI`: Added new types (`HostedImageGenerationTool.cs`, `ImageGenerationToolCallContent.cs`, `ImageGenerationToolResultContent.cs`) and integration tests to enable hosted image generation across AI providers.
- `src/Libraries/Microsoft.Extensions.DataIngestion`: Refactored enrichers (Sentiment, Keyword, Classification, Summary) to use the new `EnricherOptions` and batching via the `Batching.cs` utility, with updated tests.
- Removed legacy schema exporter files (e.g. files under `src/Shared/JsonSchemaExporter/` and `NullabilityInfoContext/`) to clean up unused functionality.
- Updated OpenTelemetry instrumentation in OpenAI, Azure AI, Embedding, and SpeechToText clients to align with the latest semantic conventions.
- Revised project and package configuration files with updated metadata, preview stage tags, and code quality settings.
<!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update M.E.AI* to depend on net10.0 nuget packages

4 participants