microsoft / microsoft/typespec

[Bug]: FilterVisibility strips visibility decorators

Open
#11,952 5 comments 1 reaction 0 assignees View on GitHub
compiler:core feature triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

### Describe the bug

Applying FilterVisibility strips visibility decorators from the resulting Model.
How to keep them for further filtering?
TIA

### Reproduction

```tsp
using Reflection;

@defaultVisibility(Marker.none)
internal enum Marker {
none,
filter,
order,
link,
}

internal model GuessListType { ...FilterVisibility }
internal model GuessOrderType { ...FilterVisibility }

model Foo {
@visibility(Marker.filter) @visibility(Marker.order) @visibility(Lifecycle.Read) @key id: string,
@visibility(Marker.filter) @visibility(Marker.order) prop: int32,
@visibility(Marker.link) links: int32[],
}

model FooList is GuessListType {} // CORRECT: id, prop
model FooOrder is GuessOrderType {} // INCORRECT: empty, should be id, prop
```

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Contributor guide

Open the contributing guide

Research direction

Start with the minimal TypeSpec reproduction and inspect FilterVisibility, Reflection, and the visibility decorators used on Foo, FooList, and FooOrder. Done means decorators are preserved after the first filtering step so applying FilterVisibility again produces FooOrder with id and prop rather than an empty model.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.