Skip to content

Commit e5f8d83

Browse files
authored
Make MEAI packages use 10.0 runtime packages (#7028)
* Make MEAI packages use 10.0 runtime packages * Add back MEAI.Abstractions JsonSchemaExporter tests * Address feedback * Remove unneeded trimming suppression
1 parent 8505901 commit e5f8d83

File tree

31 files changed

+37
-2950
lines changed

31 files changed

+37
-2950
lines changed

Directory.Build.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
<Import Project="$(MSBuildThisFileDirectory)\eng\MSBuild\Generators.targets" />
99
<Import Project="$(MSBuildThisFileDirectory)\eng\MSBuild\ProjectStaging.targets" />
1010

11+
<PropertyGroup>
12+
<!-- Workaround https://github.com/dotnet/sdk/issues/51265 - can be removed when updating to .NET 10.0.100 (GA) SDK -->
13+
<RestoreEnablePackagePruning Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">false</RestoreEnablePackagePruning>
14+
</PropertyGroup>
15+
1116
<!-- Warning stuff -->
1217
<PropertyGroup>
1318
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NETSDK1138;MSB3270</MSBuildWarningsAsMessages>

eng/MSBuild/LegacySupport.props

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ItemGroup Condition="'$(InjectCompilerFeatureRequiredOnLegacy)' == 'true' AND ('$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netcoreapp3.1')">
33
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\LegacySupport\CompilerFeatureRequiredAttribute\*.cs" LinkBase="LegacySupport\CompilerFeatureRequiredAttribute" />
44
</ItemGroup>
5-
5+
66
<ItemGroup Condition="'$(InjectRequiredMemberOnLegacy)' == 'true' AND ('$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netcoreapp3.1')">
77
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\LegacySupport\RequiredMemberAttribute\*.cs" LinkBase="LegacySupport\RequiredMemberAttribute" />
88
</ItemGroup>
@@ -47,10 +47,6 @@
4747
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\LegacySupport\StringSyntaxAttribute\*.cs" LinkBase="LegacySupport\StringSyntaxAttribute" />
4848
</ItemGroup>
4949

50-
<ItemGroup Condition="'$(InjectJsonSchemaExporterOnLegacy)' == 'true' AND ('$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net8.0')">
51-
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\Shared\JsonSchemaExporter\**\*.cs" LinkBase="Shared\EmptyCollections" />
52-
</ItemGroup>
53-
5450
<ItemGroup Condition="'$(InjectGetOrAddOnLegacy)' == 'true' AND ('$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0')">
5551
<Compile Include="$(MSBuildThisFileDirectory)\..\..\src\LegacySupport\GetOrAdd\*.cs" LinkBase="LegacySupport\GetOrAdd" />
5652
</ItemGroup>

src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<RootNamespace>Microsoft.Extensions.AI</RootNamespace>
55
<Description>Abstractions representing generative AI components.</Description>
66
<Workstream>AI</Workstream>
7+
<ForceLatestDotnetVersions>true</ForceLatestDotnetVersions>
78
</PropertyGroup>
89

910
<PropertyGroup>
@@ -21,21 +22,20 @@
2122

2223
<PropertyGroup>
2324
<InjectExperimentalAttributeOnLegacy>true</InjectExperimentalAttributeOnLegacy>
24-
<InjectJsonSchemaExporterOnLegacy>true</InjectJsonSchemaExporterOnLegacy>
2525
<InjectRequiredMemberOnLegacy>true</InjectRequiredMemberOnLegacy>
2626
<InjectSharedEmptyCollections>true</InjectSharedEmptyCollections>
2727
<InjectStringHashOnLegacy>true</InjectStringHashOnLegacy>
2828
<InjectStringSyntaxAttributeOnLegacy>true</InjectStringSyntaxAttributeOnLegacy>
2929
<InjectSystemIndexOnLegacy>true</InjectSystemIndexOnLegacy>
3030
</PropertyGroup>
3131

32-
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
32+
<ItemGroup>
3333
<PackageReference Include="System.Text.Json" />
3434
</ItemGroup>
3535

3636
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
3737
<Reference Include="System.Net.Http" />
3838
<Reference Include="System.ComponentModel.DataAnnotations" />
3939
</ItemGroup>
40-
40+
4141
</Project>

src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonSchemaCreateContext.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Microsoft.Extensions.AI;
1515
/// Defines the context in which a JSON schema within a type graph is being generated.
1616
/// </summary>
1717
/// <remarks>
18-
/// This struct is being passed to the user-provided <see cref="AIJsonSchemaCreateOptions.TransformSchemaNode"/>
18+
/// This struct is being passed to the user-provided <see cref="AIJsonSchemaCreateOptions.TransformSchemaNode"/>
1919
/// callback by the <see cref="AIJsonUtilities.CreateJsonSchema"/> method and cannot be instantiated directly.
2020
/// </remarks>
2121
public readonly struct AIJsonSchemaCreateContext
@@ -51,32 +51,20 @@ internal AIJsonSchemaCreateContext(JsonSchemaExporterContext exporterContext)
5151
/// Gets the declaring type of the property or parameter being processed.
5252
/// </summary>
5353
public Type? DeclaringType =>
54-
#if NET9_0_OR_GREATER
5554
_exporterContext.PropertyInfo?.DeclaringType;
56-
#else
57-
_exporterContext.DeclaringType;
58-
#endif
5955

6056
/// <summary>
6157
/// Gets the <see cref="ICustomAttributeProvider"/> corresponding to the property or field being processed.
6258
/// </summary>
6359
public ICustomAttributeProvider? PropertyAttributeProvider =>
64-
#if NET9_0_OR_GREATER
6560
_exporterContext.PropertyInfo?.AttributeProvider;
66-
#else
67-
_exporterContext.PropertyAttributeProvider;
68-
#endif
6961

7062
/// <summary>
7163
/// Gets the <see cref="System.Reflection.ICustomAttributeProvider"/> of the
7264
/// constructor parameter associated with the accompanying <see cref="PropertyInfo"/>.
7365
/// </summary>
7466
public ICustomAttributeProvider? ParameterAttributeProvider =>
75-
#if NET9_0_OR_GREATER
7667
_exporterContext.PropertyInfo?.AssociatedParameter?.AttributeProvider;
77-
#else
78-
_exporterContext.ParameterInfo;
79-
#endif
8068

8169
/// <summary>
8270
/// Retrieves a custom attribute of a specified type that is applied to the specified schema node context.

src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Schema.Create.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ internal static void ValidateSchemaDocument(JsonElement document, [CallerArgumen
199199
}
200200
}
201201

202-
#if !NET9_0_OR_GREATER
203-
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access",
204-
Justification = "Pre STJ-9 schema extraction can fail with a runtime exception if certain reflection metadata have been trimmed. " +
205-
"The exception message will guide users to turn off 'IlcTrimMetadata' which resolves all issues.")]
206-
#endif
207202
private static JsonNode CreateJsonSchemaCore(
208203
Type? type,
209204
ParameterInfo? parameter,

src/Libraries/Microsoft.Extensions.AI.AzureAIInference/Microsoft.Extensions.AI.AzureAIInference.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<RootNamespace>Microsoft.Extensions.AI</RootNamespace>
55
<Description>Implementation of generative AI abstractions for Azure.AI.Inference.</Description>
66
<Workstream>AI</Workstream>
7+
<ForceLatestDotnetVersions>true</ForceLatestDotnetVersions>
78
</PropertyGroup>
89

910
<PropertyGroup>
@@ -29,9 +30,6 @@
2930

3031
<ItemGroup>
3132
<PackageReference Include="Azure.AI.Inference" />
32-
</ItemGroup>
33-
34-
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
3533
<PackageReference Include="System.Memory.Data" />
3634
<PackageReference Include="System.Text.Json" />
3735
</ItemGroup>

src/Libraries/Microsoft.Extensions.AI.OpenAI/Microsoft.Extensions.AI.OpenAI.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<RootNamespace>Microsoft.Extensions.AI</RootNamespace>
55
<Description>Implementation of generative AI abstractions for OpenAI-compatible endpoints.</Description>
66
<Workstream>AI</Workstream>
7+
<ForceLatestDotnetVersions>true</ForceLatestDotnetVersions>
78
</PropertyGroup>
89

910
<PropertyGroup>
@@ -31,9 +32,6 @@
3132

3233
<ItemGroup>
3334
<PackageReference Include="OpenAI" />
34-
</ItemGroup>
35-
36-
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
3735
<PackageReference Include="System.Memory.Data" />
3836
<PackageReference Include="System.Text.Json" />
3937
</ItemGroup>

src/Libraries/Microsoft.Extensions.AI/ChatCompletion/ChatResponse{T}.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ public class ChatResponse<T> : ChatResponse
2222
{
2323
private static readonly JsonReaderOptions _allowMultipleValuesJsonReaderOptions = new()
2424
{
25-
#if NET9_0_OR_GREATER
2625
AllowMultipleValues = true
27-
#endif
2826
};
2927
private readonly JsonSerializerOptions _serializerOptions;
3028

src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,15 @@ public OpenTelemetryChatClient(IChatClient innerClient, ILogger? logger = null,
6969
_tokenUsageHistogram = _meter.CreateHistogram<int>(
7070
OpenTelemetryConsts.GenAI.Client.TokenUsage.Name,
7171
OpenTelemetryConsts.TokensUnit,
72-
OpenTelemetryConsts.GenAI.Client.TokenUsage.Description
73-
#if NET9_0_OR_GREATER
74-
, advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.TokenUsage.ExplicitBucketBoundaries }
75-
#endif
72+
OpenTelemetryConsts.GenAI.Client.TokenUsage.Description,
73+
advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.TokenUsage.ExplicitBucketBoundaries }
7674
);
7775

7876
_operationDurationHistogram = _meter.CreateHistogram<double>(
7977
OpenTelemetryConsts.GenAI.Client.OperationDuration.Name,
8078
OpenTelemetryConsts.SecondsUnit,
81-
OpenTelemetryConsts.GenAI.Client.OperationDuration.Description
82-
#if NET9_0_OR_GREATER
83-
, advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.OperationDuration.ExplicitBucketBoundaries }
84-
#endif
79+
OpenTelemetryConsts.GenAI.Client.OperationDuration.Description,
80+
advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.OperationDuration.ExplicitBucketBoundaries }
8581
);
8682

8783
_jsonSerializerOptions = AIJsonUtilities.DefaultOptions;

src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryImageGenerator.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,15 @@ public OpenTelemetryImageGenerator(IImageGenerator innerGenerator, ILogger? logg
6262
_tokenUsageHistogram = _meter.CreateHistogram<int>(
6363
OpenTelemetryConsts.GenAI.Client.TokenUsage.Name,
6464
OpenTelemetryConsts.TokensUnit,
65-
OpenTelemetryConsts.GenAI.Client.TokenUsage.Description
66-
#if NET9_0_OR_GREATER
67-
, advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.TokenUsage.ExplicitBucketBoundaries }
68-
#endif
65+
OpenTelemetryConsts.GenAI.Client.TokenUsage.Description,
66+
advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.TokenUsage.ExplicitBucketBoundaries }
6967
);
7068

7169
_operationDurationHistogram = _meter.CreateHistogram<double>(
7270
OpenTelemetryConsts.GenAI.Client.OperationDuration.Name,
7371
OpenTelemetryConsts.SecondsUnit,
74-
OpenTelemetryConsts.GenAI.Client.OperationDuration.Description
75-
#if NET9_0_OR_GREATER
76-
, advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.OperationDuration.ExplicitBucketBoundaries }
77-
#endif
72+
OpenTelemetryConsts.GenAI.Client.OperationDuration.Description,
73+
advice: new() { HistogramBucketBoundaries = OpenTelemetryConsts.GenAI.Client.OperationDuration.ExplicitBucketBoundaries }
7874
);
7975
}
8076

0 commit comments

Comments
 (0)