-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add @useSystemTextJsonConverter
decorator for csharp
#1230
Closed
Closed
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0e4606a
wip
live1206 ddcdc82
wip
live1206 a4ba0b3
add changelog and fix format
live1206 5668ad7
set sub-namespace for decorator
live1206 8f35f17
clean up
live1206 79effb3
Merge branch 'main' into json-converter
live1206 8cb7069
fix format
live1206 c532e9c
Merge branch 'json-converter' of https://github.com/live1206/typespec…
live1206 6d37315
fix format
live1206 1d26dfb
update doc
live1206 843aab5
Merge branch 'main' into json-converter
live1206 4e35b0b
regen docs
live1206 b51bfc8
Merge branch 'json-converter' of https://github.com/live1206/typespec…
live1206 2a8904c
update doc
live1206 bdec73d
rename to hasJsonConverter
live1206 796dda8
Merge branch 'main' into json-converter
live1206 e278c4f
update namespace
live1206 f9ffd8b
remove scope and implementation
live1206 4e37acd
regen
live1206 c385ce0
Merge branch 'main' into json-converter
live1206 1e9758d
Merge branch 'main' into json-converter
live1206 c558a6e
move decorator to root namespace
live1206 f5d5474
Merge branch 'main' into json-converter
live1206 a4d3e0e
fix test
live1206 bf00958
fix format
live1206 e796bd4
regen docs
live1206 1c499e7
add scope to implementation
live1206 4e0c38b
rename to useSystemTextJsonConverter
live1206 1fd1583
fix format
live1206 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
changeKind: feature | ||
packages: | ||
- "@azure-tools/typespec-client-generator-core" | ||
--- | ||
|
||
Add `@hasJsonConverter` for csharp only to indicate if JSON converter is needed | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/typespec-client-generator-core/generated-defs/Azure.ClientGenerator.Core.CSharp.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { DecoratorContext, Model } from "@typespec/compiler"; | ||
|
||
/** | ||
* Whether a model needs the custom JSON converter, this is only used for backward compatibility for csharp. | ||
* | ||
* @example | ||
* ```typespec | ||
* @hasJsonConverter | ||
* model MyModel { | ||
* prop: string; | ||
* } | ||
* ``` | ||
*/ | ||
export type HasJsonConverterDecorator = (context: DecoratorContext, target: Model) => void; |
12 changes: 12 additions & 0 deletions
12
...ypespec-client-generator-core/generated-defs/Azure.ClientGenerator.Core.CSharp.ts-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** An error here would mean that the decorator is not exported or doesn't have the right name. */ | ||
import { $hasJsonConverter } from "@azure-tools/typespec-client-generator-core"; | ||
import type { HasJsonConverterDecorator } from "./Azure.ClientGenerator.Core.CSharp.js"; | ||
|
||
type Decorators = { | ||
$hasJsonConverter: HasJsonConverterDecorator; | ||
}; | ||
|
||
/** An error here would mean that the exported decorator is not using the same signature. Make sure to have export const $decName: DecNameDecorator = (...) => ... */ | ||
const _: Decorators = { | ||
$hasJsonConverter, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
lets rename to @useSystemTextJsonConverter to make it more explicit what this is used for.
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.
renamed
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.
I'll say it feels quite weird having this at the root of Tcgc namespace with this name that is very csharp specific
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.
I think this is indeed csharp specific only decorator.
@timotheeguerin Are you implying we should keep it within csharp sub-namespace if we ensure it will not be used for other languages?
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.
Yeah just feels like this is not super compatible with the new approach of using a shared name and scope.
But if you feel like it's best then I'm not blocking or anything
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.
We have decided that language-specific decorators will go in the main namespace because of grow-up, but they will have to specify the scope, and we have an issue to have linter warnings if a decorator is applied to emitters that won't do anything with it.
My question with this PR is more: I thought we had decided that there was a use case for Java here too, and that there was going to be a redesign of this decorator (most likely just a rename), that would make it compatible with Java's scenario as well