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

[Bug]: propagation of usage flags makes base model type usage ambiguous #1827

Closed
4 tasks done
jhendrixMSFT opened this issue Nov 7, 2024 · 0 comments
Closed
4 tasks done
Assignees
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@jhendrixMSFT
Copy link
Member

Describe the bug

Some change in 0.47.x causes usage flags to propagate from derived type to base type. This means that it's no longer possible to identify base types that aren't explicitly annotated.

For Go, which does not have inheritance, we omit base types by default unless they're explicitly referenced (directly or transitively) via an operation.

For model-only builds we can only rely on usage flags to control the output. Now that these flags are propagated, the usage on base model types is ambiguous.

Reproduction

For the following tsp, BaseClassThatsPruned has a usage of output even though it's not explicitly annotated as such.

import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;

@service({
  title: "ModelsOnly",
})
namespace ModelsOnly;

model BaseClassThatsPruned {
    id: int32;
}

model DerivedOne extends BaseClassThatsPruned {
    name: string;
}

model PreservedBaseClass {
    id: int32;
}

model DerivedTwo extends PreservedBaseClass {
    name: string;
}

@@access(ModelsOnly.PreservedBaseClass, Access.public);
@@access(ModelsOnly.DerivedOne, Access.public);
@@access(ModelsOnly.DerivedTwo, Access.public);
@@usage(ModelsOnly.PreservedBaseClass, Usage.output);
@@usage(ModelsOnly.DerivedOne, Usage.output);
@@usage(ModelsOnly.DerivedTwo, Usage.output);

Checklist

  • Follow our Code of Conduct
  • Check that this issue is about the Azure libraries for typespec. For bug in the typespec language or core libraries file it in the TypeSpec repo
  • Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@jhendrixMSFT jhendrixMSFT added bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library labels Nov 7, 2024
@tadelesh tadelesh self-assigned this Nov 11, 2024
tadelesh added a commit that referenced this issue Nov 13, 2024
…ception usage from output usage (#1834)

resolve: #1827

add `disableUsageAccessPropagationToBase` flag: this flag aims to
support language that does not generate base model, it will skip the
base model's propagation but will not skip the property or subtype of
the base model.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

2 participants