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

fix(generator): do not keep azure.core models #4598

Closed
wants to merge 1 commit into from

Conversation

archerzz
Copy link
Member

Description

Even the accessibility is set, we should not keep them since they should be referenced from Azure.Core

resolve #4597

Checklist

To ensure a quick review and merge, please ensure:

  • The PR has a understandable title and description explaining the why and what.
  • The PR is opened in draft if not ready for review yet.
    • If opened in draft, please allocate sufficient time (24 hours) after moving out of draft for review
  • The branch is recent enough to not have merge conflicts upon creation.

Ready to Land?

  • Build is completely green
    • Submissions with test failures require tracking issue and approval of a CODEOWNER
  • At least one +1 review by a CODEOWNER
  • All -1 reviews are confirmed resolved by the reviewer
    • Override/Marking reviews stale must be discussed with CODEOWNERS first

Even the accessibility is set, we should not keep them since they should be referenced from Azure.Core

resovle Azure#4597
@archerzz
Copy link
Member Author

I cherrypick this change to my TCGC PR.
-The regen PR is Azure/azure-sdk-for-net#43495

@@ -58,7 +58,7 @@ public DpgOutputLibrary(string libraryName, IReadOnlyDictionary<InputEnumType, E

private IEnumerable<string>? _accessOverriddenModels;
public IEnumerable<string> AccessOverriddenModels => _accessOverriddenModels ??= Enums.Where(e => e.IsAccessibilityOverridden).Select(e => e.Declaration.Name)
.Concat(Models.Where(m => m.IsAccessibilityOverridden).Select(m => m.Declaration.Name));
.Concat(Models.Where(m => m.IsAccessibilityOverridden && (m.Namespace == null || !m.Namespace.StartsWith("Azure.Core"))).Select(m => m.Declaration.Name));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well if this is the reason, I think we do not need to fix this because this really looks like a workaround, and we should not do this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have to fix, maybe we should let emitter not generate models from azure.core. There is a flag in TCGC that to filter out azure.core models.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot let TCGC filter out core models, because that will break other cases for emitter. and I remember in generator we already filter out core models?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our emitter could do this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Previously I thought our generator will remove core types. If that assumption is false, then it makes sense to filter out in emitter.

@@ -48,6 +48,9 @@ internal sealed class ModelTypeProvider : SerializableObjectType
protected override bool IsAbstract => !Configuration.SuppressAbstractBaseClasses.Contains(DefaultName) && _inputModel.DiscriminatorPropertyName is not null && _inputModel.DiscriminatorValue is null;

public ModelTypeProviderFields Fields => _fields ??= EnsureFields();

public string? Namespace => _inputModel.Namespace;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this property is kind of misleading because the namespace of a model in its generated code should be found in Declaration.Namespace instead of this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I can change it into OriginalNamespace or something like that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that does not make sense either, this type is an "output type", it really should not provide anything that is not used in output

@archerzz archerzz closed this Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[generator]: do not keep a class under Azure.Core namespace even if its accessibility is internal
3 participants