Skip to content

Conversation

@jorgerangel-msft
Copy link
Contributor

@jorgerangel-msft jorgerangel-msft commented Jan 30, 2026

Adds the initial XML deserialization support for models using MRW.

contributes to: Azure/azure-sdk-for-net#48062, #5656
fixes: #5646

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jan 30, 2026
@github-actions
Copy link
Contributor

No changes needing a change description found.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 30, 2026

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/http@9545
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client@9545
npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client-csharp@9545

commit: 557b5ad

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 30, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@jorgerangel-msft jorgerangel-msft force-pushed the xml-deserialization branch 11 times, most recently from a4f2fa6 to 22a3f76 Compare February 2, 2026 23:07
@jorgerangel-msft jorgerangel-msft changed the title [wip]: Add XML Model Deserialization Support Add XML Model Deserialization Support Feb 2, 2026
=> element.Property(nameof(XElement.Value)).As<string>();

public static ScopedApi<IEnumerable<XAttribute>> Attributes(this ScopedApi<XElement> element)
=> element.Invoke(nameof(XElement.Attributes)).As<IEnumerable<XAttribute>>();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: new line

{
public partial class MockInputModel : global::Sample.Models.MockInputModelBase, global::System.ClientModel.Primitives.IJsonModel<global::Sample.Models.MockInputModel>
{
protected override global::Sample.Models.MockInputModelBase PersistableModelCreateCore(global::System.BinaryData data, global::System.ClientModel.Primitives.ModelReaderWriterOptions options)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm is there a reason the ordering changed?

}

@route("/plants")
interface PlantOperations {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have at least one model that is used as both JSON and XML?

public bool IsHttpMetadata { get; }
public bool IsApiVersion { get; }
internal FormattableString? Description { get; }
public XmlWireInformation? XmlWireInformation { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels a little odd to have an XmlWireInformation property in MTG when we don't even have one for JSON here. Would it be reasonable to just store off the SerializationOptions so it is a bit more generic?

{
public class XmlWireInformation
{
public XmlWireInformation(InputXmlSerializationOptions xmlOptions)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can collapse this into MRWTypeDefinition.Xml

{
public class XmlWireNamespaceOptions
{
public XmlWireNamespaceOptions(InputXmlNamespaceOptions options)
Copy link
Contributor

@JoshLove-msft JoshLove-msft Feb 2, 2026

Choose a reason for hiding this comment

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

Is the XmlNamespaceOptions emitted already by the emitter? I think it would be nice if we could wrap this into the Xml serialization options and do away with InputXmlNamespaceOptions. I believe these options are still applied at the model property level but I may be missing something.

optionalInt?: int32;

@doc("A nullable string")
nullableString: string | null;
Copy link
Contributor

@JoshLove-msft JoshLove-msft Feb 3, 2026

Choose a reason for hiding this comment

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

Can we add the namespace options on a few properties?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement XML deserialization

3 participants