Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IsAzureArm to distinguish MPG and DPG #47374

Merged
merged 5 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
</ItemGroup>

<ItemGroup Condition="'$(IsGeneratorLibrary)' == 'true'">
<PackageReference Update="Microsoft.Generator.CSharp.ClientModel" Version="1.0.0-alpha.20241121.2" />
<PackageReference Update="Microsoft.Generator.CSharp.ClientModel" Version="1.0.0-alpha.20241128.1" />
</ItemGroup>

<!--
Expand Down
5 changes: 4 additions & 1 deletion eng/packages/http-client-csharp/emitter/src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import { EmitContext } from "@typespec/compiler";

import {
$onEmit as $OnMGCEmit,
NetEmitterOptions
NetEmitterOptions,
setSDKContextOptions
} from "@typespec/http-client-csharp";
import { azureSDKContextOptions } from "./sdk-context-options.js";

export async function $onEmit(context: EmitContext<NetEmitterOptions>) {
context.options["plugin-name"] = "AzureClientPlugin";
context.options["emitter-extension-path"] = import.meta.url;
setSDKContextOptions(azureSDKContextOptions);
await $OnMGCEmit(context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

import { CreateSdkContextOptions } from "@azure-tools/typespec-client-generator-core";

export const azureSDKContextOptions: CreateSdkContextOptions = {
versioning: {},
additionalDecorators: [
"Azure\\.ClientGenerator\\.Core\\.@useSystemTextJsonConverter",
live1206 marked this conversation as resolved.
Show resolved Hide resolved
"Azure\\.ResourceManager\\.@armProviderNamespace"
live1206 marked this conversation as resolved.
Show resolved Hide resolved
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
using Microsoft.CodeAnalysis;
using Microsoft.Generator.CSharp;
using Microsoft.Generator.CSharp.ClientModel;
using Microsoft.Generator.CSharp.Input;
using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;

namespace Azure.Generator;

Expand Down Expand Up @@ -56,4 +58,9 @@ public override void Configure()
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
""";

/// <summary>
/// Identify if the input is generated for Azure ARM.
/// </summary>
internal Lazy<bool> IsAzureArm => new Lazy<bool>(() => InputLibrary.InputNamespace.Clients.Any(c => c.Decorators.Any(d => d.Name.Equals("Azure.ResourceManager.@armProviderNamespace"))));
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading