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]: don't overwrite explicit access with calculated access #1824

Open
4 tasks done
jhendrixMSFT opened this issue Nov 7, 2024 · 2 comments
Open
4 tasks done

[Bug]: don't overwrite explicit access with calculated access #1824

jhendrixMSFT opened this issue Nov 7, 2024 · 2 comments
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

If a type has explicitly set @@access, that value shouldn't be overwritten by a calculated value.

Reproduction

For the following tsp, I expect that BaseClassThatsPruned should have its access set to internal. However, it's set to public.

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.BaseClassThatsPruned, Access.internal);
@@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
Copy link
Member

tadelesh commented Nov 8, 2024

we do not allow override a model that needs to be public to internal currently. but it seems to be a reasonable for go scenario. i'd like to collect more thought for this. @Azure/dpg-devs

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Nov 8, 2024

Maybe this be language specific?

I guess Java won't compile pass, if BaseClassThatsPruned be not public/exported, but its subclass DerivedOne be public.

I am fine as long as user won't do this to Java... Unless they know what to follow up (with customization etc.) on this.

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

3 participants