-
Notifications
You must be signed in to change notification settings - Fork 228
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
feat(versioning): add code fixes for incompatible version errors #5459
base: main
Are you sure you want to change the base?
feat(versioning): add code fixes for incompatible version errors #5459
Conversation
- add code fixes for most of incompatible version errors - fix inconsistent error message formats - add unit test case - remove redudant codes resolve microsoft#4842
@@ -208,13 +209,6 @@ export function $onValidate(program: Program) { | |||
validateVersionedNamespaceUsage(program, namespaceDependencies); | |||
} | |||
|
|||
function getAllVersions(p: Program, t: Type): Version[] | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's already defined in versioning.ts
:
function getAllVersions(p: Program, t: Type): Version[] | undefined { |
All changed packages have been documented.
|
You can try these changes here
|
@@ -799,8 +798,7 @@ function validateAvailabilityForRef( | |||
targetAvail: Map<string, Availability>, | |||
source: Type, | |||
target: Type, | |||
sourceOptions?: TypeNameOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those two parameters are never really passed in, so I delete them for simplicity
@@ -162,7 +162,7 @@ describe("versioning: validate incompatible references", () => { | |||
expectDiagnostics(diagnostics, { | |||
code: "@typespec/versioning/incompatible-versioned-reference", | |||
message: | |||
"'TestService.test' is referencing versioned type 'TestService.Foo' but is not versioned itself.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like we don't compare the error message in unit testing, but I update them anyway
A few issues worth mentioning. Fix Parameter VersionsI cannot insert @added(Versions.v2)
model Foo {}
op test(param: Foo): void; Ideally, it should be op test(@added(Version.V2)
param:Foo): void; The reason is that the type of Fix by InsertionIn this PR, I only provide fixes to insert @added(Versions.V3)
@added(Versions.V2) // a better fix is to replace `@added(Versions.V3)`
model Foo {}; @removed(Versions.V2)
@added(Versions.V2) // a better fix is to delete `@removed(Versions.V2)`
model Foo{}; Alternative fixesSome error cases can have other ways to fix. But that requires more context which is not available in the validation logic, unless we do more changes. For example, @added(Versions.v3)
model Foo {}
model Bar {
foo: Foo;
} The error is reported on |
resolve #4842