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
Conversation
Even the accessibility is set, we should not keep them since they should be referenced from Azure.Core resovle Azure#4597
I cherrypick this change to my TCGC PR.
|
@@ -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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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:
Ready to Land?