Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/typespec-rust/.scripts/tspcompile.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const azureHttpSpecsGroup = {
'spector_apiverheader': {input: 'azure/client-generator-core/api-version/header/client.tsp'},
'spector_apiverpath': {input: 'azure/client-generator-core/api-version/path/client.tsp'},
'spector_apiverquery': {input: 'azure/client-generator-core/api-version/query/client.tsp'},
'spector_client_default_value': {input: 'azure/client-generator-core/client-default-value'},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The decorator is part of the legacy namespace Azure.ClientGenerator.Core.Legacy.clientDefaultValue. Do we want/need to support this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the question I am asking in this PR. Do you think we should? I will also ask @heaths.
In the current state of the PR, we won't support it, because not implementing it is cheaper than implementing and throwing it away, and my thought was also that we maight want to not support it. But that can be done, relatively inexpensively, I think. We would emit a couple of impl Default for ...s.

I'd only say, if not supporting it is the intended behavior, there is no reason to not report it to Spector, as if we have a problem, as if something yet needs to be covered. If we think that we're, at least currently, view it as that we don't intend to support that, let's still run the tests to keep them green. The tests will formalize the semantics, and will state that it is intentional.

If we change this decision in the future, we can update the emitter code, and also update the tests.
From the prespective of not having breaking changes in the future, it seems ok to me to not implement it now if we're not sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For model properties it's a pretty easy change and there's no compat problems.

The interesting case is for method parameters. If a required method param has a client-side default value, then it becomes optional which would clearly be a breaking change.

If the scope is models only then I agree that we don't have to decide now. Are there any params?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracking issue #898

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per #898, this PR should implement Default for options and models, and as for the function parameter, it would move it to options (and implement Default the same way). Sounds good.
Please let me know if that is not what you'd like to see.
I will prioritize updating this PR after the current release blockers are fixed.

'spector_clientinit_default': {input: 'azure/client-generator-core/client-initialization/default'},
'spector_clientinit_individually': {input: 'azure/client-generator-core/client-initialization/individually'},
'spector_clientinit_individually_parent': {input: 'azure/client-generator-core/client-initialization/individuallyParent'},
Expand Down
9 changes: 9 additions & 0 deletions packages/typespec-rust/test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/typespec-rust/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ members = [
"spector/azure/client-generator-core/api-version/path",
"spector/azure/client-generator-core/api-version/query",
"spector/azure/client-generator-core/alternate-type",
"spector/azure/client-generator-core/client-default-value",
"spector/azure/client-generator-core/client-initialization/default",
"spector/azure/client-generator-core/client-initialization/individually",
"spector/azure/client-generator-core/client-initialization/individuallyParent",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "spector_client_default_value"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true

[features]
default = ["azure_core/default"]

[dependencies]
azure_core = { workspace = true }
serde = { workspace = true }

[dev-dependencies]
tokio = { workspace = true }

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading