diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/Configuration.json b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/Configuration.json
new file mode 100644
index 000000000000..30deaa8da171
--- /dev/null
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/Configuration.json
@@ -0,0 +1,12 @@
+{
+ "package-name": "Azure.AI.Language.QuestionAnswering.Inference",
+ "namespace": "Azure.AI.Language.QuestionAnswering.Inference",
+ "model-namespace": false,
+ "license": {
+ "name": "MIT License",
+ "company": "Microsoft Corporation",
+ "link": "https://mit-license.org",
+ "header": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.",
+ "description": "Copyright (c) Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE."
+ }
+}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/AnswersOptions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/AnswersOptions.cs
index bce225e59ad2..26272b8ebab7 100644
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/AnswersOptions.cs
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/AnswersOptions.cs
@@ -1,8 +1,9 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using Azure.Core;
+using Microsoft.TypeSpec.Generator.Customizations;
namespace Azure.AI.Language.QuestionAnswering.Inference
{
@@ -16,7 +17,9 @@ public partial class AnswersOptions
/// is null.
internal AnswersOptions WithQuestion(string question)
{
- Question = Argument.CheckNotNullOrEmpty(question, nameof(question));
+ Argument.AssertNotNullOrEmpty(question, nameof(question));
+
+ Question = question;
return this;
}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Azure.AI.Language.QuestionAnswering.Inference.csproj b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Azure.AI.Language.QuestionAnswering.Inference.csproj
index 4d7fb4a29119..8eba955ab8aa 100644
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Azure.AI.Language.QuestionAnswering.Inference.csproj
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Azure.AI.Language.QuestionAnswering.Inference.csproj
@@ -6,18 +6,16 @@
Azure Inference
$(RequiredTargetFrameworks)
true
- true
Azure.AI.Language.QuestionAnswering.Inference
Azure.AI.Language.QuestionAnswering.Inference
$(NoWarn);AZC0034;AZC0012
-
-
-
-
+
+
+
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswerSpan.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswerSpan.cs
deleted file mode 100644
index 1cc905357a6a..000000000000
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswerSpan.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-
-namespace Azure.AI.Language.QuestionAnswering.Inference
-{
- /// Answer span object of QnA.
- public partial class AnswerSpan
- {
- ///
- /// Keeps track of any properties unknown to the library.
- ///
- /// To assign an object to the value of this property use .
- ///
- ///
- /// To assign an already formatted json string to this property use .
- ///
- ///
- /// Examples:
- ///
- /// -
- /// BinaryData.FromObjectAsJson("foo")
- /// Creates a payload of "foo".
- ///
- /// -
- /// BinaryData.FromString("\"foo\"")
- /// Creates a payload of "foo".
- ///
- /// -
- /// BinaryData.FromObjectAsJson(new { key = "value" })
- /// Creates a payload of { "key": "value" }.
- ///
- /// -
- /// BinaryData.FromString("{\"key\": \"value\"}")
- /// Creates a payload of { "key": "value" }.
- ///
- ///
- ///
- ///
- private IDictionary _serializedAdditionalRawData;
-
- /// Initializes a new instance of .
- internal AnswerSpan()
- {
- }
-
- /// Initializes a new instance of .
- /// Predicted text of answer span.
- /// Predicted score of answer span, value ranges from 0 to 1.
- /// The answer span offset from the start of answer.
- /// The length of the answer span.
- /// Keeps track of any properties unknown to the library.
- internal AnswerSpan(string text, double? confidence, int? offset, int? length, IDictionary serializedAdditionalRawData)
- {
- Text = text;
- Confidence = confidence;
- Offset = offset;
- Length = length;
- _serializedAdditionalRawData = serializedAdditionalRawData;
- }
-
- /// Predicted text of answer span.
- public string Text { get; }
- /// Predicted score of answer span, value ranges from 0 to 1.
- public double? Confidence { get; }
- /// The answer span offset from the start of answer.
- public int? Offset { get; }
- /// The length of the answer span.
- public int? Length { get; }
- }
-}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswersFromTextResult.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswersFromTextResult.cs
deleted file mode 100644
index 2eaef581fc89..000000000000
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswersFromTextResult.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-
-namespace Azure.AI.Language.QuestionAnswering.Inference
-{
- /// Represents the answer results.
- public partial class AnswersFromTextResult
- {
- ///
- /// Keeps track of any properties unknown to the library.
- ///
- /// To assign an object to the value of this property use .
- ///
- ///
- /// To assign an already formatted json string to this property use .
- ///
- ///
- /// Examples:
- ///
- /// -
- /// BinaryData.FromObjectAsJson("foo")
- /// Creates a payload of "foo".
- ///
- /// -
- /// BinaryData.FromString("\"foo\"")
- /// Creates a payload of "foo".
- ///
- /// -
- /// BinaryData.FromObjectAsJson(new { key = "value" })
- /// Creates a payload of { "key": "value" }.
- ///
- /// -
- /// BinaryData.FromString("{\"key\": \"value\"}")
- /// Creates a payload of { "key": "value" }.
- ///
- ///
- ///
- ///
- private IDictionary _serializedAdditionalRawData;
-
- /// Initializes a new instance of .
- internal AnswersFromTextResult()
- {
- Answers = new ChangeTrackingList();
- }
-
- /// Initializes a new instance of .
- /// Represents the answer results.
- /// Keeps track of any properties unknown to the library.
- internal AnswersFromTextResult(IReadOnlyList answers, IDictionary serializedAdditionalRawData)
- {
- Answers = answers;
- _serializedAdditionalRawData = serializedAdditionalRawData;
- }
-
- /// Represents the answer results.
- public IReadOnlyList Answers { get; }
- }
-}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswersResult.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswersResult.cs
deleted file mode 100644
index 6185001b9b76..000000000000
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/AnswersResult.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-
-namespace Azure.AI.Language.QuestionAnswering.Inference
-{
- /// Represents List of Question Answers.
- public partial class AnswersResult
- {
- ///
- /// Keeps track of any properties unknown to the library.
- ///
- /// To assign an object to the value of this property use .
- ///
- ///
- /// To assign an already formatted json string to this property use .
- ///
- ///
- /// Examples:
- ///
- /// -
- /// BinaryData.FromObjectAsJson("foo")
- /// Creates a payload of "foo".
- ///
- /// -
- /// BinaryData.FromString("\"foo\"")
- /// Creates a payload of "foo".
- ///
- /// -
- /// BinaryData.FromObjectAsJson(new { key = "value" })
- /// Creates a payload of { "key": "value" }.
- ///
- /// -
- /// BinaryData.FromString("{\"key\": \"value\"}")
- /// Creates a payload of { "key": "value" }.
- ///
- ///
- ///
- ///
- private IDictionary _serializedAdditionalRawData;
-
- /// Initializes a new instance of .
- internal AnswersResult()
- {
- Answers = new ChangeTrackingList();
- }
-
- /// Initializes a new instance of .
- /// Represents Answer Result list.
- /// Keeps track of any properties unknown to the library.
- internal AnswersResult(IReadOnlyList answers, IDictionary serializedAdditionalRawData)
- {
- Answers = answers;
- _serializedAdditionalRawData = serializedAdditionalRawData;
- }
-
- /// Represents Answer Result list.
- public IReadOnlyList Answers { get; }
- }
-}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/Argument.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/Argument.cs
index eb4d6a4daa93..c26ac55d13d5 100644
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/Argument.cs
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/Argument.cs
@@ -11,8 +11,10 @@
namespace Azure.AI.Language.QuestionAnswering.Inference
{
- internal static class Argument
+ internal static partial class Argument
{
+ /// The value.
+ /// The name.
public static void AssertNotNull(T value, string name)
{
if (value is null)
@@ -21,8 +23,10 @@ public static void AssertNotNull(T value, string name)
}
}
+ /// The value.
+ /// The name.
public static void AssertNotNull(T? value, string name)
- where T : struct
+ where T : struct
{
if (!value.HasValue)
{
@@ -30,6 +34,8 @@ public static void AssertNotNull(T? value, string name)
}
}
+ /// The value.
+ /// The name.
public static void AssertNotNullOrEmpty(IEnumerable value, string name)
{
if (value is null)
@@ -51,6 +57,8 @@ public static void AssertNotNullOrEmpty(IEnumerable value, string name)
}
}
+ /// The value.
+ /// The name.
public static void AssertNotNullOrEmpty(string value, string name)
{
if (value is null)
@@ -62,68 +70,5 @@ public static void AssertNotNullOrEmpty(string value, string name)
throw new ArgumentException("Value cannot be an empty string.", name);
}
}
-
- public static void AssertNotNullOrWhiteSpace(string value, string name)
- {
- if (value is null)
- {
- throw new ArgumentNullException(name);
- }
- if (string.IsNullOrWhiteSpace(value))
- {
- throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name);
- }
- }
-
- public static void AssertNotDefault(ref T value, string name)
- where T : struct, IEquatable
- {
- if (value.Equals(default))
- {
- throw new ArgumentException("Value cannot be empty.", name);
- }
- }
-
- public static void AssertInRange(T value, T minimum, T maximum, string name)
- where T : notnull, IComparable
- {
- if (minimum.CompareTo(value) > 0)
- {
- throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed.");
- }
- if (maximum.CompareTo(value) < 0)
- {
- throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed.");
- }
- }
-
- public static void AssertEnumDefined(Type enumType, object value, string name)
- {
- if (!Enum.IsDefined(enumType, value))
- {
- throw new ArgumentException($"Value not defined for {enumType.FullName}.", name);
- }
- }
-
- public static T CheckNotNull(T value, string name)
- where T : class
- {
- AssertNotNull(value, name);
- return value;
- }
-
- public static string CheckNotNullOrEmpty(string value, string name)
- {
- AssertNotNullOrEmpty(value, name);
- return value;
- }
-
- public static void AssertNull(T value, string name, string message = null)
- {
- if (value != null)
- {
- throw new ArgumentException(message ?? "Value must be null.", name);
- }
- }
}
}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CancellationTokenExtensions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CancellationTokenExtensions.cs
new file mode 100644
index 000000000000..dd3b7d7fa565
--- /dev/null
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CancellationTokenExtensions.cs
@@ -0,0 +1,17 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Threading;
+using Azure;
+
+namespace Azure.AI.Language.QuestionAnswering.Inference
+{
+ internal static partial class CancellationTokenExtensions
+ {
+ public static RequestContext ToRequestContext(this CancellationToken cancellationToken) => cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null;
+ }
+}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ChangeTrackingDictionary.cs
index 5ee6ec3515f4..1075bca7d919 100644
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ChangeTrackingDictionary.cs
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ChangeTrackingDictionary.cs
@@ -11,7 +11,8 @@
namespace Azure.AI.Language.QuestionAnswering.Inference
{
- internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull
+ internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary
+ where TKey : notnull
{
private IDictionary _innerDictionary;
@@ -19,6 +20,7 @@ public ChangeTrackingDictionary()
{
}
+ /// The inner dictionary.
public ChangeTrackingDictionary(IDictionary dictionary)
{
if (dictionary == null)
@@ -28,6 +30,7 @@ public ChangeTrackingDictionary(IDictionary dictionary)
_innerDictionary = new Dictionary(dictionary);
}
+ /// The inner dictionary.
public ChangeTrackingDictionary(IReadOnlyDictionary dictionary)
{
if (dictionary == null)
@@ -41,16 +44,22 @@ public ChangeTrackingDictionary(IReadOnlyDictionary dictionary)
}
}
+ /// Gets the IsUndefined.
public bool IsUndefined => _innerDictionary == null;
+ /// Gets the Count.
public int Count => IsUndefined ? 0 : EnsureDictionary().Count;
+ /// Gets the IsReadOnly.
public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly;
+ /// Gets the Keys.
public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys;
+ /// Gets the Values.
public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values;
+ /// Gets or sets the value associated with the specified key.
public TValue this[TKey key]
{
get
@@ -67,8 +76,10 @@ public TValue this[TKey key]
}
}
+ /// Gets the Keys.
IEnumerable IReadOnlyDictionary.Keys => Keys;
+ /// Gets the Values.
IEnumerable IReadOnlyDictionary.Values => Values;
public IEnumerator> GetEnumerator()
@@ -89,6 +100,7 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}
+ /// The item to add.
public void Add(KeyValuePair item)
{
EnsureDictionary().Add(item);
@@ -99,6 +111,7 @@ public void Clear()
EnsureDictionary().Clear();
}
+ /// The item to search for.
public bool Contains(KeyValuePair item)
{
if (IsUndefined)
@@ -108,6 +121,8 @@ public bool Contains(KeyValuePair item)
return EnsureDictionary().Contains(item);
}
+ /// The array to copy.
+ /// The index.
public void CopyTo(KeyValuePair[] array, int index)
{
if (IsUndefined)
@@ -117,6 +132,7 @@ public void CopyTo(KeyValuePair[] array, int index)
EnsureDictionary().CopyTo(array, index);
}
+ /// The item to remove.
public bool Remove(KeyValuePair item)
{
if (IsUndefined)
@@ -126,11 +142,14 @@ public bool Remove(KeyValuePair item)
return EnsureDictionary().Remove(item);
}
+ /// The key.
+ /// The value to add.
public void Add(TKey key, TValue value)
{
EnsureDictionary().Add(key, value);
}
+ /// The key to search for.
public bool ContainsKey(TKey key)
{
if (IsUndefined)
@@ -140,6 +159,7 @@ public bool ContainsKey(TKey key)
return EnsureDictionary().ContainsKey(key);
}
+ /// The key.
public bool Remove(TKey key)
{
if (IsUndefined)
@@ -149,6 +169,8 @@ public bool Remove(TKey key)
return EnsureDictionary().Remove(key);
}
+ /// The key to search for.
+ /// The value.
public bool TryGetValue(TKey key, out TValue value)
{
if (IsUndefined)
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ChangeTrackingList.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ChangeTrackingList.cs
index bfba88e33ce9..c0cf66a0cd98 100644
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ChangeTrackingList.cs
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ChangeTrackingList.cs
@@ -12,7 +12,7 @@
namespace Azure.AI.Language.QuestionAnswering.Inference
{
- internal class ChangeTrackingList : IList, IReadOnlyList
+ internal partial class ChangeTrackingList : IList, IReadOnlyList
{
private IList _innerList;
@@ -20,6 +20,7 @@ public ChangeTrackingList()
{
}
+ /// The inner list.
public ChangeTrackingList(IList innerList)
{
if (innerList != null)
@@ -28,6 +29,7 @@ public ChangeTrackingList(IList innerList)
}
}
+ /// The inner list.
public ChangeTrackingList(IReadOnlyList innerList)
{
if (innerList != null)
@@ -36,12 +38,16 @@ public ChangeTrackingList(IReadOnlyList innerList)
}
}
+ /// Gets the IsUndefined.
public bool IsUndefined => _innerList == null;
+ /// Gets the Count.
public int Count => IsUndefined ? 0 : EnsureList().Count;
+ /// Gets the IsReadOnly.
public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly;
+ /// Gets or sets the value associated with the specified key.
public T this[int index]
{
get
@@ -85,6 +91,7 @@ IEnumerator IEnumerable.GetEnumerator()
return GetEnumerator();
}
+ /// The item to add.
public void Add(T item)
{
EnsureList().Add(item);
@@ -95,6 +102,7 @@ public void Clear()
EnsureList().Clear();
}
+ /// The item.
public bool Contains(T item)
{
if (IsUndefined)
@@ -104,6 +112,8 @@ public bool Contains(T item)
return EnsureList().Contains(item);
}
+ /// The array to copy to.
+ /// The array index.
public void CopyTo(T[] array, int arrayIndex)
{
if (IsUndefined)
@@ -113,6 +123,7 @@ public void CopyTo(T[] array, int arrayIndex)
EnsureList().CopyTo(array, arrayIndex);
}
+ /// The item.
public bool Remove(T item)
{
if (IsUndefined)
@@ -122,6 +133,7 @@ public bool Remove(T item)
return EnsureList().Remove(item);
}
+ /// The item.
public int IndexOf(T item)
{
if (IsUndefined)
@@ -131,11 +143,14 @@ public int IndexOf(T item)
return EnsureList().IndexOf(item);
}
+ /// The inner list.
+ /// The item.
public void Insert(int index, T item)
{
EnsureList().Insert(index, item);
}
+ /// The inner list.
public void RemoveAt(int index)
{
if (IsUndefined)
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ClientPipelineExtensions.cs
new file mode 100644
index 000000000000..df5dde075af8
--- /dev/null
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ClientPipelineExtensions.cs
@@ -0,0 +1,72 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Threading;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Core;
+using Azure.Core.Pipeline;
+
+namespace Azure.AI.Language.QuestionAnswering.Inference
+{
+ internal static partial class ClientPipelineExtensions
+ {
+ public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context)
+ {
+ (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse();
+ await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false);
+
+ if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow)
+ {
+ throw new RequestFailedException(message.Response);
+ }
+
+ return message.Response;
+ }
+
+ public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context)
+ {
+ (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse();
+ pipeline.Send(message, userCancellationToken);
+
+ if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow)
+ {
+ throw new RequestFailedException(message.Response);
+ }
+
+ return message.Response;
+ }
+
+ public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context)
+ {
+ Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false);
+ switch (response.Status)
+ {
+ case >= 200 and < 300:
+ return Response.FromValue(true, response);
+ case >= 400 and < 500:
+ return Response.FromValue(false, response);
+ default:
+ return new ErrorResult(response, new RequestFailedException(response));
+ }
+ }
+
+ public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context)
+ {
+ Response response = pipeline.ProcessMessage(message, context);
+ switch (response.Status)
+ {
+ case >= 200 and < 300:
+ return Response.FromValue(true, response);
+ case >= 400 and < 500:
+ return Response.FromValue(false, response);
+ default:
+ return new ErrorResult(response, new RequestFailedException(response));
+ }
+ }
+ }
+}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenMemberAttribute.cs
new file mode 100644
index 000000000000..72778edeb7e4
--- /dev/null
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenMemberAttribute.cs
@@ -0,0 +1,20 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Microsoft.TypeSpec.Generator.Customizations
+{
+ [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))]
+ internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute
+ {
+ /// The original name of the member.
+ public CodeGenMemberAttribute(string originalName) : base(originalName)
+ {
+ }
+ }
+}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenSerializationAttribute.cs
new file mode 100644
index 000000000000..dfcabf517497
--- /dev/null
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenSerializationAttribute.cs
@@ -0,0 +1,48 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Microsoft.TypeSpec.Generator.Customizations
+{
+ [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)]
+ internal partial class CodeGenSerializationAttribute : Attribute
+ {
+ /// The property name which these hooks apply to.
+ public CodeGenSerializationAttribute(string propertyName)
+ {
+ PropertyName = propertyName;
+ }
+
+ /// The property name which these hooks apply to.
+ /// The serialization name of the property.
+ public CodeGenSerializationAttribute(string propertyName, string serializationName)
+ {
+ PropertyName = propertyName;
+ SerializationName = serializationName;
+ }
+
+ /// Gets or sets the property name which these hooks should apply to.
+ public string PropertyName { get; }
+
+ /// Gets or sets the serialization name of the property.
+ public string SerializationName { get; set; }
+
+ ///
+ /// Gets or sets the method name to use when serializing the property value (property name excluded).
+ /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer);
+ ///
+ public string SerializationValueHook { get; set; }
+
+ ///
+ /// Gets or sets the method name to use when deserializing the property value from the JSON.
+ /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required
+ /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional
+ ///
+ public string DeserializationValueHook { get; set; }
+ }
+}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenSuppressAttribute.cs
new file mode 100644
index 000000000000..38d536e69173
--- /dev/null
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenSuppressAttribute.cs
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Microsoft.TypeSpec.Generator.Customizations
+{
+ [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)]
+ internal partial class CodeGenSuppressAttribute : Attribute
+ {
+ /// The member to suppress.
+ /// The types of the parameters of the member.
+ public CodeGenSuppressAttribute(string member, params Type[] parameters)
+ {
+ Member = member;
+ Parameters = parameters;
+ }
+
+ /// Gets the Member.
+ public string Member { get; }
+
+ /// Gets the Parameters.
+ public Type[] Parameters { get; }
+ }
+}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenTypeAttribute.cs
new file mode 100644
index 000000000000..f36b5f513173
--- /dev/null
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/CodeGenTypeAttribute.cs
@@ -0,0 +1,24 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+
+namespace Microsoft.TypeSpec.Generator.Customizations
+{
+ [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))]
+ internal partial class CodeGenTypeAttribute : Attribute
+ {
+ /// The original name of the type.
+ public CodeGenTypeAttribute(string originalName)
+ {
+ OriginalName = originalName;
+ }
+
+ /// Gets the OriginalName.
+ public string OriginalName { get; }
+ }
+}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ErrorResult.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ErrorResult.cs
new file mode 100644
index 000000000000..e185b7f18821
--- /dev/null
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ErrorResult.cs
@@ -0,0 +1,32 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using Azure;
+
+namespace Azure.AI.Language.QuestionAnswering.Inference
+{
+ internal partial class ErrorResult : Response
+ {
+ private readonly Response _response;
+ private readonly RequestFailedException _exception;
+
+ public ErrorResult(Response response, RequestFailedException exception)
+ {
+ _response = response;
+ _exception = exception;
+ }
+
+ /// Gets the Value.
+ public override T Value => throw _exception;
+
+ ///
+ public override Response GetRawResponse()
+ {
+ return _response;
+ }
+ }
+}
diff --git a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ModelSerializationExtensions.cs
index ac6aaf3fc452..d3caa601c582 100644
--- a/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ModelSerializationExtensions.cs
+++ b/sdk/cognitivelanguage/Azure.AI.Language.QuestionAnswering.Inference/src/Generated/Internal/ModelSerializationExtensions.cs
@@ -11,18 +11,16 @@
using System.Diagnostics;
using System.Globalization;
using System.Text.Json;
-using System.Xml;
-using Azure.Core;
namespace Azure.AI.Language.QuestionAnswering.Inference
{
- internal static class ModelSerializationExtensions
+ internal static partial class ModelSerializationExtensions
{
- internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 };
internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W");
- internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3");
- internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3");
- internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray());
+ internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions
+ {
+ MaxDepth = 256
+ };
public static object GetObject(this JsonElement element)
{
@@ -48,14 +46,14 @@ public static object GetObject(this JsonElement element)
case JsonValueKind.Null:
return null;
case JsonValueKind.Object:
- var dictionary = new Dictionary();
+ Dictionary dictionary = new Dictionary();
foreach (var jsonProperty in element.EnumerateObject())
{
dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject());
}
return dictionary;
case JsonValueKind.Array:
- var list = new List