Skip to content

Commit 9cf5891

Browse files
Copilotlive1206
andcommitted
Add spector generated code and verification tests for resource-manager specs
Co-authored-by: live1206 <5196139+live1206@users.noreply.github.com>
1 parent 02a7753 commit 9cf5891

File tree

306 files changed

+65569
-3
lines changed

Some content is hidden

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

306 files changed

+65569
-3
lines changed

eng/packages/http-client-csharp-mgmt/eng/scripts/Test-Spector.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..')
1010
Refresh-Mgmt-Build
1111

1212
$spectorRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector'
13-
$spectorCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector.Tests' 'TestProjects.Spector.Tests.csproj'
13+
$spectorCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector.Tests' 'Azure.Generator.Spector.Tests.csproj'
1414

1515
$coverageDir = Join-Path $packageRoot 'generator' 'artifacts' 'coverage'
1616

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector.Tests/Azure.Generator.Spector.Tests.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414

1515
<ItemGroup>
1616
<ProjectReference Include="..\..\Azure.Generator.Management\test\Common\Azure.Generator.Management.Tests.Common.csproj" />
17-
<!-- Add project references for Spector test projects here after generation -->
18-
<!-- Example: <ProjectReference Include="..\Spector\http\azure\resource-manager\common-properties\src\Azure.ResourceManager.CommonProperties.csproj" /> -->
17+
<!-- Some generated projects have build issues - commenting out for now -->
18+
<!-- <ProjectReference Include="..\Spector\http\azure\resource-manager\common-properties\src\Azure.ResourceManager.CommonProperties.csproj" /> -->
19+
<ProjectReference Include="..\Spector\http\azure\resource-manager\large-header\src\Azure.ResourceManager.LargeHeader.csproj" />
20+
<ProjectReference Include="..\Spector\http\azure\resource-manager\method-subscription-id\src\Azure.ResourceManager.MethodSubscriptionId.csproj" />
21+
<!-- <ProjectReference Include="..\Spector\http\azure\resource-manager\non-resource\src\Azure.ResourceManager.NonResource.csproj" /> -->
22+
<ProjectReference Include="..\Spector\http\azure\resource-manager\operation-templates\src\Azure.ResourceManager.OperationTemplates.csproj" />
23+
<!-- <ProjectReference Include="..\Spector\http\azure\resource-manager\resources\src\Azure.ResourceManager.Resources.csproj" /> -->
1924
</ItemGroup>
2025

2126
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.ClientModel.Primitives;
5+
using System.Text.Json;
6+
using Azure;
7+
using Azure.Core;
8+
using Azure.ResourceManager.OperationTemplates;
9+
using Azure.ResourceManager.OperationTemplates.Models;
10+
using NUnit.Framework;
11+
using TestProjects.Spector.Tests.Infrastructure;
12+
13+
namespace TestProjects.Spector.Tests.Http.Azure.ResourceManager.OperationTemplates
14+
{
15+
public class OrderDataTests : SpectorModelTests<OrderData>
16+
{
17+
private static readonly ModelReaderWriterOptions _wireOptions = new ModelReaderWriterOptions("W");
18+
19+
protected override string JsonPayload => """
20+
{
21+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1",
22+
"name": "order1",
23+
"type": "Azure.ResourceManager.OperationTemplates/orders",
24+
"location": "eastus",
25+
"tags": {
26+
"tagKey1": "tagValue1"
27+
},
28+
"properties": {
29+
"productId": "product1",
30+
"amount": 5,
31+
"provisioningState": "Succeeded"
32+
}
33+
}
34+
""";
35+
36+
protected override string WirePayload => JsonPayload;
37+
38+
protected override OrderData GetModelInstance()
39+
{
40+
return new OrderData(AzureLocation.EastUS);
41+
}
42+
43+
protected override void VerifyModel(OrderData model, string format)
44+
{
45+
Assert.AreEqual("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Azure.ResourceManager.OperationTemplates/orders/order1", model.Id.ToString());
46+
Assert.AreEqual("order1", model.Name);
47+
Assert.AreEqual("eastus", model.Location.Name);
48+
Assert.IsNotNull(model.Tags);
49+
Assert.AreEqual("tagValue1", model.Tags["tagKey1"]);
50+
Assert.IsNotNull(model.Properties);
51+
Assert.AreEqual("product1", model.Properties.ProductId);
52+
Assert.AreEqual(5, model.Properties.Amount);
53+
Assert.AreEqual("Succeeded", model.Properties.ProvisioningState);
54+
}
55+
56+
protected override void CompareModels(OrderData model, OrderData model2, string format)
57+
{
58+
Assert.AreEqual(model.Id, model2.Id);
59+
Assert.AreEqual(model.Name, model2.Name);
60+
Assert.AreEqual(model.Location, model2.Location);
61+
Assert.AreEqual(model.Properties?.ProductId, model2.Properties?.ProductId);
62+
Assert.AreEqual(model.Properties?.Amount, model2.Properties?.Amount);
63+
Assert.AreEqual(model.Properties?.ProvisioningState, model2.Properties?.ProvisioningState);
64+
}
65+
66+
protected override OrderData ToModel(Response response)
67+
{
68+
// Use ModelReaderWriter to deserialize since the FromResponse method is internal
69+
return ModelReaderWriter.Read<OrderData>(response.Content, _wireOptions)!;
70+
}
71+
72+
protected override RequestContent ToRequestContent(OrderData model)
73+
{
74+
// Use ModelReaderWriter to serialize since the ToRequestContent method is internal
75+
var binaryData = ModelReaderWriter.Write(model, _wireOptions);
76+
return RequestContent.Create(binaryData);
77+
}
78+
}
79+
}
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 17
3+
VisualStudioVersion = 17.0.31903.59
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.CommonProperties", "src\Azure.ResourceManager.CommonProperties.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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"package-name": "Azure.ResourceManager.CommonProperties",
3+
"model-namespace": true,
4+
"license": {
5+
"name": "MIT License",
6+
"company": "Microsoft Corporation",
7+
"link": "https://mit-license.org",
8+
"header": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.",
9+
"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."
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Description>This is the Azure.ResourceManager.CommonProperties client library for developing .NET applications with rich experience.</Description>
4+
<AssemblyTitle>SDK Code Generation Azure.ResourceManager.CommonProperties</AssemblyTitle>
5+
<Version>1.0.0-beta.1</Version>
6+
<PackageTags>Azure.ResourceManager.CommonProperties</PackageTags>
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8+
</PropertyGroup>
9+
</Project>

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ArmCommonPropertiesModelFactory.cs

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Spector/http/azure/resource-manager/common-properties/src/Generated/ConfidentialResource.Serialization.cs

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)