Skip to content

Commit c815770

Browse files
Adopt Spector type scenarios (Azure#49657)
* Gen Spector type libraries * Add tests
1 parent c8ac897 commit c815770

File tree

467 files changed

+64547
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

467 files changed

+64547
-20
lines changed

eng/Packages.Data.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@
206206
</ItemGroup>
207207

208208
<ItemGroup Condition="'$(IsGeneratorLibrary)' == 'true'">
209-
<PackageReference Update="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250423.2" />
209+
<PackageReference Update="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250424.2" />
210+
<PackageReference Update="Microsoft.TypeSpec.Generator.Input" Version="1.0.0-alpha.20250424.2" />
210211
<PackageReference Update="Azure.Generator" Version="1.0.0-alpha.20250423.3" />
211212
<PackageReference Update="System.ClientModel" Version="1.3.0" />
212213
</ItemGroup>

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,9 @@ function IsSpecDir {
5353
$failingSpecs = @(
5454
Join-Path 'http' 'payload' 'pageable'
5555
Join-Path 'http' 'payload' 'xml'
56-
Join-Path 'http' 'type' 'model' 'flatten'
57-
Join-Path 'http' 'type' 'model' 'templated'
5856
Join-Path 'http' 'payload' 'multipart'
5957
Join-Path 'http' 'server' 'path' 'multiple'
6058
Join-Path 'http' 'server' 'versions' 'versioned'
61-
Join-Path 'http' 'type' 'union'
62-
Join-Path 'http' 'type' 'enum' 'extensible'
63-
Join-Path 'http' 'type' 'model' 'inheritance' 'enum-discriminator'
64-
Join-Path 'http' 'type' 'property' 'additional-properties'
65-
Join-Path 'http' 'type' 'property' 'optionality'
66-
Join-Path 'http' 'type' 'property' 'value-types'
6759
Join-Path 'http' 'versioning' 'added'
6860
Join-Path 'http' 'versioning' 'madeOptional'
6961
Join-Path 'http' 'versioning' 'removed'
@@ -82,9 +74,6 @@ $failingSpecs = @(
8274
Join-Path 'http' 'parameters' 'collection-format'
8375
Join-Path 'http' 'response' 'status-code-range' # Response namespace conflicts with Azure.Response
8476
Join-Path 'http' 'routes'
85-
Join-Path 'http' 'type' 'array'
86-
Join-Path 'http' 'type' 'dictionary'
87-
Join-Path 'http' 'type' 'scalar'
8877
)
8978

9079
$azureAllowSpecs = @(

eng/packages/http-client-csharp/generator/Azure.Generator/src/Properties/launchSettings.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@
105105
"commandName": "Executable",
106106
"executablePath": "dotnet"
107107
},
108+
"http-type-array": {
109+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/array -g AzureStubGenerator",
110+
"commandName": "Executable",
111+
"executablePath": "dotnet"
112+
},
113+
"http-type-dictionary": {
114+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/dictionary -g AzureStubGenerator",
115+
"commandName": "Executable",
116+
"executablePath": "dotnet"
117+
},
118+
"http-type-enum-extensible": {
119+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/enum/extensible -g AzureStubGenerator",
120+
"commandName": "Executable",
121+
"executablePath": "dotnet"
122+
},
108123
"http-type-enum-fixed": {
109124
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/enum/fixed -g AzureStubGenerator",
110125
"commandName": "Executable",
@@ -115,6 +130,11 @@
115130
"commandName": "Executable",
116131
"executablePath": "dotnet"
117132
},
133+
"http-type-model-inheritance-enum-discriminator": {
134+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/enum-discriminator -g AzureStubGenerator",
135+
"commandName": "Executable",
136+
"executablePath": "dotnet"
137+
},
118138
"http-type-model-inheritance-nested-discriminator": {
119139
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/model/inheritance/nested-discriminator -g AzureStubGenerator",
120140
"commandName": "Executable",
@@ -145,10 +165,35 @@
145165
"commandName": "Executable",
146166
"executablePath": "dotnet"
147167
},
168+
"http-type-property-additional-properties": {
169+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/property/additional-properties -g AzureStubGenerator",
170+
"commandName": "Executable",
171+
"executablePath": "dotnet"
172+
},
148173
"http-type-property-nullable": {
149174
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/property/nullable -g AzureStubGenerator",
150175
"commandName": "Executable",
151176
"executablePath": "dotnet"
177+
},
178+
"http-type-property-optionality": {
179+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/property/optionality -g AzureStubGenerator",
180+
"commandName": "Executable",
181+
"executablePath": "dotnet"
182+
},
183+
"http-type-property-value-types": {
184+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/property/value-types -g AzureStubGenerator",
185+
"commandName": "Executable",
186+
"executablePath": "dotnet"
187+
},
188+
"http-type-scalar": {
189+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/scalar -g AzureStubGenerator",
190+
"commandName": "Executable",
191+
"executablePath": "dotnet"
192+
},
193+
"http-type-union": {
194+
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/type/union -g AzureStubGenerator",
195+
"commandName": "Executable",
196+
"executablePath": "dotnet"
152197
}
153198
}
154199
}

eng/packages/http-client-csharp/generator/Azure.Generator/test/common/Azure.Generator.Tests.Common.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<IsTestProject>true</IsTestProject>
8+
<!-- Don't warn for missing XML comments for test project. -->
9+
<NoWarn>$(NoWarn);1591</NoWarn>
710
</PropertyGroup>
811

912
<ItemGroup>
10-
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" />
13+
<PackageReference Include="Azure.Core" />
14+
<PackageReference Include="NUnit" />
15+
<PackageReference Include="NUnit3TestAdapter" />
16+
<PackageReference Include="Microsoft.TypeSpec.Generator.Input" />
1117
</ItemGroup>
1218

1319
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using NUnit.Framework;
6+
7+
namespace Azure.Generator.Tests.Common
8+
{
9+
public static class BinaryDataAssert
10+
{
11+
public static void AreEqual(BinaryData expected, BinaryData result)
12+
{
13+
CollectionAssert.AreEqual(expected?.ToArray(), result?.ToArray());
14+
}
15+
}
16+
}

eng/packages/http-client-csharp/generator/Azure.Generator/test/common/InputFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System.Collections.Generic;
5+
using System.Linq;
46
using Microsoft.TypeSpec.Generator.Input;
57

68
namespace Azure.Generator.Tests.Common
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Diagnostics;
5+
using System.IO;
6+
using System.Reflection;
7+
8+
namespace Azure.Generator.Tests.Common
9+
{
10+
public static class ModelTestHelper
11+
{
12+
public static string GetLocation(string filePath)
13+
{
14+
StackTrace stackTrace = new StackTrace();
15+
MethodBase method = stackTrace.GetFrame(1)!.GetMethod()!;
16+
string testsLocation = Directory.GetParent(method.DeclaringType!.Assembly.Location)!.FullName;
17+
18+
var startNamespace = testsLocation.IndexOf("bin") + 4;
19+
var endNamespace = testsLocation.IndexOf("Debug") - 1;
20+
var namespaceLength = endNamespace - startNamespace;
21+
var testNamespace = method.DeclaringType.Namespace!.Substring(namespaceLength);
22+
var segments = testNamespace.Split('.');
23+
foreach (var segment in segments)
24+
{
25+
testsLocation = Path.Combine(testsLocation, segment);
26+
}
27+
return Path.Combine(testsLocation, filePath);
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)