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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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


private ConstructorSignature InitializationConstructorSignature => _publicConstructor ??= EnsurePublicConstructorSignature();
private ConstructorSignature SerializationConstructorSignature => _serializationConstructor ??= EnsureSerializationConstructorSignature();

Expand Down
Expand Up @@ -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.


private AspDotNetExtensionTypeProvider? _aspDotNetExtension;
public AspDotNetExtensionTypeProvider AspDotNetExtension => _aspDotNetExtension ??= new AspDotNetExtensionTypeProvider(RestClients, Configuration.Namespace, _sourceInputModel);
Expand Down