Merged
Conversation
…bstract base types (microsoft#9484) ## Problem Regenerating SDKs from TypeSpec (previously from autorest) changes constructor accessibility on abstract base types, breaking existing code. Example from Azure.Search.Documents: **Previous (autorest):** ```csharp public abstract partial class SearchIndexerDataIdentity { public SearchIndexerDataIdentity() { } } ``` **Current (TypeSpec without fix):** ```csharp public abstract partial class SearchIndexerDataIdentity { private protected SearchIndexerDataIdentity(string odataType) { } // Constructor is private protected instead of public } ``` ## Changes ### Core Implementation - **TypeProvider.ProcessTypeForBackCompatibility**: Extended to process constructors in addition to methods - **TypeProvider.BuildConstructorsForBackCompatibility**: New virtual method for constructor backward compatibility logic - **ModelProvider.BuildConstructorsForBackCompatibility**: Changes constructor modifiers from `private protected` to `public` on abstract base types when the last contract had a public constructor with matching parameters ### Approach This implementation changes the accessibility modifier on existing constructors rather than generating new ones. It only applies when: 1. The type is an abstract base type 2. The last contract had a public constructor 3. The current version generates a `private protected` constructor with matching parameters (same count, types, and names) ### Generated Code ```csharp public abstract partial class SearchIndexerDataIdentity { /// <summary> Initializes a new instance of SearchIndexerDataIdentity. </summary> public SearchIndexerDataIdentity(string odataType) { OdataType = odataType; } } ``` ## Testing - Added `BackCompat_AbstractTypeConstructorAccessibility` test that verifies constructor modifiers change from `private protected` to `public` - All 1231 tests pass - Updated documentation with new "Model Constructors" section <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> ---- *This section details on the original issue you should resolve* <issue_title>[Bug]: Backward Compatibility not generating pre-existing public constructors</issue_title> <issue_description>### Describe the bug Pre-existing public constructors should not be missing from the generated code. This should be another Back Compat scenario. See [Backward Compatibility Support](https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/generator/docs/backward-compatibility.md) for more details. Generating Azure.Search.Documents have the issue where a public constructor is missing, for instance, this is what the previously generated code from autorest looks like: ```csharp // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // <auto-generated/> #nullable disable using System; using System.Collections.Generic; namespace Azure.Search.Documents.Indexes.Models { /// <summary> /// Abstract base type for data identities. /// Please note <see cref="SearchIndexerDataIdentity"/> is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include <see cref="SearchIndexerDataNoneIdentity"/> and <see cref="SearchIndexerDataUserAssignedIdentity"/>. /// </summary> public abstract partial class SearchIndexerDataIdentity { /// <summary> /// Keeps track of any properties unknown to the library. /// <para> /// To assign an object to the value of this property use <see cref="BinaryData.FromObjectAsJson{T}(T, System.Text.Json.JsonSerializerOptions?)"/>. /// </para> /// <para> /// To assign an already formatted json string to this property use <see cref="BinaryData.FromString(string)"/>. /// </para> /// <para> /// Examples: /// <list type="bullet"> /// <item> /// <term>BinaryData.FromObjectAsJson("foo")</term> /// <description>Creates a payload of "foo".</description> /// </item> /// <item> /// <term>BinaryData.FromString("\"foo\"")</term> /// <description>Creates a payload of "foo".</description> /// </item> /// <item> /// <term>BinaryData.FromObjectAsJson(new { key = "value" })</term> /// <description>Creates a payload of { "key": "value" }.</description> /// </item> /// <item> /// <term>BinaryData.FromString("{\"key\": \"value\"}")</term> /// <description>Creates a payload of { "key": "value" }.</description> /// </item> /// </list> /// </para> /// </summary> private protected IDictionary<string, BinaryData> _serializedAdditionalRawData; /// <summary> Initializes a new instance of <see cref="SearchIndexerDataIdentity"/>. </summary> public SearchIndexerDataIdentity() { } /// <summary> Initializes a new instance of <see cref="SearchIndexerDataIdentity"/>. </summary> /// <param name="oDataType"> A URI fragment specifying the type of identity. </param> /// <param name="serializedAdditionalRawData"> Keeps track of any properties unknown to the library. </param> internal SearchIndexerDataIdentity(string oDataType, IDictionary<string, BinaryData> serializedAdditionalRawData) { ODataType = oDataType; _serializedAdditionalRawData = serializedAdditionalRawData; } /// <summary> A URI fragment specifying the type of identity. </summary> internal string ODataType { get; set; } } } ``` and the new generated model looks like: ```csharp // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // <auto-generated/> #nullable disable using System; using System.Collections.Generic; namespace Azure.Search.Documents.Models { /// <summary> /// Abstract base type for data identities. /// Please note this is the abstract base class. The derived classes available for instantiation are: <see cref="SearchIndexerDataNoneIdentity"/> and <see cref="SearchIndexerDataUserAssignedIdentity"/>. /// </summary> public abstract partial class SearchIndexerDataIdentity { /// <summary> Keeps track of any properties unknown to the library. </summary> private protected readonly IDictionary<string, BinaryData> _additionalBinaryDataProperties; /// <summary> Initializes a new instance of <see cref="SearchIndexerDataIdentity"/>. </summary> /// <param name="odataType"> A URI fragment specifying the type of identity. </param> private protected SearchIndexerDataIdentity(string odataType) { OdataType = odataType; } /// <summary> Initializes a new instance of <see cref="SearchIndexerDataIdentity"/>. </summary> ... </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9483 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JonathanCrd <17486462+JonathanCrd@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Co-authored-by: jolov <jolov@microsoft.com>
…delType` (microsoft#9336) ## Summary Added overloads to `isArrayModelType` and `isRecordModelType` that don't require the unused program parameter. The old signature is deprecated but still works for backward compatibility. ## Usage ```javascript // New (preferred) isArrayModelType(type) isRecordModelType(type) // Old (deprecated, still works) isArrayModelType(program, type) isRecordModelType(program, type) ```
Adds updates to the input types in preparation for adding xml serialization support. contributes to : microsoft#5645
Co-authored-by: iscai-msft <isabellavcai@gmail.com>
Co-authored-by: iscai-msft <isabellavcai@gmail.com>
This pull request improves how API version parameters are handled, specifically ensuring that API version query parameters are correctly reinjected during pagination scenarios. It also adds a test to validate this behavior. **Pagination and Parameter Reinjection Improvements:** * Added logic to ensure API version parameters (those marked as `IsApiVersion`) are preserved and reinjected across pagination requests in the `GetReinjectedParametersMap` method of `RestClientProvider`. * Updated the `ShouldSkipReinjectedParameter` method to skip both `maxpagesize` and `api-version` parameters when determining which parameters to reinject, preventing unnecessary reinjection of these special parameters. * Defined a constant for the API version parameter name (`ApiVersionParameterName`) to improve maintainability and clarity. **Testing Enhancements:** * Added a new unit test, `TestApiVersionParameterReinjectedInCreateNextRequestMethod`, to verify that the generated client code correctly reinjects the `api-version` parameter during pagination. Solves: microsoft#9492
…crosoft#9498) ## Plan: Add support for 302 redirect in http-client-csharp - [x] Understand the issue from migration blocker document - [x] Identify root cause in RestClientProvider.GetClassifier - [x] Update GetSuccessStatusCodes to include 3xx status codes - [x] Add test case for 302 redirect in http-client-csharp - [x] Validate test passes with changes - [x] Run broader test suite to ensure no regressions - [x] Code review and address feedback - [x] COMPLETE ### Summary Successfully added support for HTTP 3xx redirect status codes (including 302) to the http-client-csharp emitter. ### Changes Made 1. **RestClientProvider.cs** (1 line changed): - Line 862: Changed from `statusCode < 300` to `statusCode < 400` - Allows 3xx redirect status codes to be treated as success responses 2. **Unit test**: - Added `Validate3xxRedirectStatusCode` test in `RestClientProviderTests.cs` to verify 302 redirect support - Test validates proper pipeline message classifier creation for 3xx status codes - Test validates that the CreateRequest method properly references and uses the classifier property - Test is self-contained and uses InputFactory to create test data ### Test Results ✅ All 1010 unit tests pass (Microsoft.TypeSpec.Generator.ClientModel.Tests) ✅ New test specifically validates 302 redirect functionality including CreateRequest method behavior ✅ No regressions in existing functionality ### Migration Blocker Resolution This resolves the migration blocker for Azure.Communication.ProgrammableConnectivity which uses 302 redirects in its OAuth authorization flow. The service can now migrate from the legacy emitter to http-client-csharp v1.0.0+. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Add support for 302 redirect</issue_title> > <issue_description>See https://github.com/Azure/azure-sdk-for-net/blob/8401911d737002189207067dde4177ea94846126/sdk/communication/Azure.Communication.ProgrammableConnectivity/MIGRATION_BLOCKER.md</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9497 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
…on (microsoft#9501) - [x] Review Azure SDK PR #13235 pattern for removing API Key authentication - [x] Update Create-APIReview.ps1 to remove API Key parameter and add Bearer token authentication - Removed `$APIKey` parameter from script - Added `Get-ApiViewBearerToken()` function that acquires Azure AD tokens via `az account get-access-token` - Updated `Upload-SourceArtifact` to use Bearer token instead of API Key - Updated `Upload-ReviewTokenFile` to use Bearer token instead of API Key - Changed API endpoints from `UploadAutoReview` to `upload` and `CreateApiReview` to `create` (lowercase) - Changed HTTP method from GET to POST for the create endpoint - Improved error handling with more detailed error messages - [x] Update create-apireview.yml to use AzureCLI@2 task instead of Powershell@2 task - Changed task from `Powershell@2` to `AzureCLI@2` - Added `AzureServiceConnection` parameter with default value "APIView prod deployment" - Removed `-APIKey $(azuresdk-apiview-apikey)` argument - Removed `pwsh: true` (not needed with AzureCLI@2) - Added `azureSubscription`, `scriptType`, and `scriptLocation` inputs - [x] Address security concern: removed potentially sensitive token response from error logging <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Stop using Api Key in Create-ApiReview script</issue_title> > <issue_description>We can follow the same pattern as used in Azure/azure-sdk-tools#13235 > > And apply those changes to https://github.com/microsoft/typespec/blob/main/eng/emitters/scripts/Create-APIReview.ps1 > > Also need to update https://github.com/microsoft/typespec/blob/main/eng/emitters/pipelines/templates/steps/create-apireview.yml</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9500 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
This pull request updates the C# HTTP client generator to improve parameter naming consistency for paging operations. Specifically, it ensures that the "top" query parameter is renamed to "maxCount" in generated REST client methods, and adds a corresponding unit test to verify this behavior. Additionally, the `InputParameter.Update` method is enhanced to allow updating multiple fields at once. Solves: microsoft#9502
…-only) (microsoft#9495) Optional Content-Type headers were incorrectly transformed into extensible enums by the type converter. They must remain as constants. ## Changes **Emitter (type-converter.ts)** - Skip enum transformation for Content-Type headers, preserving constant type regardless of optionality **Emitter (operation-converter.ts)** - Pass header parameter to `fromSdkType` to enable Content-Type detection **Emitter Tests (operation-converter.test.ts)** - Added tests to verify Content-Type remains as constant type for both optional and required bodies ## Result Content-Type headers now remain as constants in the type model instead of being transformed to enums when the body parameter is optional. This prevents the enum transformation while preserving the constant type information for downstream processing. ## Note This PR focuses solely on the emitter-side fix to prevent unwanted enum transformation. Generator-side handling of optional Content-Type parameters (if needed for conditional setting) will be addressed separately. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Fix optional contentType issue</issue_title> > <issue_description>As described in Azure/azure-sdk-for-net#55300, but the issue belongs in this repo.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9494 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Co-authored-by: jolov <jolov@microsoft.com>
Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
- Move EditorTabs component for reuse in typespec-azure - Make sure the tryit plugin works correctly when using `<Code` component
Co-authored-by: iscai-msft <isabellavcai@gmail.com>
Updates System.ClientModel package from 1.8.0 to 1.9.0 in both generator source and generated project templates. ## Changes - **Packages.Data.props**: Updated `System.ClientModel` to 1.9.0 and `System.Memory.Data` to 10.0.1 (transitive dependency requirement) - **NewProjectScaffolding.cs**: Updated generated project template to reference System.ClientModel 1.9.0 - Regenerated all test projects (74 .csproj files) to reflect the new package versions <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Bump SCM to 1.9.0</issue_title> > <issue_description>Bump System.ClientModel package to 1.9.0 both in our [generator source](https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/generator/Packages.Data.props#L17) and in the generated project file.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9518 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…#9524) Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.3 to 7.5.7. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/isaacs/node-tar/commit/4a37eb9a1cf1137df4eb70c5c7f849f412ff3cdb"><code>4a37eb9</code></a> 7.5.7</li> <li><a href="https://github.com/isaacs/node-tar/commit/f4a7aa9bc3d717c987fdf1480ff7a64e87ffdb46"><code>f4a7aa9</code></a> fix: properly sanitize hard links containing ..</li> <li><a href="https://github.com/isaacs/node-tar/commit/394ece6ad8d81742a4e4058af227c616cd947a25"><code>394ece6</code></a> 7.5.6</li> <li><a href="https://github.com/isaacs/node-tar/commit/7d4cc17c76f6bd11dcd83de47187dc6dff206eee"><code>7d4cc17</code></a> fix race puting a Link ahead of its target File</li> <li><a href="https://github.com/isaacs/node-tar/commit/26ab90474e642cf00d84a05bcdc2eaf2a19f1581"><code>26ab904</code></a> 7.5.5</li> <li><a href="https://github.com/isaacs/node-tar/commit/e9a1ddb821b29ddee75b9470dd511066148c8070"><code>e9a1ddb</code></a> fix: do not prevent valid linkpaths within archive</li> <li><a href="https://github.com/isaacs/node-tar/commit/911c886bb170a6ee3db05fd3709221752213ec8a"><code>911c886</code></a> 7.5.4</li> <li><a href="https://github.com/isaacs/node-tar/commit/3b1abfae650056edfabcbe0a0df5954d390521e6"><code>3b1abfa</code></a> normalize out unicode ligatures</li> <li><a href="https://github.com/isaacs/node-tar/commit/a43478c5c51a71ec996cea62ff824eb9dc9dd17c"><code>a43478c</code></a> remove some unused files</li> <li><a href="https://github.com/isaacs/node-tar/commit/970c58f6d3d0c932081f8b40218f612db2fabb5a"><code>970c58f</code></a> update deps</li> <li>Additional commits viewable in <a href="https://github.com/isaacs/node-tar/compare/v7.5.3...v7.5.7">compare view</a></li> </ul> </details> <details> <summary>Maintainer changes</summary> <p>This version was pushed to npm by <a href="https://www.npmjs.com/~isaacs">isaacs</a>, a new releaser for tar since your current version.</p> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/microsoft/typespec/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…essing (microsoft#9528) - [x] Understand the issue: The previous fix in PR microsoft#9495 added Content-Type header detection in `type-converter.ts`, but it relies on `sdkProperty` being passed to `fromSdkType`. The `fromHeaderParameter` function in `operation-converter.ts` doesn't pass the header parameter to `fromSdkType`, so the fix doesn't work. - [x] Fix `fromHeaderParameter` to pass the header parameter `p` to `fromSdkType` so the Content-Type detection can work - [x] Unify all parameter-processing functions to pass property instance to `fromSdkType`: - `fromQueryParameter` - `fromPathParameter` - `fromHeaderParameter` - `fromBodyParameter` - `updateMethodParameter` - [x] Investigated making `sdkProperty` required - not feasible as many callers have no property context (model base types, array/dict value types, etc.) - [x] Run existing tests to verify the fix works (all 177 tests pass) - [x] Fix CI formatting issues - [x] Run code review and security checks <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Fix optional contentType issue</issue_title> > <issue_description>As described in Azure/azure-sdk-for-net#55300, but the issue belongs in this repo.</issue_description> > > <agent_instructions>The previous [fix ](microsoft#9495) does not really fix the issue entirely. > Please fix this again following the root cause in this comment: https://github.com/microsoft/typespec/issues/9494#issuecomment-3822513806</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@ArcturusZhang</author><body> > I think this is not fixed. > The fix introduced an extra check to see if it is a content type header, by checking if the `sdkProperty` is not undefined, but in our code, when the `fromSdkType` is called converting the method parameters (for instance [here](https://github.com/microsoft/typespec/blob/f1a7649b3b53ab7d30488cf7274f813696cdf2d0/packages/http-client-csharp/emitter/src/lib/operation-converter.ts#L482)), the `sdkProperty` argument is never passed in. Therefore the fix is not actually running.</body></comment_new> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9494 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>
…rosoft#9516) ## ✅ Implementation Complete: Add backward compatibility support for object-typed AdditionalProperties ### Issue Resolved Successfully implemented backward compatibility for models with `IDictionary<string, object>` AdditionalProperties (from old generator) that are now generated as `IDictionary<string, BinaryData>` (in new generator). ### Final Solution **Core Approach: Matching Backing Field Types** The solution detects when a model previously had object-typed AdditionalProperties and creates the backing field with the appropriate type, ensuring perfect type alignment between field and property. ### Files Changed **packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/ModelProvider.cs** - Added object dictionary type support alongside BinaryData - Added early backward compatibility detection via `ShouldUseObjectAdditionalProperties()` - Updated `BuildRawDataField()` to create field with object or BinaryData type based on backward compat needs - Updated property generation logic to use matching backing field type - Added comprehensive XML documentation - Fixed null-safety issues with IsFrameworkType checks **packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelProviderTests.cs** - Added `TestBuildProperties_WithObjectAdditionalPropertiesBackwardCompatibility` test **packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/test/Providers/MrwSerializationTypeDefinitions/AdditionalPropertiesTest.cs** - Added comprehensive deserialization test verifying all code aspects - Added comprehensive serialization test verifying all code aspects - Both tests validate complete generated code with detailed assertions **packages/http-client-csharp/generator/docs/backward-compatibility.md** - Added new section "AdditionalProperties Type Preservation" - Documents the object-to-BinaryData migration scenario - Provides examples of before/after code - Explains serialization/deserialization behavior differences - Formatted with prettier (removed trailing whitespace) ### Test Results ✅ - **1232/1232** Microsoft.TypeSpec.Generator.Tests PASSED - **1014/1014** Microsoft.TypeSpec.Generator.ClientModel.Tests PASSED - **10/10** AdditionalPropertiesTest tests PASSED - **2/2** Serialization backward compatibility tests with comprehensive assertions PASSED ### Comprehensive Test Coverage **Deserialization test verifies:** - Variable declaration: `IDictionary<string, object> additionalProperties` - Dictionary initialization: `ChangeTrackingDictionary<string, object>()` - Property enumeration: `foreach (var prop in element.EnumerateObject())` - Property name checks: `prop.NameEquals("name"u8)` - Type-specific methods: `GetString()` for known properties, `GetObject()` for additional properties - Constructor call with proper parameters **Serialization test verifies:** - Format validation and error handling - Property name serialization: `writer.WritePropertyName("name"u8)` - Property value serialization: `writer.WriteStringValue(Name)` - Foreach iteration over AdditionalProperties - Key serialization: `writer.WritePropertyName(item.Key)` - Value serialization: `writer.WriteObjectValue<object>(item.Value, options)` - Options.Format handling ### Backward Compatibility Guarantees | Scenario | Result | |----------|--------| | Existing library with object type | ✅ Maintains object type when regenerated | | New library without previous version | ✅ Uses BinaryData type (new default) | | Binary compatibility | ✅ Fully maintained - same types | | Source compatibility | ✅ Fully maintained - code compiles | | Serialization | ✅ Works with both types - fully verified | | Deserialization | ✅ Works with both types - fully verified | ### Ready for Merge This PR successfully resolves the issue with comprehensive test coverage and documentation updates. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Add backcompat support for public AdditionalProperties property on models defined as object valued dictionary</issue_title> > <issue_description>In the old generator, we would generate AdditionalProperties as `IDictionary<string, object>`. In the new generator, we use `IDictionary<string, BinaryData>`. We will need to implement support for object for backwards compatibility.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9515 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
…ft#9521) ## Fix Content-Type header setting in RestClient ✅ ### Summary Fixed an issue where Content-Type headers were set unconditionally, even when request content was optional and might be null. ### Changes Made - [x] Modified `RestClientProvider.BuildCreateRequestMethodBody` to detect and pass content parameter to `AppendHeaderParameters` - [x] Updated `AppendHeaderParameters` to wrap Content-Type header setting in `if (content != null)` check **only when body parameter is optional** - [x] Added comprehensive tests to verify the fix with full statement assertion - [x] Added test for required body parameter with assertion that Content-Type is NOT wrapped in if statement - [x] Removed unnecessary cast - ParameterProvider has implicit conversion to ValueExpression - [x] All 51 RestClientProvider tests passing ### Result **Before:** ```csharp // When body is optional request.Headers.Set("Content-Type", "application/json"); request.Content = content; // content could be null ``` **After (when body is optional):** ```csharp if (content != null) { request.Headers.Set("Content-Type", "application/json"); } request.Content = content; ``` **After (when body is required):** ```csharp request.Headers.Set("Content-Type", "application/json"); request.Content = content; // content is required, no null check needed ``` This ensures Content-Type headers are only wrapped in null checks when the request body parameter is actually optional, avoiding unnecessary checks for required parameters. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Content-Type setting in RestClient is not correct</issue_title> > <issue_description>Currently we have code generated like this Azure/azure-sdk-for-net#55347 (comment). This isn't correct (obviously). We should instead be checking if the RequestContent is null when setting the Content-Type header. > </issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9520 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
…microsoft#9538) while onboarding to the project, I noticed a failing unit test on windows (en-CA) locale. This is due to a variant behaviour on how dates are represented
…rosoft#9539) while working on microsoft#9538 I noticed they were missing. Note: using teams here would make things easier
This pull request refactors how special query parameters, particularly API version and max page size, are detected and handled in the `RestClientProvider` class. The changes improve the flexibility and accuracy of parameter updates, especially for paging operations, by relying on parameter metadata rather than hardcoded string comparisons. Parameter handling improvements: * Refactored the logic for detecting API version and max page size parameters in `ShouldUpdateReinjectedParameter` to use parameter metadata (`IsApiVersion` and paging metadata) instead of comparing against hardcoded strings. * Updated the call to `ShouldUpdateReinjectedParameter` in `AppendQueryParameters` to pass the full `InputParameter` and `InputPagingServiceMethod`, enabling the new metadata-based logic.
microsoft#9430) This pull request adds support for custom array encoding formats in the C# HTTP client generator, allowing arrays to be serialized and deserialized using delimiters such as comma, space, pipe, or newline. The changes span the model, serialization logic, type conversion, and test coverage to ensure correct handling of these encodings. ### Array encoding support * Introduced an optional `encode` property to `InputModelProperty` and related types to specify the desired array encoding (e.g., `commaDelimited`, `spaceDelimited`, etc.). This is reflected in the type definitions, model constructors, and JSON serialization/deserialization logic. * Updated the type converter (`type-converter.ts`) to propagate the `encode` property from SDK model properties into the input model. ### Serialization and deserialization logic * Added custom serialization and deserialization methods in `MrwSerializationTypeDefinition.cs` to handle arrays with specified encodings. These methods join or split array elements using the appropriate delimiter and handle both string and primitive element types. ### Test coverage * Added new tests in `EncodeArrayTests.cs` to verify correct serialization and deserialization for each supported encoding format (comma, space, pipe, newline). Implements: microsoft#9028
…ft#9544) Bumps [tar](https://github.com/isaacs/node-tar) from 7.5.6 to 7.5.7. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/isaacs/node-tar/commit/4a37eb9a1cf1137df4eb70c5c7f849f412ff3cdb"><code>4a37eb9</code></a> 7.5.7</li> <li><a href="https://github.com/isaacs/node-tar/commit/f4a7aa9bc3d717c987fdf1480ff7a64e87ffdb46"><code>f4a7aa9</code></a> fix: properly sanitize hard links containing ..</li> <li>See full diff in <a href="https://github.com/isaacs/node-tar/compare/v7.5.6...v7.5.7">compare view</a></li> </ul> </details> <details> <summary>Maintainer changes</summary> <p>This version was pushed to npm by <a href="https://www.npmjs.com/~isaacs">isaacs</a>, a new releaser for tar since your current version.</p> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/microsoft/typespec/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…erialized names (microsoft#9477) - [x] Investigate the issue and understand the root cause - [x] Write failing tests that reproduce the bug - [x] Fix the issue by comparing serialized names instead of C# property names for discriminator de-duplication - [x] Verify all related tests pass (1233 generator tests) - [x] Run code review and address feedback - [x] Add null checks for SerializedName as suggested in review - [x] Add verification that correct discriminator value is passed to base class ## Root Cause Analysis The bug occurs in `ModelProvider.BuildProperties()` where the check for duplicate discriminator properties only compared by C# property name (`property.Name`) instead of also checking the serialized name (`property.SerializedName`). When the base model has a discriminator property with a different C# name than the derived model's discriminator property (but the same wire name like `@odata.type`), the check failed and the discriminator property was incorrectly added to the derived class. ## Fix Added a HashSet of base discriminator serialized names and extended the check to skip discriminator properties that match by either: 1. C# property name (existing check) 2. Serialized name (new check) Added null checks for `SerializedName` as per code review feedback to ensure defensive coding practices. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[Bug]: Duplicate Discriminator Property in Derived Types</issue_title> > <issue_description>### Describe the bug > > ### Description > The TypeSpec C# generator creates a duplicate `OdataType` property in derived classes when the base class already defines it as the discriminator. This causes CS0108 "hides inherited member" compiler warnings/errors. > > ### Reproduction > In `ContentUnderstandingSkill.cs` (derived from `SearchIndexerSkill`): > > **Base class (`SearchIndexerSkill.cs`):** > ```csharp > internal string OdataType { get; set; } > ``` > > **Derived class (`ContentUnderstandingSkill.cs`) incorrectly re-declares:** > ```csharp > internal string OdataType { get; set; } = "#Microsoft.Skills.Util.ContentUnderstandingSkill"; > ``` > > The internal constructor also has a redundant parameter: > ```csharp > internal ContentUnderstandingSkill( > string odataType, // ? passed to base class > ..., > string odataType0) // ? duplicate, assigned to local OdataType > : base(odataType, ...) > { > // ... > OdataType = odataType0; // ? This shouldn't exist > } > ``` > > ### Expected Behavior > Derived types should NOT re-declare the discriminator property. The value should be set via the base class constructor only, which is already being done correctly in the public constructor: > > ```csharp > public ContentUnderstandingSkill(...) > : base("#Microsoft.Skills.Util.ContentUnderstandingSkill", inputs, outputs) > ``` > > ### Compiler Error > ``` > CS0108: 'ContentUnderstandingSkill.OdataType' hides inherited member 'SearchIndexerSkill.OdataType'. > Use the new keyword if hiding was intended. > ``` > > ### Root Cause > The TypeSpec definition likely has the `@odata.type` discriminator property appearing in both the base type and derived type definitions, or there's a conflict between the discriminator and a regular property with the same JSON name. > > ### Affected Types > - `ContentUnderstandingSkill` > - `ChatCompletionSkill` > - Potentially all derived skill types and any other polymorphic hierarchy with a discriminator property > > --- > > ### Reproduction > > Existing File with error : https://github.com/Azure/azure-sdk-for-net/blob/3df80e71cc22102f60910e9d188ca864ea18849d/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.cs#L138C1-L139C1 > > Previous file: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/src/Generated/Models/ChatCompletionSkill.cs > > ### Checklist > > - [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md) > - [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate. > - [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions). > - [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.</issue_description> > > <agent_instructions>This fix applies to packages\http-client-csharp</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9437 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JonathanCrd <17486462+JonathanCrd@users.noreply.github.com> Co-authored-by: Jonathan Cárdenas <JonathanCrd@users.noreply.github.com>
…emitter (microsoft#9274) - [x] Explore the http-client-python repository structure - [x] Understand the emitter and generator architecture - [x] Review existing documentation and structure - [x] Create comprehensive architecture documentation - [x] Add the documentation to the website - [x] Review and finalize documentation - [x] Fix ASCII diagram box alignment - [x] Add m2r transformation to emitter responsibilities - [x] Align directory structure comments - [x] Ensure all diagram right borders align at column 66 - [x] Align all # comments to column 43 in directory tree - [x] Simplify component details to reduce duplication - [x] Fix Prettier formatting issues <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[python] docs to introduce source code of http-client-python</issue_title> > <issue_description>Context: > http-client-python contains 2 part of code, > (1) first part is in folder "emitter" written by typescript which handle info from typespec-client-generator-code, then pass handled data to "generator/pygen" written by python to generate sdk. > (2) In pygen, it is pre-handled again in "preprocess" then pass to "codegen". In "codegen", "models" prepares all necessary info then "serializers" render files with template files of "templates" and parameter info from "models" to generated sdk file. > > Ask: > With up context, write a brief introduction to "http-client-python" so that developers could understand the repo and develop quickly. > > NOTE: > (1) context is just help you understand the repo but DO NOT be limited by context so you can read the files or code of this repo to make a good doc > </issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9273 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/typespec/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Reverts the temporary URL change introduced in microsoft#9870, restoring the `$APIViewUri` default in `eng/emitters/scripts/Create-APIReview.ps1` back to `https://apiview.dev/autoreview`. After merging: Azure/azure-sdk-tools#14341 - **`eng/emitters/scripts/Create-APIReview.ps1`**: Reverts `$APIViewUri` default from `https://apiview.org/autoreview` → `https://apiview.dev/autoreview` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > Create a pull request in `microsoft/typespec` that reverts the changes introduced by PR microsoft#9870 ("Use apiview.org temporarily"). > > Context: > - Target PR to revert: microsoft#9870 > - Original author: JoshLove-msft > - PR state: merged > > Requirements: > 1. Identify the merge commit (or commits) that PR microsoft#9870 introduced to the default branch. > 2. Create a new branch for the revert. > 3. Revert the PR cleanly (use `git revert` of the merge commit where appropriate) so the repository returns to the state prior to PR microsoft#9870. > 4. Ensure all tests/CI checks that normally run for PRs pass. > 5. Open a PR titled like `Revert "Use apiview.org temporarily" (microsoft#9870)` with a clear description explaining why this is a revert and referencing PR microsoft#9870. > 6. If the revert causes conflicts, resolve them in a minimal, safe way and document what was done. > > Notes: > - Prefer reverting the merge commit that brought in PR microsoft#9870 to preserve history. > - Keep the revert focused strictly on undoing PR microsoft#9870 (avoid unrelated formatting or refactors). </details> <!-- START COPILOT CODING AGENT SUFFIX --> *This pull request was created from Copilot chat.* > <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tjprescott <5723682+tjprescott@users.noreply.github.com> Co-authored-by: Travis Prescott <tjprescott@users.noreply.github.com>
…pace is versioned (microsoft#9939) When `@overload` is used inside an interface within a `@versioned` namespace, the compiler incorrectly reports `overload-same-parent`. The versioning mutator clones the interface and its operations, then `finishType()` re-runs decorators on the clones—but decorator args still reference the original types. The cloned operation's `interface` points to the cloned interface while `overloadBase.interface` points to the original, so reference equality fails. ```tsp @versioned(Versions) @service(#{ title: "Widget Service" }) namespace DemoService; enum Versions { v1 } interface Widgets { op create(data: string | bytes, @Header contentType: "text/plain" | "application/octet-stream"): void; @overload(Widgets.create) // ❌ overload-same-parent op createString(data: string, @Header contentType: "text/plain"): void; } ``` ### Changes - **`packages/compiler/src/lib/decorators.ts`**: `areOperationsInSameContainer` now falls back to AST node identity comparison when reference equality fails. Cloned types preserve the same `node` from their source, so this correctly identifies two interface/namespace instances as originating from the same declaration. - **`packages/openapi3/test/overloads.test.ts`**: Added tests for overloads inside both interfaces and namespaces within versioned namespaces, with assertions on the emitted OpenAPI output. > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `telemetry.astro.build` > - Triggering command: `/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build sh pec/�� tput-dir ../../w--llmstxt node ules/.bin/node import @typespecnode /home/REDACTED/wor/home/REDACTED/work/typespec/typespec/packages/http-specs/node_modules�� /.bin/node node tobu�� astro check --minimumFailingSeve--typekits node _modules/.bin/sh perimental gen-enode SE_fce680ab2cc46/home/REDACTED/work/typespec/typespec/packages/http-server-js/node_modules/.bin/..hint tobuf/reference node` (dns block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/microsoft/typespec/settings/copilot/coding_agent) (admins only) > > </details> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>`@overload` interface validation fails when the enclosing namespace is versioned</issue_title> > <issue_description>[Here is a sample](https://typespec.io/playground/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7CtIZcmVzdNUZdmVyc2lvbmluZyI7Cgp1c2luZyBWyRQ7CgpAxyJlZCjHGHMpCkBzZXJ2aWNlKCN7IHRpdGxlOiAiV2lkZ2V0IFPGGiIgfSkKbmFtZXNwYWNlIERlbW%2FHGjsKCmVudW3IZnMgewogIHYxLAp96ACASHR0cDvHDFJlc3Q7Cgptb2RlbCDHY8QxQGtleSBpZDogc3Ry5QCpICB3ZWlnaHQ6IGludDMyxBFjb2xvcjogInJlZCIgfCAiYmx1ZSLEGeQAmMo6fQoKQGVycm9yx2ZFxAzFZWNvZGXLUG1lc3NhZ846aW50ZXJm5ADj5gCd5wDlxT9Ac2hhcmVkUm91dGXED3B1dMRVcmVhdGXGLiguLi7GCik6x0HEaUBvdmVybG9hZCjNVS7MOynfYcYmMtVifQo%3D&e=%40typespec%2Fopenapi3&options=%7B%7D&vs=%7B%7D) > > Note that this appears to be the same issue resolved by this (only now versioning uses mutators): https://github.com/microsoft/typespec/pull/1760</issue_description> > > <agent_instructions>Create a test validating the correct behavior in a versioned namespace, validate that it fails without a fix, then create a fix that makes the test pass. The referenced fix, which examines the source property of both operations (if it exists) is likely a good way to proceed. Verify that all tests pass, that there are no misspellings (pnpm cspell) and that no files are incorrectly formatted (pnpm format)</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9937 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Enum values are generated in UPPER_CASE, so reserved word padding is unnecessary. Removes `PadType.ENUM_VALUE` and its associated logic. - **`python_mappings.py`**: Remove `ENUM_VALUE` variant from `PadType` enum and its entry in `RESERVED_WORDS` - **`preprocess/__init__.py`**: Drop `update_enum_value` import; replace padding logic with direct `str.upper()` (retaining `ENUM_` prefix for digit-leading names) - **`test_name_converter.py`**: Remove `ENUM_VALUE` test cases that referenced the deleted variant (CI fix) <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
…ults payload (microsoft#9778) - [x] Add `test_enumeration_results` — original flat-list payload test - [x] Add `test_enumeration_results_nested_empty_list` — nested model with `itemsName`-wrapped empty list - [x] Add `test_enumeration_results_azure_sdk_pattern` — Azure SDK model pattern with two unwrapped list fields - [x] Add `test_enumeration_results_blobs_unwrapped` — documents `unwrapped=True` behavior on model-typed field - [x] Fix pylint `too-many-instance-attributes` on `_RestField` — move the disable annotation outside the `has_padded_model_property` conditional so it is always emitted (11 attributes now unconditionally) - [x] All 35 tests pass <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[http-client-python] model base deserialization</issue_title> > <issue_description>Can we add a new test for deserializing the following xml payload: > > > `<?xml version="1.0" encoding="utf-8"?><EnumerationResults ServiceEndpoint="https://service.blob.core.windows.net/" ContainerName="acontainer108f32e8"><Delimiter>/</Delimiter><Blobs /><NextMarker /></EnumerationResults>`</issue_description> > > <agent_instructions>to the http-client-python package</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9777 <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: l0lawrence <100643745+l0lawrence@users.noreply.github.com> Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
update agent instruction
- emitter part for Azure/azure-sdk-for-java#47621 - autorest PR: Azure/autorest.java#3298 - sdk repo PR: Azure/azure-sdk-for-java#48226 - sync SDK PR looks good: Azure/azure-sdk-for-java#48179 ## Summary Replace `AzureResourceManager` with SDK-specific `XXManager` as the entry point in Fluent Premium samples. Previously, premium samples were generated with `AzureResourceManager` as the entry type and then moved to `sdk/resourcemanager/azure-resourcemanager/samples` by the downstream `generate.py` script. This change makes premium samples use the corresponding `XXManager` (e.g., `ComputeManager`, `StorageManager`) directly, so samples can stay in their own SDK location. ### Before vs After ```java // Before: premium sample used AzureResourceManager void sampleMethod(com.azure.resourcemanager.AzureResourceManager azure) { azure.storageAccounts().manager().serviceClient().getStorageAccounts().list(); } // After: premium sample uses SDK-specific manager void sampleMethod(com.azure.resourcemanager.storage.StorageManager manager) { manager.serviceClient().getStorageAccounts().list(); } ``` Will update `generate.py` when this got shipped.
microsoft#9943) Adds sync and async Python SDK tests for the `authentication/noauth/union` Spector scenario, which validates clients generated with `NoAuth | OAuth2Auth` union authentication. - **Sync tests** in `generic_mock_api_tests/test_authentication.py`: - `test_noauth_union_valid_no_auth` — unauthenticated request - `test_noauth_union_valid_token` — OAuth2 ****** request - **Async tests** in `generic_mock_api_tests/asynctests/test_authentication_async.py`: async counterparts of the above Tests are placed in `generic_mock_api_tests` since both azure and unbranded flavors share the same import path (`authentication.noauth.union.UnionClient`). <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
…icrosoft#9926) - [x] TypeScript: Add `milliseconds-integer` and `milliseconds-number` to `DurationSchema` format type in `time.ts` - [x] TypeScript: Update `DURATION_KNOWN_ENCODING` and `getDurationFormat` in `type-utils.ts` to handle `milliseconds` encoding - [x] Java: Add `MILLISECONDS_INTEGER` and `MILLISECONDS_NUMBER` to `DurationSchema.Format` enum - [x] Java: Add `DURATION_MILLISECONDS_LONG` and `DURATION_MILLISECONDS_DOUBLE` to `ClassType` - [x] Java: Add `DURATION_MILLISECONDS_LONG` and `DURATION_MILLISECONDS_DOUBLE` to `PrimitiveType` - [x] Java: Update `PrimitiveMapper` to map new formats to new types - [x] Java: Update `WireTypeClientTypeConverter` with milliseconds conversion logic - [x] Java: Update `ClassType.getClientType()` and `PrimitiveType.getClientType()` for new types - [x] Java: Update `ModelTestCaseUtil` to handle new types - [x] Java: Update `ProxyMethodMapper` and `ClientCoreProxyMethodMapper` RETURN_VALUE_WIRE_TYPE_OPTIONS - [x] Regenerate test files using `Generate.ps1` - [x] Update test files `EncodeDurationTests.java` to cover milliseconds scenarios; only disable `floatMilliseconds`/`float64Milliseconds`/`floatMillisecondsLargerUnit` for query/header (they produce `35625.0` instead of `35625`) - [x] Build and unit tests passing - [x] Add changeset <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>http-client-java, support DurationKnownEncoding.milliseconds</issue_title> > <issue_description>### Clear and concise description of the problem > > In packages/http-client-java > > Support `DurationKnownEncoding.milliseconds` > > Test scenario is at https://github.com/microsoft/typespec/blob/main/packages/http-specs/specs/encode/duration/main.tsp#L240-L251 > > Check existing Java code of DURATION_LONG and DURATION_DOUBLE. On Java, we can call it DURATION_MILLISECONDS_LONG and DURATION_MILLISECONDS_DOUBLE > > Typescript code would be around DURATION_KNOWN_ENCODING and related code. > > ### Checklist > > - [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md) > - [x] Read the [docs](https://typespec.io/docs/). > - [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9925 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com> Co-authored-by: Weidong Xu <weidxu@microsoft.com>
…icrosoft#9785) - [x] Add extensible enum (union) with 33 special word member names to `special-words/main.tsp` - [x] Simplify to single `@put` operation per reviewer feedback - [x] Add `ExtensibleString` return type so mock API echoes back the sent value - [x] Simplify return type to `putExtensibleStringValue(@Body body: ExtensibleString): ExtensibleString;` - [x] Add handler to dynamically extract request body and echo it back in response - [x] Remove explicit contentType headers (default application/json is sufficient) - [x] Remove redundant `@doc` decorators from union definition for consistency with rest of file - [x] Rename `union Enum` to `union ExtensibleString` to avoid blocking actual enum tests - [x] Rename interface `Enums` to `ExtensibleStrings`, route `/enums` to `/extensible-strings`, and operation `putEnumValue` to `putExtensibleStringValue` - [x] Regenerate spec-summary - [x] Add chronus changeset for @typespec/http-specs - [x] Build validated (61 scenarios pass) - [x] Format, code review, and security scan clean <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/typespec/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
…del scenarios (microsoft#9949) Adds Python SDK mock API tests for the Spector scenarios introduced/fixed in [Azure/typespec-azure#4006](Azure/typespec-azure#4006), which corrected the `flattenReadOnlyModel` response shape so read-only properties are returned wrapped in a `properties` object rather than flattened to the parent level. ## Changes - **Dependency bump**: `@azure-tools/azure-http-specs` `0.1.0-alpha.38-dev.2` → `0.1.0-alpha.38-dev.6` to pick up the new/updated Spector scenarios - **New sync + async tests** in `test_azure_client_generator_core_flatten[_async].py`: - `test_put_flatten_unknown_model` — verifies `properties` is **not** flattened for `unknown` (non-model) types - `test_put_flatten_read_only_model` — verifies the response returns read-only properties wrapped under `properties`: ```python def test_put_flatten_read_only_model(client: FlattenPropertyClient): result = client.put_flatten_read_only_model(Solution(name="foo")) assert result == Solution( name="foo", properties=SolutionProperties(solution_id="solution1", title="Solution Title", content="Solution Content"), ) ``` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[python] add test case for Azure/typespec-azure#4006 > </issue_title> > <issue_description>follow skill https://github.com/microsoft/typespec/blob/main/.github/skills/python-sdk-spector-mock-api-tests/SKILL.md to write test case for Azure/typespec-azure#4006 > </issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9948 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
…ecific parameters (microsoft#9919) - [x] Fix `ClientProvider.cs`: `HasAccessorOnlyParameters()` detects subclient-specific params; `BuildFields()` skips caching field; `BuildMethods()` generates parameterized accessor - [x] Add unit tests for Parent-only subclients with accessor-only parameters - [x] Add `MetricsClientParams` to `SampleService/main.tsp`; regenerate `Sample-TypeSpec` - [x] Revert Spector azure test project changes - [x] Run prettier on `SampleService/main.tsp` - [x] Run `Generate.ps1` and check in regenerated files <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Subclient parameters need to be included in accessors</issue_title> > <issue_description>For subclients that can be created individually or from the parent, the subclient parameters are not included in the subclient accessors currently. </issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9775 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Co-authored-by: jolov <jolov@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t#9959) When a route contains a query string (e.g., `@route("?comp=copy")`), `AddUriSegments` treated the entire literal as a path segment, generating `uri.AppendPath("?comp=copy", false)` instead of `uri.AppendQuery("comp", "copy", true)`. This produces malformed URIs like `?comp=copy?copyid=...`. ### Changes - **`RestClientProvider.cs`**: Extract `AppendLiteralSegment` helper that splits literal segments at `?`, emitting `AppendPath` for the path portion and `AppendQuery` for each `key=value` pair in the query portion. Both call sites in `AddUriSegments` now use this helper. - **`RestClientProviderTests.cs`**: Add tests covering multiple scenarios: - `TestBuildCreateRequestMethodWithQueryInPath` — route with `?comp=copy` and an additional query parameter. - `TestBuildCreateRequestMethodWithSlashQueryInPath` — route starting with `/?comp=copy` (slash before query). - `TestBuildCreateRequestMethodWithMixedPathAndQueryInPath` — route with both path segments, path parameters, multiple inline query params, and an additional query parameter (`/items/{p1}?comp=copy&restype=container`). **Before:** ```csharp uri.AppendPath("?comp=copy", false); uri.AppendQuery("copyid", copyId, true); // → ?comp=copy?copyid=... ``` **After:** ```csharp uri.AppendQuery("comp", "copy", true); uri.AppendQuery("copyid", copyId, true); // → ?comp=copy©id=... ``` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>CreateRequest Method Should Call uri.AppendQuery if Path uri starts with "?" Query Separator</issue_title> > <issue_description>Consider this operation: > > ``` > @put > @SharedRoute > @route("?comp=copy") > abortCopyFromUrl is StorageOperationNoBody< > { > ...TimeoutParameter; > > /** The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. */ > @clientName("copyId") > @query > copyid: string; > > ...LeaseIdOptionalParameter; > > /** The copy action to be performed. */ > @Header("x-ms-copy-action") > copyActionAbortConstant: "abort"; > }, > { > @statuscode statusCode: 204; > } > >; > > ``` > > The route contains a query string and the request body accepts a query. This results in the generated CreateRequest method for this operation to use > ```csharp > uri.AppendPath("?comp=copy", false); > uri.AppendQuery("copyid", copyId, true); > ``` > > instead of calling `AppendQuery` > > ```csharp > uri.AppendQuery("comp", "copy", true); > uri.AppendQuery("copyid", copyId, true); > ``` > > Which is leading to a possibly malformed uri `?comp=copy?copyid=6808d511-671f-47f0-b909-abe739c65139>`. > We should correctly parse the route and call the correct UriBuilder APIs for each component of the string.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9958 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…params (microsoft#9945) Float-typed duration values transmitted as query/header params were compared as strings, causing valid representations like `"35625.0"` to fail against expected `"35625"` even though they're numerically equal. ## Changes - **New `createQueryFloatServerTests` helper**: Uses `parseFloat()` for numeric comparison instead of string equality for float query param scenarios - **New `createHeaderFloatServerTests` helper**: Same numeric comparison approach for float header scenarios - **Updated 8 scenarios** to use the new float helpers — the ones where whole-number float values create representation ambiguity: - `floatMilliseconds` / `float64Milliseconds` (35625) - `floatSecondsLargerUnit` (150) - `floatMillisecondsLargerUnit` (210000) Non-float scenarios (int32, iso8601) and non-ambiguous floats like `35.625` are unchanged — their string comparison remains appropriate. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[Bug]: mockapi in e2e test, logic to compare float is not correct</issue_title> > <issue_description>### Describe the bug > > mockapi in test https://github.com/microsoft/typespec/blob/main/packages/http-specs/specs/encode/duration/mockapi.ts > > On test of duration as float, in query param and header param, it compares with e.g. `35625`, which fails other same float value of `35625.0` etc. > > Please fix these mockapi, to make it compare the float number (not its string representation). > > ### Reproduction > > run test with e.g. `35625.0` as input > > ### Checklist > > - [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md) > - [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate. > - [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions). > - [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9944 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/typespec/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
For Azure/azure-sdk-for-java#48323 (comment) The only service affected, in SDK, is sdk/neonpostgres Azure/azure-sdk-for-java#48334 The change is from `branche` to `branch`, which is correct. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…icrosoft#9964) The `@clientOption("includeRootSlash")` decorator was a workaround in the Python emitter to control stripping the leading slash from operation paths. This is a TypeSpec core concern and should not be solved via a custom decorator. - Removed `getClientOptions` import (only consumer) - Removed the client hierarchy walk that resolved the `includeRootSlash` option - Simplified URL to use `operation.path` directly instead of conditionally stripping the leading slash <!-- START COPILOT CODING AGENT TIPS --> --- 💡 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](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com> Co-authored-by: Chenjie Shi <tadelesh.shi@live.cn>
…#9960) Configure git user.name and user.email on the freshly initialized repo so commits succeed in CI environments without a global git identity. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ns and nonresource.nonresourceoperations.create (microsoft#9977) Adds missing e2e test coverage for two ARM Spector scenarios in the http-client-java test suite. ## Changes - **`MethodSubscriptionIdTest.java`** — adds `testOperationsList()` to cover the `azure.resourcemanager.methodsubscriptionid.operations` scenario: calls `manager.operations().list()` and asserts the returned operation name, `isDataAction`, and display fields against the expected Spector mock response. - **`NonResourceTests.java`** — adds `testNonResourceCreate()` to cover the `azure.resourcemanager.nonresource.nonresourceoperations.create` scenario: uses the low-level fluent client (`manager.serviceClient().getNonResourceOperations().create(...)`) directly, since the high-level model mistakenly treats `NonResource` as an ARM resource (same reason the existing `testNonResourcePut()` is `@Disabled`). ```java // NonResource create — goes via low-level client to bypass incorrect resource treatment NonResourceInner body = new NonResourceInner().withId("id").withName("hello").withType("nonResource"); NonResourceInner result = manager.serviceClient().getNonResourceOperations().create("eastus", "hello", body); Assertions.assertEquals("id", result.id()); Assertions.assertEquals("hello", result.name()); Assertions.assertEquals("nonResource", result.type()); ``` <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
…ty collections during deserialization (microsoft#9968) When a service returns an empty XML wrapper element (e.g., `<Blobs />`), unwrapped list properties deserialize to `null` because the list is only initialized inside the foreach loop upon matching a child element. For required, non-nullable properties this should yield an empty list. ### Changes - **`MrwSerializationTypeDefinition.cs`**: In `GetPropertyVariableDeclarations()`, added `IsXmlUnwrappedRequiredCollection` helper that initializes unwrapped, required, non-nullable collection properties with `new List<T>()` at variable declaration time instead of `default` - **`MrwSerializationTypeDefinition.Xml.cs`**: In `CreateXmlDeserializeListAssignment()`, added `isPreInitialized` parameter to skip the redundant `if (list == null)` null-check when the list is already initialized at declaration time - **`XmlDeserializationTests.cs`**: Added `XmlDeserializationMethodHandlesOptionalUnwrappedListProperty` test using `FilteredMethodsTypeProvider` to verify optional properties retain the null-check and are not affected - **Test data / regenerated code**: Updated expected output and regenerated `XmlAdvancedModel.Serialization.cs` ### Generated output ```csharp // Variable initialized at declaration instead of default IList<string> colors = new List<string>(); IDictionary<string, BinaryData> additionalBinaryDataProperties = new ChangeTrackingDictionary<string, BinaryData>(); foreach (var child in element.Elements()) { string localName = child.Name.LocalName; if (localName == "colors") { // No null check needed — colors is already initialized colors.Add((string)child); continue; } } return new TestXmlModel(colors, additionalBinaryDataProperties); ``` <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Always Initialize Non-Optional Unwrapped Items in XML Deserialization</issue_title> > <issue_description>Consider this tsp: > > ``` > @Xml.name("EnumerationResults") > model ListBlobsResponse { > /** The service endpoint. */ > @Xml.attribute > @Xml.name("ServiceEndpoint") > serviceEndpoint: string; > > /** The container name. */ > @Xml.attribute > @Xml.name("ContainerName") > containerName: string; > > /** The prefix of the blobs. */ > @Xml.name("Prefix") prefix?: string; > > /** The marker of the blobs. */ > @Xml.name("Marker") marker?: string; > > /** The max results of the blobs. */ > @Xml.name("MaxResults") maxResults?: int32; > > /** The blob segment. */ > @Xml.name("Blobs") > segment: BlobFlatListSegment; > > /** The next marker of the blobs. */ > @continuationToken > @Xml.name("NextMarker") > nextMarker?: string; > } > > /** The blob flat list segment. */ > model BlobFlatListSegment { > /** The blob items. */ > @pageItems > @Xml.name("Blob") > @Xml.unwrapped > blobItems: BlobItem[]; > } > > ``` > > The service can returns `<Blobs />` and the current XML deserialization code will deserialize segment into `null` since there are no Blob elements in `Blobs`. Since blobItems is unwrapped and non-nullable, we should be initializing it to an empty list by default. > > We should update the xml deserialization to initialize collection properties to an empty collection when they are non-nullable, required, and unwrapped.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9967 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/typespec/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…roviderWriter.WriteEnumContent (microsoft#9947) - [x] Add attribute rendering for enum fields in `TypeProviderWriter.WriteEnumContent()` - [x] Add test to validate enum field attributes are written correctly - [x] Add test data file for the new test - [x] Run tests to validate changes (all 4 TypeProviderWriter tests pass) - [x] Revert unrelated formatting/header changes from `dotnet format` - [x] Run code review and security scanning <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[http-client-csharp] TypeProviderWriter.WriteEnumContent does not render field attributes on enum members</issue_title> > <issue_description>## Bug Description > > `TypeProviderWriter.WriteEnumContent()` iterates over `_provider.Fields` to write enum members, but it only writes `XmlDocs`, `Name`, and `InitializationValue`. It **never writes `field.Attributes`**, even though `FieldProvider` supports them and `WriteField()` (used for class/struct fields) does render attributes. > > This means any attributes added to enum fields via `BuildFields()` in a custom `EnumProvider` are silently dropped during code generation. > > ## Reproduction > > 1. Create a custom `EnumProvider` that overrides `BuildFields()` and adds attributes to enum field providers (e.g., `[DataMember(Name = "...")]`). > 2. Run code generation. > 3. The generated `.cs` file will **not** contain the attributes on enum members. > > ## Root Cause > > In [`TypeProviderWriter.cs` line 112-132](https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Primitives/TypeProviderWriter.cs#L112-L132): > > ```csharp > private void WriteEnumContent(CodeWriter writer) > { > using (writer.Scope()) > { > for (int i = 0; i < _provider.Fields.Count; i++) > { > writer.WriteXmlDocsNoScope(_provider.Fields[i].XmlDocs); > // Missing: field.Attributes are never written here > writer.Append($"{_provider.Fields[i].Name}"); > ... > } > } > } > ``` > > Compare with [`WriteField()` in `CodeWriter.cs`](https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Writers/CodeWriter.cs#L482-L492) which does render attributes: > > ```csharp > public CodeWriter WriteField(FieldProvider field) > { > WriteXmlDocsNoScope(field.XmlDocs); > if (field.Attributes.Count > 0) > { > foreach (var attr in field.Attributes) > { > attr.Write(this); > } > } > ... > } > ``` > > ## Suggested Fix > > Add attribute rendering in `WriteEnumContent` before writing the field name: > > ```csharp > writer.WriteXmlDocsNoScope(_provider.Fields[i].XmlDocs); > foreach (var attr in _provider.Fields[i].Attributes) > { > attr.Write(writer); > } > writer.Append($"{_provider.Fields[i].Name}"); > ``` > > ## Impact > > This blocks downstream generators (e.g., Azure Provisioning generator) from adding `[DataMember(Name = "...")]` or other custom attributes to enum members for serialization purposes.</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes microsoft#9946 <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com> Co-authored-by: Dapeng Zhang <dapzhang@microsoft.com>
…icrosoft#9987) moved from microsoft#9953 Follow-up to microsoft#9785: the `putExtensibleStringValue` operation was missing an explicit response content-type header, inconsistent with the pattern used by other extensible enum endpoints. - Updated return type in `packages/http-specs/specs/special-words/main.tsp`: ```typespec putExtensibleStringValue(@Body body: ExtensibleString): { @Header contentType: "application/json"; @Body body: ExtensibleString; }; ``` > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `telemetry.astro.build` > - Triggering command: `/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/typespec/typespec/website/node_modules/.bin/../astro/astro.js build sh s/.b�� ../../website/sr--llmstxt sh _modules/pnpm/dist/node-gyp-bin/node --no-emit git _modules/pnpm/digenerate-scenarios-summary node tobu�� build.json sh /.bin/sh ld.json && pnpm node pnpm tobuf/reference node` (dns block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/microsoft/typespec/settings/copilot/coding_agent) (admins only) > > </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/microsoft/typespec/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.