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

[core] Fix enum-driven visibility consistency issues when projections are used #5525

Merged

Conversation

witemple-msft
Copy link
Member

  • Changed getLifecycleVisibilityEnum to honor projections when program is a ProjectedProgram.
  • Taught Projector to project EnumValue values only, so that they remain consistent with projected Enum and EnumMember references. If the projection of the underlying EnumMember does not result in another EnumMember (i.e. it projects to some other type, which I think should be rare, but possible according to the type system), the projector gives up and returns the original enum member.

A more complex solution would try to project all values, but this could damage the scalar hierarchy and there is an open issue to consider removing projections in favor of mutators in the future.

Closes #5450
Closes #5461

@witemple-msft witemple-msft added the compiler:core Issues for @typespec/compiler label Jan 8, 2025
@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 8, 2025

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

Enum-driven visibility decorators and projections now interact correctly.,> ,> Projections now project EnumValue values to preserve consistency with projected Enum/EnumMember types using a best-effort,> strategy.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 8, 2025

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs 🛝 VSCode Extension

@witemple-msft
Copy link
Member Author

No error as expected

validated property removed from schema User as expected.

Copy link
Member

@bterlson bterlson left a comment

Choose a reason for hiding this comment

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

I approve of this hack.

@witemple-msft witemple-msft added this pull request to the merge queue Jan 8, 2025
Merged via the queue into microsoft:main with commit abd3664 Jan 8, 2025
24 checks passed
@witemple-msft witemple-msft deleted the witemple/visibility-projection-fix branch January 8, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler
Projects
None yet
4 participants