Skip to content

Commit d461696

Browse files
m-nashsarangan12
authored andcommitted
Adopt http/type/enum/fixed (microsoft#4235)
Fixes microsoft#3997
1 parent 030a6a9 commit d461696

11 files changed

Lines changed: 595 additions & 1 deletion

File tree

packages/http-client-csharp/eng/scripts/Generate.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ $failingSpecs = @(
7373
Join-Path 'http' 'special-headers' 'conditional-request'
7474
Join-Path 'http' 'special-headers' 'repeatability'
7575
Join-Path 'http' 'type' 'dictionary'
76-
Join-Path 'http' 'type' 'enum' 'fixed'
7776
Join-Path 'http' 'type' 'model' 'empty'
7877
Join-Path 'http' 'type' 'model' 'flatten'
7978
Join-Path 'http' 'type' 'model' 'usage'

packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Properties/launchSettings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
"commandName": "Executable",
6666
"executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe"
6767
},
68+
"http-type-enum-fixed": {
69+
"commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/type/enum/fixed -p StubLibraryPlugin",
70+
"commandName": "Executable",
71+
"executablePath": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe"
72+
},
6873
"http-type-scalar": {
6974
"commandLineArgs": "$(SolutionDir)/TestProjects/CadlRanch/http/type/scalar -p StubLibraryPlugin",
7075
"commandName": "Executable",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.ClientModel;
6+
using System.Threading.Tasks;
7+
using _Type._Enum.Fixed;
8+
using _Type._Enum.Fixed.Models;
9+
using NUnit.Framework;
10+
11+
namespace TestProjects.CadlRanch.Tests.Http._Type._Enum.Fixed
12+
{
13+
internal class FixedTests : CadlRanchTestBase
14+
{
15+
[CadlRanchTest]
16+
public Task Type_Enum_Fixed_String_getKnownValue() => Test(async (host) =>
17+
{
18+
var response = await new FixedClient(host, null).GetStringClient().GetKnownValueAsync();
19+
Assert.AreEqual(DaysOfWeekEnum.Monday, response.Value);
20+
});
21+
22+
[CadlRanchTest]
23+
public Task Type_Enum_Fixed_String_putKnownValue() => Test(async (host) =>
24+
{
25+
var response = await new FixedClient(host, null).GetStringClient().PutKnownValueAsync(DaysOfWeekEnum.Monday);
26+
Assert.AreEqual(204, response.GetRawResponse().Status);
27+
});
28+
29+
[CadlRanchTest]
30+
public Task Type_Enum_Fixed_String_putUnknownValue() => Test((host) =>
31+
{
32+
var exception = Assert.ThrowsAsync<ClientResultException>(() => new FixedClient(host, null).GetStringClient().PutUnknownValueAsync(BinaryContent.Create(BinaryData.FromObjectAsJson("Weekend")), null));
33+
Assert.IsNotNull(exception?.GetRawResponse());
34+
Assert.AreEqual(500, exception?.GetRawResponse()?.Status);
35+
return Task.CompletedTask;
36+
});
37+
}
38+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"output-folder": ".",
3+
"namespace": "Type.Enum.Fixed",
4+
"library-name": "Type.Enum.Fixed",
5+
"use-model-reader-writer": true
6+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 16
3+
VisualStudioVersion = 16.0.29709.97
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Type._Enum.Fixed", "src\_Type._Enum.Fixed.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
17+
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
21+
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU
29+
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
40+
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU
41+
EndGlobalSection
42+
GlobalSection(SolutionProperties) = preSolution
43+
HideSolutionNode = FALSE
44+
EndGlobalSection
45+
GlobalSection(ExtensibilityGlobals) = postSolution
46+
SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE}
47+
EndGlobalSection
48+
EndGlobal
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// <auto-generated/>
2+
3+
#nullable disable
4+
5+
using System;
6+
using System.ClientModel.Primitives;
7+
8+
namespace _Type._Enum.Fixed
9+
{
10+
public partial class FixedClient
11+
{
12+
public FixedClient() : this(new Uri("http://localhost:3000"), new FixedClientOptions()) => throw null;
13+
14+
public FixedClient(Uri endpoint, FixedClientOptions options) => throw null;
15+
16+
public ClientPipeline Pipeline => throw null;
17+
18+
public virtual String GetStringClient() => throw null;
19+
}
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// <auto-generated/>
2+
3+
#nullable disable
4+
5+
using System.ClientModel.Primitives;
6+
7+
namespace _Type._Enum.Fixed
8+
{
9+
public partial class FixedClientOptions : ClientPipelineOptions
10+
{
11+
}
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// <auto-generated/>
2+
3+
#nullable disable
4+
5+
namespace _Type._Enum.Fixed.Models
6+
{
7+
public enum DaysOfWeekEnum
8+
{
9+
/// <summary> Monday. </summary>
10+
Monday,
11+
/// <summary> Tuesday. </summary>
12+
Tuesday,
13+
/// <summary> Wednesday. </summary>
14+
Wednesday,
15+
/// <summary> Thursday. </summary>
16+
Thursday,
17+
/// <summary> Friday. </summary>
18+
Friday,
19+
/// <summary> Saturday. </summary>
20+
Saturday,
21+
/// <summary> Sunday. </summary>
22+
Sunday
23+
}
24+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// <auto-generated/>
2+
3+
#nullable disable
4+
5+
using System.ClientModel;
6+
using System.ClientModel.Primitives;
7+
using System.Threading.Tasks;
8+
using _Type._Enum.Fixed.Models;
9+
10+
namespace _Type._Enum.Fixed
11+
{
12+
public partial class String
13+
{
14+
protected String() => throw null;
15+
16+
public ClientPipeline Pipeline => throw null;
17+
18+
public virtual ClientResult GetKnownValue(RequestOptions options) => throw null;
19+
20+
public virtual Task<ClientResult> GetKnownValueAsync(RequestOptions options) => throw null;
21+
22+
public virtual ClientResult<DaysOfWeekEnum> GetKnownValue() => throw null;
23+
24+
public virtual Task<ClientResult<DaysOfWeekEnum>> GetKnownValueAsync() => throw null;
25+
26+
public virtual ClientResult PutKnownValue(BinaryContent content, RequestOptions options) => throw null;
27+
28+
public virtual Task<ClientResult> PutKnownValueAsync(BinaryContent content, RequestOptions options) => throw null;
29+
30+
public virtual ClientResult PutKnownValue(DaysOfWeekEnum body) => throw null;
31+
32+
public virtual Task<ClientResult> PutKnownValueAsync(DaysOfWeekEnum body) => throw null;
33+
34+
public virtual ClientResult PutUnknownValue(BinaryContent content, RequestOptions options) => throw null;
35+
36+
public virtual Task<ClientResult> PutUnknownValueAsync(BinaryContent content, RequestOptions options) => throw null;
37+
38+
public virtual ClientResult PutUnknownValue(DaysOfWeekEnum body) => throw null;
39+
40+
public virtual Task<ClientResult> PutUnknownValueAsync(DaysOfWeekEnum body) => throw null;
41+
}
42+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Description>This is the _Type._Enum.Fixed client library for developing .NET applications with rich experience.</Description>
4+
<AssemblyTitle>SDK Code Generation _Type._Enum.Fixed</AssemblyTitle>
5+
<Version>1.0.0-beta.1</Version>
6+
<PackageTags>_Type._Enum.Fixed</PackageTags>
7+
<TargetFramework>netstandard2.0</TargetFramework>
8+
<LangVersion>latest</LangVersion>
9+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="System.ClientModel" Version="1.1.0-beta.4" />
14+
<PackageReference Include="System.Text.Json" Version="8.0.4" />
15+
</ItemGroup>
16+
</Project>

0 commit comments

Comments
 (0)