Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
11 stars 37 forks source link

[Bug]: Unable to apply different templates for operation in different versions #993

Closed live1206 closed 3 months ago

live1206 commented 3 months ago

Describe the bug

We need to apply different templates for update operation in different versions as below, but complier is complaining duplication of update

  @renamedFrom(Versions.v1, "update")
  @removed(Versions.v2)
  update1 is ArmResourcePatchSync<Employee, EmployeeProperties>;

  @added(Versions.v2)
  @parameterVisibility
  update is ArmCustomPatchAsync<Employee, Employee>;
 error interface-duplicate Interface already has a member named update

Reproduction

Details

Checklist

timotheeguerin commented 3 months ago

You have to give it a different name in the old one playground


  @renamedFrom(Versions.v1, "update")
  @removed(Versions.v2)
  @sharedRoute
  updateOld is ArmResourcePatchSync<Employee, EmployeeProperties>;

  @added(Versions.v2)
  @parameterVisibility
  @sharedRoute
  update is ArmCustomPatchAsync<Employee, Employee>;
markcowl commented 3 months ago

As timothee showed, here is a playground showing this

live1206 commented 3 months ago

You have to give it a different name in the old one playground


  @renamedFrom(Versions.v1, "update")
  @removed(Versions.v2)
  @sharedRoute
  updateOld is ArmResourcePatchSync<Employee, EmployeeProperties>;

  @added(Versions.v2)
  @parameterVisibility
  @sharedRoute
  update is ArmCustomPatchAsync<Employee, Employee>;

I did try to give it a different name for the old one, the key is @sharedRoute. Thanks for the help, @timotheeguerin

tadelesh commented 3 months ago

oh, @sharedRoute. but i do think typespec should introduce way to versioning decorator instead of using track to handle it since lots of protocol level breaking changes are from decorators.