diff --git a/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/SimplePost.sln b/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/SimplePost.sln
index 936f70170f9..8b99758a6ad 100644
--- a/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/SimplePost.sln
+++ b/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/SimplePost.sln
@@ -1,10 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29709.97
+# Visual Studio Version 17
+VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimplePost", "src\SimplePost.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimplePost.Tests", "tests\SimplePost.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimplePost", "src\SimplePost.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -12,34 +10,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
- {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
- {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU
- {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU
- {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU
- {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/Argument.cs b/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/Argument.cs
index 432f4d3232f..ff5a451e9e1 100644
--- a/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/Argument.cs
+++ b/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/Argument.cs
@@ -3,127 +3,30 @@
//
-#nullable disable
+#nullable enable
using System;
-using System.Collections;
-using System.Collections.Generic;
-namespace SimplePost
+namespace SimplePost;
+
+internal static class Argument
{
- internal static class Argument
+ public static void AssertNotNull(T value, string name)
{
- public static void AssertNotNull(T value, string name)
- {
- if (value is null)
- {
- throw new ArgumentNullException(name);
- }
- }
-
- public static void AssertNotNull(T? value, string name)
- where T : struct
+ if (value is null)
{
- if (!value.HasValue)
- {
- throw new ArgumentNullException(name);
- }
+ throw new ArgumentNullException(name);
}
-
- public static void AssertNotNullOrEmpty(IEnumerable value, string name)
- {
- if (value is null)
- {
- throw new ArgumentNullException(name);
- }
- if (value is ICollection collectionOfT && collectionOfT.Count == 0)
- {
- throw new ArgumentException("Value cannot be an empty collection.", name);
- }
- if (value is ICollection collection && collection.Count == 0)
- {
- throw new ArgumentException("Value cannot be an empty collection.", name);
- }
- using IEnumerator e = value.GetEnumerator();
- if (!e.MoveNext())
- {
- throw new ArgumentException("Value cannot be an empty collection.", name);
- }
- }
-
- public static void AssertNotNullOrEmpty(string value, string name)
- {
- if (value is null)
- {
- throw new ArgumentNullException(name);
- }
- if (value.Length == 0)
- {
- 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)
+ }
+ public static void AssertNotNullOrEmpty(string value, string name)
+ {
+ if (value is null)
{
- AssertNotNullOrEmpty(value, name);
- return value;
+ throw new ArgumentNullException(name);
}
-
- public static void AssertNull(T value, string name, string message = null)
+ if (value.Length == 0)
{
- if (value != null)
- {
- throw new ArgumentException(message ?? "Value must be null.", name);
- }
+ throw new ArgumentException("Value cannot be an empty string.", name);
}
}
}
diff --git a/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/CancellationTokenExtensions.cs b/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/CancellationTokenExtensions.cs
new file mode 100644
index 00000000000..c27cae478e7
--- /dev/null
+++ b/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/CancellationTokenExtensions.cs
@@ -0,0 +1,27 @@
+//
+
+#nullable enable
+
+using System.Threading;
+using Azure;
+
+namespace SimplePost;
+
+internal static class CancellationTokenExtensions
+{
+ public static RequestContext ToRequestContext(this CancellationToken cancellationToken)
+ {
+ if (cancellationToken == default)
+ {
+ return DefaultRequestContext;
+ }
+
+ return new RequestContext()
+ {
+ CancellationToken = cancellationToken
+ };
+ }
+
+ private static RequestContext DefaultRequestContext => _defaultRequestContext ??= new();
+ private static RequestContext? _defaultRequestContext;
+}
diff --git a/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/ModelSerializationExtensions.cs b/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/ModelSerializationExtensions.cs
deleted file mode 100644
index 12c51b45884..00000000000
--- a/test/AzureClients/SimplePost/tsp-output/@azure-tools/typespec-csharp/src/Generated/Internal/ModelSerializationExtensions.cs
+++ /dev/null
@@ -1,398 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ClientModel.Primitives;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Globalization;
-using System.Text.Json;
-using System.Xml;
-using Azure.Core;
-
-namespace SimplePost
-{
- internal static class ModelSerializationExtensions
- {
- internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W");
-
- public static object GetObject(this JsonElement element)
- {
- switch (element.ValueKind)
- {
- case JsonValueKind.String:
- return element.GetString();
- case JsonValueKind.Number:
- if (element.TryGetInt32(out int intValue))
- {
- return intValue;
- }
- if (element.TryGetInt64(out long longValue))
- {
- return longValue;
- }
- return element.GetDouble();
- case JsonValueKind.True:
- return true;
- case JsonValueKind.False:
- return false;
- case JsonValueKind.Undefined:
- case JsonValueKind.Null:
- return null;
- case JsonValueKind.Object:
- var 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