microsoft / typespec

https://typespec.io/
MIT License
4.49k stars 214 forks source link

Decide how to handle Usage when it comes to readonly properties #4662

Closed JoshLove-msft closed 1 week ago

JoshLove-msft commented 1 month ago

In Autorest, Usage determines if a property has a setter or for collections, if it is generated as IReadOnlyList/IReadOnlyDictionary. Currently, in MGC, we only use the readonly decorator. If we were to respect usage, adding an input usage to a model would result in a breaking change that we'd have to account for with some back compat strategy. This seems unexpected as the user never said the property MUST NOT be modified, like they would be saying if they used the readonly decorator. For non-collection properties, it would be OK to support usage because adding a setter is not breaking.

JoshLove-msft commented 1 week ago

Might be worth filing an issue to Typespec to allow visibility to be set on a model.

JoshLove-msft commented 1 week ago

https://github.com/microsoft/typespec/issues/4952