-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Minimal Reproduction Spec
Add the following TypeSpec to the mgmt test project (or a standalone spec) and regenerate:
import "@typespec/http";
import "@typespec/rest";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
using TypeSpec.Http;
using TypeSpec.Rest;
using Azure.ResourceManager;
@armProviderNamespace
@service({
title: "Repro Service",
})
@versioned(Versions)
namespace Repro.Service;
enum Versions {
@useDependency(Azure.ResourceManager.Versions.v1_0_Preview_1)
v2024_01_01: "2024-01-01",
}
model ReproResource
is Azure.ResourceManager.TrackedResource<ReproProperties, false> {
...ResourceNameParameter<
Resource = ReproResource,
KeyName = "reproName",
SegmentName = "repros"
>;
/** The managed service identities assigned to this resource. */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property"
identity?: Azure.ResourceManager.CommonTypes.ManagedServiceIdentity;
}
model ReproProperties {
provisioningState?: string;
displayName?: string;
}
@armResourceOperations
interface ReproResources {
get is ArmResourceRead<ReproResource>;
createOrUpdate is ArmResourceCreateOrUpdateAsync<ReproResource>;
delete is ArmResourceDeleteWithoutOkAsync<ReproResource>;
listByResourceGroup is ArmResourceListByParent<ReproResource>;
listBySubscription is ArmListBySubscription<ReproResource>;
}Key triggering pattern
The distinguishing factor is the direct identity? envelope property on the resource model:
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property"
identity?: Azure.ResourceManager.CommonTypes.ManagedServiceIdentity;The local test project's JobResource (databox.tsp) uses the same TrackedResource<T, false> base but does not have a direct identity envelope property, and generates correctly with TrackedResourceData as the base class.
Expected output
public partial class ReproResourceData : TrackedResourceDataActual output (with published npm package)
public partial class ReproResourceData : ArmResourceBug Description
When regenerating the NewRelic SDK (Azure.ResourceManager.NewRelicObservability) using the published npm package @azure-typespec/http-client-csharp-mgmt@1.0.0-alpha.20260314.2, the generator emits wrong base classes:
NewRelicMonitorResourceData : ArmResource— should be: TrackedResourceDataNewRelicMonitorResource.Serialization.csredundantly adds: ArmResourceto the partial declaration — should only have: IJsonModel<NewRelicMonitorResourceData>
This causes build error CS0115: no suitable method found to override because ArmResource doesn't have JsonModelWriteCore.
Reproduction
- Regenerate the NewRelic SDK:
tsp-client update --output-dir sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability - Build:
dotnet build sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/src - Observe
CS0115errors onNewRelicMonitorResourceData.JsonModelWriteCore
Expected Behavior
NewRelicMonitorResourceData should inherit from TrackedResourceData (matching the TypeSpec definition is Azure.ResourceManager.TrackedResource<MonitorProperties, false>).
Investigation Findings
- The local generator test project (
Mgmt-TypeSpec) correctly generatesTrackedResourceDatafor the same pattern (TrackedResource<T, false>indatabox.tsp→JobResourceData : TrackedResourceData). - The bug only reproduces when using the published npm package (
@azure-typespec/http-client-csharp-mgmt@1.0.0-alpha.20260314.2), not the local build. - The bug is likely in the published generator DLL or the
@typespec/http-client-csharp@1.0.0-alpha.20260313.1dependency bundled in the npm package. - The mgmt emitter does not modify
baseModel— the issue originates upstream in the code model generation.
TypeSpec Definition (NewRelic)
model NewRelicMonitorResource
is Azure.ResourceManager.TrackedResource<MonitorProperties, false> {
...ResourceNameParameter<...>
identity?: Azure.ResourceManager.CommonTypes.ManagedServiceIdentity;
}Affected Package
@azure-typespec/http-client-csharp-mgmt@1.0.0-alpha.20260314.2- SDK:
Azure.ResourceManager.NewRelicObservability