Skip to content

Commit 5c0f11a

Browse files
Fix for 552
2 parents d1b1316 + aa1c930 commit 5c0f11a

File tree

1,107 files changed

+486215
-19723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,107 files changed

+486215
-19723
lines changed

.config/dotnet-tools.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"snippet-generator"
99
],
1010
"rollForward": false
11+
},
12+
"azure.sdk.tools.testproxy": {
13+
"version": "1.0.0-dev.20250922.2",
14+
"commands": [
15+
"test-proxy"
16+
],
17+
"rollForward": false
1118
}
1219
}
1320
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This workflow validates changes made to the codegen folder by running code generation
2+
# and ensuring the process completes successfully without errors.
3+
name: CodeGen Validation
4+
5+
on:
6+
pull_request:
7+
paths:
8+
- 'codegen/**'
9+
- '.github/workflows/codegen-validation.yml'
10+
- 'scripts/Invoke-CodeGen.ps1'
11+
types: [opened, reopened, synchronize]
12+
workflow_dispatch:
13+
14+
jobs:
15+
validate-codegen:
16+
name: Validate Code Generation
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '22.x'
27+
28+
- name: Setup .NET
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
# Use the version specified in global.json
32+
global-json-file: global.json
33+
34+
- name: Run CodeGen Script
35+
shell: pwsh
36+
run: |
37+
Write-Host "Running code generation validation..."
38+
./scripts/Invoke-CodeGen.ps1
39+
40+
if ($LASTEXITCODE -ne 0) {
41+
Write-Error "Code generation failed with exit code: $LASTEXITCODE"
42+
exit $LASTEXITCODE
43+
}
44+
45+
Write-Host "Code generation completed successfully!"
46+
47+
- name: Check for uncommitted changes
48+
run: |
49+
# Check if there are any changes to tracked files after code generation
50+
if ! git diff --quiet; then
51+
echo "::error::Code generation produced uncommitted changes. Please run the codegen script locally and commit the results."
52+
echo "Changed files:"
53+
git diff --name-only
54+
echo "Diff details:"
55+
git diff
56+
exit 1
57+
fi
58+
59+
# Also check for untracked files that might have been generated
60+
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
61+
echo "::error::Code generation produced untracked files. Please review and commit them if they should be included."
62+
echo "Untracked files:"
63+
git ls-files --others --exclude-standard
64+
exit 1
65+
fi
66+
67+
echo "No uncommitted changes detected - code generation is up to date!"

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Release History
22

3+
## 2.6.0-beta.1 (Unreleased)
4+
5+
### Features Added
6+
7+
- OpenAI.Chat:
8+
- Added the `Minimal` property to `ChatReasoningEffortLevel`
9+
10+
- OpenAI.Responses:
11+
- Added the `Minimal` property to `ResponseReasoningEffortLevel`
12+
313
## 2.5.0 (2025-09-23)
414

515
### Features Added

api/OpenAI.net8.0.cs

Lines changed: 190 additions & 6 deletions
Large diffs are not rendered by default.

api/OpenAI.netstandard2.0.cs

Lines changed: 176 additions & 6 deletions
Large diffs are not rendered by default.

codegen/generator/src/OpenAI.Library.Plugin.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<RootNamespace>OpenAI.Microsoft.Generator.CSharp.ClientModel.Plugin</RootNamespace>
77
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250915.1" />
11+
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20251001.2" />
1212
</ItemGroup>
1313

1414
<!-- Copy output to package dist path for local execution and -->
@@ -22,5 +22,3 @@
2222
</Target>
2323

2424
</Project>
25-
26-

codegen/generator/src/OpenAILibraryGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.ComponentModel.Composition;
32
using Microsoft.TypeSpec.Generator;
43
using Microsoft.TypeSpec.Generator.ClientModel;
@@ -16,11 +15,12 @@ public OpenAILibraryGenerator(GeneratorContext context) : base(context) { }
1615
protected override void Configure()
1716
{
1817
base.Configure();
18+
// This should be first, as it recomputes the type
19+
AddVisitor(new NonAbstractPublicTypesVisitor());
1920
AddVisitor(new ConstructorFixupVisitor());
2021
AddVisitor(new KindRenameVisitor());
2122
AddVisitor(new VisibilityVisitor());
2223
AddVisitor(new ContentInnerCollectionDefinedVisitor());
23-
AddVisitor(new NonAbstractPublicTypesVisitor());
2424
AddVisitor(new PageOrderRemovalVisitor(this));
2525
AddVisitor(new OmittedTypesVisitor());
2626
AddVisitor(new InvariantFormatAdditionalPropertiesVisitor());

codegen/generator/src/OpenAILibraryVisitor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public class OpenAILibraryVisitor : ScmLibraryVisitor
4949

5050
protected override TypeProvider VisitType(TypeProvider type)
5151
{
52-
if (type is ModelProvider { BaseModelProvider: null } && type.Fields.Count > 0)
52+
var additionalPropertiesField = type.Fields.FirstOrDefault(f => f.Name == AdditionalPropertiesFieldName);
53+
if (type is ModelProvider { BaseModelProvider: null } && additionalPropertiesField != null)
5354
{
5455
// Add an internal AdditionalProperties property to all base models
55-
var additionalPropertiesField = type.Fields.Single(f => f.Name == AdditionalPropertiesFieldName);
5656
var properties = new List<PropertyProvider>(type.Properties)
5757
{
5858
new PropertyProvider($"", MethodSignatureModifiers.Internal,

codegen/generator/src/Visitors/ExperimentalAttributeVisitor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,12 @@ public class ExperimentalAttributeVisitor : ScmLibraryVisitor
618618

619619
protected override PropertyProvider? VisitProperty(PropertyProvider property)
620620
{
621+
// Skip properties that are already marked as experimental
622+
if (property.Attributes.Any(attr => attr.Type.Equals(typeof(ExperimentalAttribute))))
623+
{
624+
return base.VisitProperty(property);
625+
}
626+
621627
// Skip properties that are not public or are in non-stable classes
622628
if ((!property.Modifiers.HasFlag(MethodSignatureModifiers.Public) &&
623629
!property.Modifiers.HasFlag(MethodSignatureModifiers.Protected)) ||

codegen/generator/src/Visitors/NonAbstractPublicTypesVisitor.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Microsoft.TypeSpec.Generator.ClientModel;
22
using Microsoft.TypeSpec.Generator.Primitives;
33
using Microsoft.TypeSpec.Generator.Providers;
4-
using System.Reflection;
54

65
namespace OpenAILibraryPlugin.Visitors;
76

@@ -17,16 +16,22 @@ protected override TypeProvider VisitType(TypeProvider type)
1716
&& type.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Abstract)
1817
&& type.CustomCodeView?.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Abstract) == false)
1918
{
19+
var serializationProviders = type.SerializationProviders;
20+
21+
// ensure we build the serialization attributes before we change the modifiers
22+
foreach (var serialization in serializationProviders)
23+
{
24+
_ = serialization.Attributes;
25+
}
26+
2027
// Keep types defined in custom code without 'abstract' non-abstract
28+
type.Update(modifiers: type.DeclarationModifiers & ~TypeSignatureModifiers.Abstract);
2129

22-
// To do: replace with this line when dependencies updated to include modifier support
23-
// type.Update(modifiers: type.DeclarationModifiers & ~TypeSignatureModifiers.Abstract);
24-
// To do: remove this reflection-based workaround for the above:
25-
FieldInfo privateModifiersInfo = typeof(TypeProvider)
26-
.GetField("_declarationModifiers", BindingFlags.Instance | BindingFlags.NonPublic)!;
27-
TypeSignatureModifiers privateValue = (TypeSignatureModifiers)privateModifiersInfo.GetValue(type)!;
28-
privateValue &= ~TypeSignatureModifiers.Abstract;
29-
privateModifiersInfo.SetValue(type, privateValue);
30+
// reset the serialization to pick up the new modifiers while keeping any serialization attributes
31+
foreach (var serialization in serializationProviders)
32+
{
33+
serialization.Update(attributes: serialization.Attributes, reset: true);
34+
}
3035
}
3136
return type;
3237
}

0 commit comments

Comments
 (0)