From 0bac6e4c0b026d83d0ae7ab903312e32a255e00f Mon Sep 17 00:00:00 2001 From: Wenming Liu Date: Mon, 11 Nov 2024 14:25:17 +0800 Subject: [PATCH] Enable-WriteCore-for-Azure.AI.Translation.Document-REWOR --- .../Azure.AI.Translation.Document/CHANGELOG.md | 2 ++ .../Azure.AI.Translation.Document.netstandard2.0.cs | 12 +++++++++++- .../src/DocumentTranslateContent.Serialization.cs | 6 +++--- .../src/Generated/DocumentFilter.Serialization.cs | 11 +++++++++-- .../Generated/DocumentStatusResult.Serialization.cs | 11 +++++++++-- .../DocumentTranslateContent.Serialization.cs | 7 +++++++ .../DocumentTranslationFileFormat.Serialization.cs | 11 +++++++++-- .../DocumentTranslationInput.Serialization.cs | 11 +++++++++-- .../Generated/SupportedFileFormats.Serialization.cs | 11 +++++++++-- .../src/Generated/TranslationBatch.Serialization.cs | 11 +++++++++-- .../Generated/TranslationGlossary.Serialization.cs | 11 +++++++++-- .../src/Generated/TranslationSource.Serialization.cs | 11 +++++++++-- .../TranslationStatusResult.Serialization.cs | 11 +++++++++-- .../TranslationStatusSummary.Serialization.cs | 11 +++++++++-- .../src/Generated/TranslationTarget.Serialization.cs | 11 +++++++++-- .../Azure.AI.Translation.Document/tsp-location.yaml | 2 +- 16 files changed, 123 insertions(+), 27 deletions(-) diff --git a/sdk/translation/Azure.AI.Translation.Document/CHANGELOG.md b/sdk/translation/Azure.AI.Translation.Document/CHANGELOG.md index cfecdd4e791b7..65463f191b7a8 100644 --- a/sdk/translation/Azure.AI.Translation.Document/CHANGELOG.md +++ b/sdk/translation/Azure.AI.Translation.Document/CHANGELOG.md @@ -3,6 +3,8 @@ ### Features Added +- Exposed `JsonModelWriteCore` for model serialization procedure. + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs index 4c8944a2a97ff..98803e3c27714 100644 --- a/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs +++ b/sdk/translation/Azure.AI.Translation.Document/api/Azure.AI.Translation.Document.netstandard2.0.cs @@ -23,6 +23,7 @@ internal DocumentStatusResult() { } public System.Uri TranslatedDocumentUri { get { throw null; } } public string TranslatedToLanguageCode { get { throw null; } } public float TranslationProgressPercentage { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.DocumentStatusResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.DocumentStatusResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -35,8 +36,9 @@ public DocumentTranslateContent(Azure.AI.Translation.Document.MultipartFormFileD public DocumentTranslateContent(Azure.AI.Translation.Document.MultipartFormFileData document, System.Collections.Generic.IList glossaries) { } public Azure.AI.Translation.Document.MultipartFormFileData MultipartDocument { get { throw null; } } public System.Collections.Generic.IList MultipartGlossary { get { throw null; } } - void global::System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.DocumentTranslateContent System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.DocumentTranslateContent System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -129,6 +131,7 @@ internal DocumentTranslationFileFormat() { } public string Format { get { throw null; } } public System.Collections.Generic.IReadOnlyList FormatVersions { get { throw null; } } public Azure.AI.Translation.Document.FileFormatType? Type { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.DocumentTranslationFileFormat System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.DocumentTranslationFileFormat System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -143,6 +146,7 @@ public DocumentTranslationInput(System.Uri sourceUri, System.Uri targetUri, stri public Azure.AI.Translation.Document.StorageInputUriKind? StorageUriKind { get { throw null; } set { } } public System.Collections.Generic.IList Targets { get { throw null; } } public void AddTarget(System.Uri targetUri, string languageCode, Azure.AI.Translation.Document.TranslationGlossary glossary = null, string categoryId = null) { } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.DocumentTranslationInput System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.DocumentTranslationInput System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -285,6 +289,7 @@ public partial class SupportedFileFormats : System.ClientModel.Primitives.IJsonM { internal SupportedFileFormats() { } public System.Collections.Generic.IReadOnlyList Value { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.SupportedFileFormats System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.SupportedFileFormats System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -295,6 +300,7 @@ public partial class TranslationBatch : System.ClientModel.Primitives.IJsonModel { public TranslationBatch(System.Collections.Generic.IEnumerable inputs) { } public System.Collections.Generic.IList Inputs { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationBatch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationBatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -318,6 +324,7 @@ public TranslationGlossary(System.Uri glossaryUri, string format) { } public string FormatVersion { get { throw null; } set { } } public System.Uri GlossaryUri { get { throw null; } } public Azure.AI.Translation.Document.TranslationStorageSource? StorageSource { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationGlossary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationGlossary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -333,6 +340,7 @@ public TranslationSource(System.Uri sourceUri, string languageCode = null, strin public System.Uri SourceUri { get { throw null; } } public Azure.AI.Translation.Document.TranslationStorageSource? StorageSource { get { throw null; } set { } } public string Suffix { get { throw null; } set { } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationSource System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationSource System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -354,6 +362,7 @@ internal TranslationStatusResult() { } public System.DateTimeOffset LastModified { get { throw null; } } public Azure.AI.Translation.Document.DocumentTranslationStatus Status { get { throw null; } } public long TotalCharactersCharged { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationStatusResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationStatusResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -385,6 +394,7 @@ public TranslationTarget(System.Uri targetUri, string languageCode) { } public string LanguageCode { get { throw null; } } public Azure.AI.Translation.Document.TranslationStorageSource? StorageSource { get { throw null; } set { } } public System.Uri TargetUri { get { throw null; } } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationTarget System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.AI.Translation.Document.TranslationTarget System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } diff --git a/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslateContent.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslateContent.Serialization.cs index c66c5bc33f89d..9933748a58f50 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslateContent.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/DocumentTranslateContent.Serialization.cs @@ -27,7 +27,9 @@ internal virtual MultipartFormDataRequestContent ToMultipartRequestContent() return content; } - void global::System.ClientModel.Primitives.IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -35,7 +37,6 @@ internal virtual MultipartFormDataRequestContent ToMultipartRequestContent() throw new FormatException($"The model {nameof(DocumentTranslateContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("document"u8); #if NET6_0_OR_GREATER writer.WriteRawValue(global::System.BinaryData.FromStream(Document)); @@ -82,7 +83,6 @@ internal virtual MultipartFormDataRequestContent ToMultipartRequestContent() #endif } } - writer.WriteEndObject(); } internal static DocumentTranslateContent DeserializeDocumentTranslateContent(JsonElement element, ModelReaderWriterOptions options = null) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentFilter.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentFilter.Serialization.cs index 6cf63ba4fa904..ec48a6cb110ae 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentFilter.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentFilter.Serialization.cs @@ -18,6 +18,15 @@ internal partial class DocumentFilter : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp throw new FormatException($"The model {nameof(DocumentFilter)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Prefix)) { writer.WritePropertyName("prefix"u8); @@ -51,7 +59,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp #endif } } - writer.WriteEndObject(); } DocumentFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.Serialization.cs index b86f5dd40c523..4dc36aa9d1417 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentStatusResult.Serialization.cs @@ -18,6 +18,15 @@ public partial class DocumentStatusResult : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr throw new FormatException($"The model {nameof(DocumentStatusResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(TranslatedDocumentUri)) { writer.WritePropertyName("path"u8); @@ -67,7 +75,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr #endif } } - writer.WriteEndObject(); } DocumentStatusResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslateContent.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslateContent.Serialization.cs index b0d980dda6307..c8e344cf84ee0 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslateContent.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslateContent.Serialization.cs @@ -17,6 +17,13 @@ public partial class DocumentTranslateContent : IUtf8JsonSerializable, IJsonMode { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + DocumentTranslateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationFileFormat.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationFileFormat.Serialization.cs index ce54796127f1c..f7e6bc276bcda 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationFileFormat.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationFileFormat.Serialization.cs @@ -18,6 +18,15 @@ public partial class DocumentTranslationFileFormat : IUtf8JsonSerializable, IJso void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode throw new FormatException($"The model {nameof(DocumentTranslationFileFormat)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("format"u8); writer.WriteStringValue(Format); writer.WritePropertyName("fileExtensions"u8); @@ -77,7 +85,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode #endif } } - writer.WriteEndObject(); } DocumentTranslationFileFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationInput.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationInput.Serialization.cs index 6b2a34493ea93..760b68da84c36 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationInput.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/DocumentTranslationInput.Serialization.cs @@ -18,6 +18,15 @@ public partial class DocumentTranslationInput : IUtf8JsonSerializable, IJsonMode void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead throw new FormatException($"The model {nameof(DocumentTranslationInput)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("source"u8); writer.WriteObjectValue(Source, options); writer.WritePropertyName("targets"u8); @@ -55,7 +63,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead #endif } } - writer.WriteEndObject(); } DocumentTranslationInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/SupportedFileFormats.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/SupportedFileFormats.Serialization.cs index 29840a486129a..325560f8e7d95 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/SupportedFileFormats.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/SupportedFileFormats.Serialization.cs @@ -18,6 +18,15 @@ public partial class SupportedFileFormats : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr throw new FormatException($"The model {nameof(SupportedFileFormats)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr #endif } } - writer.WriteEndObject(); } SupportedFileFormats IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.Serialization.cs index 49bf3926d1f92..c7c031cb03295 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationBatch.Serialization.cs @@ -18,6 +18,15 @@ public partial class TranslationBatch : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(TranslationBatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("inputs"u8); writer.WriteStartArray(); foreach (var item in Inputs) @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter #endif } } - writer.WriteEndObject(); } TranslationBatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationGlossary.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationGlossary.Serialization.cs index 6e89d7cf20504..4f6aef207c85d 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationGlossary.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationGlossary.Serialization.cs @@ -18,6 +18,15 @@ public partial class TranslationGlossary : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(TranslationGlossary)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("glossaryUrl"u8); writer.WriteStringValue(GlossaryUri.AbsoluteUri); writer.WritePropertyName("format"u8); @@ -55,7 +63,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri #endif } } - writer.WriteEndObject(); } TranslationGlossary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationSource.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationSource.Serialization.cs index 37eabdb6a1e9a..75e34a70d0db9 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationSource.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationSource.Serialization.cs @@ -18,6 +18,15 @@ public partial class TranslationSource : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite throw new FormatException($"The model {nameof(TranslationSource)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("sourceUrl"u8); writer.WriteStringValue(SourceUri.AbsoluteUri); if (Optional.IsDefined(Filter)) @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite #endif } } - writer.WriteEndObject(); } TranslationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusResult.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusResult.Serialization.cs index 13dbec93c0abd..a9b1bf87bc5b6 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusResult.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusResult.Serialization.cs @@ -18,6 +18,15 @@ public partial class TranslationStatusResult : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade throw new FormatException($"The model {nameof(TranslationStatusResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("id"u8); writer.WriteStringValue(Id); writer.WritePropertyName("createdDateTimeUtc"u8); @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade #endif } } - writer.WriteEndObject(); } TranslationStatusResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.Serialization.cs index c07ff6f85e776..bdb7206c31766 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationStatusSummary.Serialization.cs @@ -18,6 +18,15 @@ internal partial class TranslationStatusSummary : IUtf8JsonSerializable, IJsonMo void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead throw new FormatException($"The model {nameof(TranslationStatusSummary)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("total"u8); writer.WriteNumberValue(Total); writer.WritePropertyName("failed"u8); @@ -55,7 +63,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead #endif } } - writer.WriteEndObject(); } TranslationStatusSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationTarget.Serialization.cs b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationTarget.Serialization.cs index d04acbc73c5f7..cafecba71fe1f 100644 --- a/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationTarget.Serialization.cs +++ b/sdk/translation/Azure.AI.Translation.Document/src/Generated/TranslationTarget.Serialization.cs @@ -18,6 +18,15 @@ public partial class TranslationTarget : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite throw new FormatException($"The model {nameof(TranslationTarget)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("targetUrl"u8); writer.WriteStringValue(TargetUri.AbsoluteUri); if (Optional.IsDefined(CategoryId)) @@ -65,7 +73,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite #endif } } - writer.WriteEndObject(); } TranslationTarget IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/sdk/translation/Azure.AI.Translation.Document/tsp-location.yaml b/sdk/translation/Azure.AI.Translation.Document/tsp-location.yaml index d24a8e80f9e1c..b9a83047f8618 100644 --- a/sdk/translation/Azure.AI.Translation.Document/tsp-location.yaml +++ b/sdk/translation/Azure.AI.Translation.Document/tsp-location.yaml @@ -1,3 +1,3 @@ directory: specification/translation/Azure.AI.DocumentTranslation -commit: a3920ed4082bec9544ac1ae75fc8abba363be7d0 +commit: 90f2533e6f95f3ec88074cbb516b205061ea2d38 repo: Azure/azure-rest-api-specs