Skip to content

Commit e0b8da9

Browse files
Upgrade MTG dependency version (Azure#48925)
* Upgrade MTG dependency version * Add link to issue * merge fixes * delete * Bump repo SCM version * Fix emitter build * Add minimal paging impl * Fix generation script * Fix extensions dependencies * Remove sampleExe var * revert scm changes * PR fb
1 parent 23ffb90 commit e0b8da9

27 files changed

+285
-108
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.20250307.1" />
209+
<PackageReference Update="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250317.2" />
210+
<PackageReference Update="System.ClientModel" Version="1.3.0" />
210211
</ItemGroup>
211212

212213
<!--

eng/packages/http-client-csharp/emitter/src/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const singleton = "Azure.ResourceManager.@singleton";
2222
const resourceMetadata = "Azure.ClientGenerator.Core.@resourceSchema";
2323

2424
export async function $onEmit(context: EmitContext<CSharpEmitterOptions>) {
25-
context.options["plugin-name"] ??= "AzureClientPlugin";
25+
context.options["generator-name"] ??= "AzureClientGenerator";
2626
context.options["emitter-extension-path"] = import.meta.url;
2727
context.options["update-code-model"] = updateCodeModel;
2828
setSDKContextOptions(azureSDKContextOptions);

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ foreach ($directory in $directories) {
160160
if (-not (Test-Path $generationDir)) {
161161
New-Item -ItemType Directory -Path $generationDir | Out-Null
162162
}
163-
163+
164164
if ($folders.Contains("versioning")) {
165165
Generate-Versioning $directory.FullName $generationDir -generateStub $stubbed
166166
$spectorLaunchProjects.Add($($folders -join "-") + "-v1", $("TestProjects/Spector/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v1")
@@ -180,7 +180,7 @@ foreach ($directory in $directories) {
180180
if ($LaunchOnly) {
181181
continue
182182
}
183-
183+
184184
Write-Host "Generating $subPath" -ForegroundColor Cyan
185185
Invoke (Get-TspCommand $specFile $generationDir $stubbed -forceNewProject $ForceNewProject)
186186

@@ -194,25 +194,24 @@ foreach ($directory in $directories) {
194194
if ($null -eq $filter) {
195195
Write-Host "Writing new launch settings" -ForegroundColor Cyan
196196
$mgcExe = "`$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.exe"
197-
$sampleExe = "`$(SolutionDir)/../generator/artifacts/bin/SamplePlugin/Debug/net8.0/Microsoft.Generator.CSharp.exe"
198197
$basicSpec = "TestProjects/Local/Basic-TypeSpec"
199198
$mgmtSpec = "TestProjects/Local/Mgmt-TypeSpec"
200199

201200
$launchSettings = @{}
202201
$launchSettings.Add("profiles", @{})
203202
$launchSettings["profiles"].Add("Basic-TypeSpec", @{})
204-
$launchSettings["profiles"]["Basic-TypeSpec"].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.dll `$(SolutionDir)/$basicSpec -p AzureClientPlugin")
203+
$launchSettings["profiles"]["Basic-TypeSpec"].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.dll `$(SolutionDir)/$basicSpec -g AzureClientGenerator")
205204
$launchSettings["profiles"]["Basic-TypeSpec"].Add("commandName", "Executable")
206205
$launchSettings["profiles"]["Basic-TypeSpec"].Add("executablePath", "dotnet")
207-
206+
208207
$launchSettings["profiles"].Add("Mgmt-TypeSpec", @{})
209-
$launchSettings["profiles"]["Mgmt-TypeSpec"].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.dll `$(SolutionDir)/$mgmtSpec -p AzureClientPlugin")
208+
$launchSettings["profiles"]["Mgmt-TypeSpec"].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.dll `$(SolutionDir)/$mgmtSpec -g AzureClientGenerator")
210209
$launchSettings["profiles"]["Mgmt-TypeSpec"].Add("commandName", "Executable")
211210
$launchSettings["profiles"]["Mgmt-TypeSpec"].Add("executablePath", "dotnet")
212211

213212
foreach ($kvp in $spectorLaunchProjects.GetEnumerator()) {
214213
$launchSettings["profiles"].Add($kvp.Key, @{})
215-
$launchSettings["profiles"][$kvp.Key].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.dll `$(SolutionDir)/$($kvp.Value) -p AzureStubPlugin")
214+
$launchSettings["profiles"][$kvp.Key].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.dll `$(SolutionDir)/$($kvp.Value) -g AzureClientGenerator")
216215
$launchSettings["profiles"][$kvp.Key].Add("commandName", "Executable")
217216
$launchSettings["profiles"][$kvp.Key].Add("executablePath", "dotnet")
218217
}

eng/packages/http-client-csharp/eng/scripts/Generation.psm1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ function Get-TspCommand {
3939
$command += " --option @azure-typespec/http-client-csharp.emitter-output-dir=$generationDir"
4040
$command += " --option @azure-typespec/http-client-csharp.save-inputs=true"
4141
if ($generateStub) {
42-
$command += " --option @azure-typespec/http-client-csharp.plugin-name=AzureStubPlugin"
42+
$command += " --option @azure-typespec/http-client-csharp.generator-name=AzureStubGenerator"
4343
}
4444

4545
if ($namespaceOverride) {
4646
$command += " --option @azure-typespec/http-client-csharp.namespace=$namespaceOverride"
4747
}
48-
48+
4949
if ($apiVersion) {
5050
$command += " --option @azure-typespec/http-client-csharp.api-version=$apiVersion"
5151
}
@@ -114,7 +114,7 @@ function Generate-Srv-Driven {
114114
## get the last two directories of the output directory and add V1/V2 to disambiguate the namespaces
115115
$namespaceRoot = $(($outputDir.Split([System.IO.Path]::DirectorySeparatorChar)[-2..-1] | `
116116
ForEach-Object { $_.Substring(0,1).ToUpper() + $_.Substring(1) }) -replace '-(\p{L})', { $_.Groups[1].Value.ToUpper() } -replace '\W', '' -join ".")
117-
$v1NamespaceOverride = $namespaceRoot + ".V1"
117+
$v1NamespaceOverride = $namespaceRoot + ".V1"
118118
$v2NamespaceOverride = $namespaceRoot + ".V2"
119119

120120
$v1SpecFilePath = $(Join-Path $specFilePath "old.tsp")
@@ -141,7 +141,7 @@ function Generate-Versioning {
141141
if ($createOutputDirIfNotExist -and -not (Test-Path $v1Dir)) {
142142
New-Item -ItemType Directory -Path $v1Dir | Out-Null
143143
}
144-
144+
145145
$v2Dir = $(Join-Path $outputDir "v2")
146146
if ($createOutputDirIfNotExist -and -not (Test-Path $v2Dir)) {
147147
New-Item -ItemType Directory -Path $v2Dir | Out-Null
@@ -150,12 +150,12 @@ function Generate-Versioning {
150150
## get the last two directories of the output directory and add V1/V2 to disambiguate the namespaces
151151
$namespaceRoot = $(($outputFolders[-2..-1] | `
152152
ForEach-Object { $_.Substring(0,1).ToUpper() + $_.Substring(1) }) -join ".")
153-
$v1NamespaceOverride = $namespaceRoot + ".V1"
153+
$v1NamespaceOverride = $namespaceRoot + ".V1"
154154
$v2NamespaceOverride = $namespaceRoot + ".V2"
155-
155+
156156
Invoke (Get-TspCommand $specFilePath $v1Dir -generateStub $generateStub -apiVersion "v1" -namespaceOverride $v1NamespaceOverride)
157157
Invoke (Get-TspCommand $specFilePath $v2Dir -generateStub $generateStub -apiVersion "v2" -namespaceOverride $v2NamespaceOverride)
158-
158+
159159
if ($outputFolders.Contains("removed")) {
160160
$v2PreviewDir = $(Join-Path $outputDir "v2Preview")
161161
if ($createOutputDirIfNotExist -and -not (Test-Path $v2PreviewDir)) {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ namespace Azure.Generator.StubLibrary
99
/// <summary>
1010
/// The stub library plugin to generate the stub library.
1111
/// </summary>
12-
[Export(typeof(CodeModelPlugin))]
13-
[ExportMetadata("PluginName", nameof(AzureStubPlugin))]
14-
public class AzureStubPlugin : AzureClientPlugin
12+
[Export(typeof(CodeModelGenerator))]
13+
[ExportMetadata(GeneratorMetadataName, nameof(AzureStubGenerator))]
14+
public class AzureStubGenerator : AzureClientGenerator
1515
{
1616
/// <summary>
1717
/// The stub library plugin to generate the stub library.
1818
/// </summary>
1919
/// <param name="context"> The Generator Context. </param>
2020
[ImportingConstructor]
21-
public AzureStubPlugin(GeneratorContext context) : base(context) { }
21+
public AzureStubGenerator(GeneratorContext context) : base(context) { }
2222

2323
/// <summary>
2424
/// Customize the generation output for stub library.

eng/packages/http-client-csharp/generator/Azure.Generator/src/AzureClientPlugin.cs renamed to eng/packages/http-client-csharp/generator/Azure.Generator/src/AzureClientGenerator.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
namespace Azure.Generator;
1515

1616
/// <summary>
17-
/// The Azure client plugin to generate the Azure client SDK.
17+
/// The Azure client generator to generate the Azure client SDK.
1818
/// </summary>
19-
[Export(typeof(CodeModelPlugin))]
20-
[ExportMetadata("PluginName", nameof(AzureClientPlugin))]
21-
public class AzureClientPlugin : ScmCodeModelPlugin
19+
[Export(typeof(CodeModelGenerator))]
20+
[ExportMetadata(GeneratorMetadataName, nameof(AzureClientGenerator))]
21+
public class AzureClientGenerator : ScmCodeModelGenerator
2222
{
23-
private static AzureClientPlugin? _instance;
24-
internal static AzureClientPlugin Instance => _instance ?? throw new InvalidOperationException("AzureClientPlugin is not loaded.");
23+
private static AzureClientGenerator? _instance;
24+
internal static AzureClientGenerator Instance => _instance ?? throw new InvalidOperationException("AzureClientGenerator is not loaded.");
2525

2626
/// <inheritdoc/>
2727
public override AzureTypeFactory TypeFactory { get; }
@@ -34,11 +34,11 @@ public class AzureClientPlugin : ScmCodeModelPlugin
3434
public override AzureInputLibrary InputLibrary { get; }
3535

3636
/// <summary>
37-
/// The Azure client plugin to generate the Azure client SDK.
37+
/// Constructs the Azure client generator used to generate the Azure client SDK.
3838
/// </summary>
3939
/// <param name="context"></param>
4040
[ImportingConstructor]
41-
public AzureClientPlugin(GeneratorContext context) : base(context)
41+
public AzureClientGenerator(GeneratorContext context) : base(context)
4242
{
4343
InputLibrary = new AzureInputLibrary(Configuration.OutputDirectory);
4444
TypeFactory = new AzureTypeFactory();
@@ -53,7 +53,7 @@ public override void Configure()
5353
base.Configure();
5454
// Include Azure.Core
5555
AddMetadataReference(MetadataReference.CreateFromFile(typeof(Response).Assembly.Location));
56-
var sharedSourceDirectory = Path.Combine(Path.GetDirectoryName(typeof(AzureClientPlugin).Assembly.Location)!, "Shared", "Core");
56+
var sharedSourceDirectory = Path.Combine(Path.GetDirectoryName(typeof(AzureClientGenerator).Assembly.Location)!, "Shared", "Core");
5757
AddSharedSourceDirectory(sharedSourceDirectory);
5858
AddVisitor(new NamespaceVisitor());
5959
if (IsAzureArm.Value)

eng/packages/http-client-csharp/generator/Azure.Generator/src/AzureOutputLibrary.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class AzureOutputLibrary : ScmOutputLibrary
2222
private IReadOnlyList<ResourceClientProvider> BuildResources()
2323
{
2424
var result = new List<ResourceClientProvider>();
25-
foreach (var client in AzureClientPlugin.Instance.InputLibrary.InputNamespace.Clients)
25+
foreach (var client in AzureClientGenerator.Instance.InputLibrary.InputNamespace.Clients)
2626
{
2727
// A resource client should contain the decorator "Azure.ResourceManager.@resourceMetadata"
2828
var resourceMetadata = client.Decorators.FirstOrDefault(d => d.Name.Equals(KnownDecorators.ResourceMetadata));
@@ -31,7 +31,7 @@ private IReadOnlyList<ResourceClientProvider> BuildResources()
3131
continue;
3232
}
3333
var resource = new ResourceClientProvider(client);
34-
AzureClientPlugin.Instance.AddTypeToKeep(resource.Name);
34+
AzureClientGenerator.Instance.AddTypeToKeep(resource.Name);
3535
result.Add(resource);
3636
}
3737
return result;
@@ -42,7 +42,7 @@ private IReadOnlyList<ResourceClientProvider> BuildResources()
4242
protected override TypeProvider[] BuildTypeProviders()
4343
{
4444
var baseProviders = base.BuildTypeProviders();
45-
if (AzureClientPlugin.Instance.IsAzureArm.Value == true)
45+
if (AzureClientGenerator.Instance.IsAzureArm.Value == true)
4646
{
4747
var resources = BuildResources();
4848
return [.. baseProviders, new RequestContextExtensionsDefinition(), ArmOperation, GenericArmOperation, .. resources, .. resources.Select(r => r.Source)];

eng/packages/http-client-csharp/generator/Azure.Generator/src/AzureTypeFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public override MethodBodyStatement SerializeJsonValue(Type valueType, ValueExpr
113113
/// <inheritdoc/>
114114
protected override ClientProvider? CreateClientCore(InputClient inputClient)
115115
{
116-
if (!AzureClientPlugin.Instance.IsAzureArm.Value)
116+
if (!AzureClientGenerator.Instance.IsAzureArm.Value)
117117
{
118118
return base.CreateClientCore(inputClient);
119119
}

eng/packages/http-client-csharp/generator/Azure.Generator/src/NamespaceVisitor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ internal class NamespaceVisitor : ScmLibraryVisitor
4747
}
4848
else
4949
{
50-
type.Type.Update(@namespace: AzureClientPlugin.Instance.TypeFactory.PrimaryNamespace);
50+
type.Type.Update(@namespace: AzureClientGenerator.Instance.TypeFactory.PrimaryNamespace);
5151
}
5252
return type;
5353
}
@@ -57,7 +57,7 @@ private static void UpdateModelsNamespace(TypeProvider type)
5757
// TODO: need to take consideration of model-namespace configuration
5858
// if model-namespace is false, set namespace to $"{AzureClientPlugin.Instance.TypeFactory.RootNamespace}"
5959
// if model-namespace is true, set namespace to $"{AzureClientPlugin.Instance.TypeFactory.RootNamespace}.Models"
60-
type.Type.Update(@namespace: AzureClientPlugin.Instance.TypeFactory.GetCleanNameSpace($"{AzureClientPlugin.Instance.TypeFactory.PrimaryNamespace}.Models"));
60+
type.Type.Update(@namespace: AzureClientGenerator.Instance.TypeFactory.GetCleanNameSpace($"{AzureClientGenerator.Instance.TypeFactory.PrimaryNamespace}.Models"));
6161
}
6262
}
6363
}

eng/packages/http-client-csharp/generator/Azure.Generator/src/Primitives/NewAzureProjectScaffolding.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ protected override string GetSourceProjectFileContent()
2323
{
2424
var builder = new CSharpProjectWriter()
2525
{
26-
Description = $"This is the {AzureClientPlugin.Instance.TypeFactory.PrimaryNamespace} client library for developing .NET applications with rich experience.",
27-
AssemblyTitle = $"SDK Code Generation {AzureClientPlugin.Instance.TypeFactory.PrimaryNamespace}",
26+
Description = $"This is the {AzureClientGenerator.Instance.TypeFactory.PrimaryNamespace} client library for developing .NET applications with rich experience.",
27+
AssemblyTitle = $"SDK Code Generation {AzureClientGenerator.Instance.TypeFactory.PrimaryNamespace}",
2828
Version = "1.0.0-beta.1",
29-
PackageTags = AzureClientPlugin.Instance.TypeFactory.PrimaryNamespace,
29+
PackageTags = AzureClientGenerator.Instance.TypeFactory.PrimaryNamespace,
3030
GenerateDocumentationFile = true,
3131
};
3232

@@ -36,7 +36,7 @@ protected override string GetSourceProjectFileContent()
3636
}
3737

3838
int pathSegmentCount = GetPathSegmentCount();
39-
if (AzureClientPlugin.Instance.InputLibrary.InputNamespace.Auth?.ApiKey is not null)
39+
if (AzureClientGenerator.Instance.InputLibrary.InputNamespace.Auth?.ApiKey is not null)
4040
{
4141
builder.CompileIncludes.Add(new CSharpProjectWriter.CSProjCompileInclude(GetCompileInclude("AzureKeyCredentialPolicy.cs", pathSegmentCount), "Shared/Core"));
4242
}
@@ -84,7 +84,7 @@ private static void TraverseInput(out bool hasOperation, out bool hasLongRunning
8484
{
8585
hasOperation = false;
8686
hasLongRunningOperation = false;
87-
foreach (var inputClient in AzureClientPlugin.Instance.InputLibrary.InputNamespace.Clients)
87+
foreach (var inputClient in AzureClientGenerator.Instance.InputLibrary.InputNamespace.Clients)
8888
{
8989
foreach (var operation in inputClient.Operations)
9090
{
@@ -100,7 +100,7 @@ private static void TraverseInput(out bool hasOperation, out bool hasLongRunning
100100

101101
private static int GetPathSegmentCount()
102102
{
103-
ReadOnlySpan<char> text = AzureClientPlugin.Instance.Configuration.OutputDirectory.AsSpan();
103+
ReadOnlySpan<char> text = AzureClientGenerator.Instance.Configuration.OutputDirectory.AsSpan();
104104
// we are either a spector project in the eng folder or a real sdk in the sdk folder
105105
int beginning = text.IndexOf("eng");
106106
if (beginning == -1)
@@ -121,7 +121,7 @@ private string GetCompileInclude(string fileName, int pathSegmentCount)
121121
}
122122

123123
private static readonly IReadOnlyList<CSharpProjectWriter.CSProjDependencyPackage> _azureDependencyPackages =
124-
AzureClientPlugin.Instance.IsAzureArm.Value == true
124+
AzureClientGenerator.Instance.IsAzureArm.Value == true
125125
? [
126126
new("Azure.Core"),
127127
new("Azure.ResourceManager"),

0 commit comments

Comments
 (0)