Skip to content
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

[core] Empty parameter visibility and visibility string deprecation #6088

Merged

Conversation

witemple-msft
Copy link
Member

@witemple-msft witemple-msft commented Feb 20, 2025

  • Makes the necessary core/http changes to deprecate
    • parameterVisibility/returnTypeVisibility with no arguments.
    • use of string visibility modifiers.
    • LegacyParameterVisibility HTTP flag.
  • Deprecations are raised as warnings visibility-legacy and will be converted to errors in 1.0-rc.
  • Numerous tests and samples have been updated to replace use of string visibility modifiers with Lifecycle modifiers.
  • Deprecation messages for deprecated APIs have been updated to indicate that they will be REMOVED in 1.0-rc.
  • Added PatchOptions/getPatchOptions which now controls Visibility.Patch.

WIP:

  • Replace uses of string-based visibility modifiers throughout Azure specs with Lifecycle modifiers (required to avoid breaking the specs repo).
  • Replace uses of empty parameter visibility constraints throughout Azure Specs with PatchOptions.
  • Remove uses of deprecated visibility analysis methods throughout Azure TypeSpec libraries/emitters (can be done between now and 1.0-rc if not before the next release).

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 20, 2025

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @typespec/http-client-csharp

The following packages have already been documented:

  • @typespec/compiler
  • @typespec/http-specs
  • @typespec/http
  • @typespec/openapi
  • @typespec/rest
Show changes

@typespec/compiler - deprecation ✏️

Deprecate use of string-based visibility modifiers using warnings.,> ,> String-based visibilities can be replaced as follows:,> ,> - "create", "read", "update", "delete", and "query" can be replaced with Lifecycle.Create, Lifecycle.Read, Lifecycle.Update, Lifecycle.Delete, and Lifecycle.Query respectively.,> - @visibility("none") can be replaced with @invisible(Lifecycle).,> ,> For example:,> ,> tsp,> @visibility("create", "read"),> example: string;,> ,> ,> can be replaced with:,> ,> tsp,> @visibility(Lifecycle.Create, Lifecycle.Read),> example: string;,> ,> ,> tsp,> @visibility("none"),> example: string;,> ,> ,> can be replaced with:,> ,> tsp,> @invisible(Lifecycle),> example: string;,> ,> ,> Additionally, @parameterVisibility with no arguments is deprecated.,> ,> tsp,> @parameterVisibility,> @patch,> op example(@bodyRoot resource: Resource): Resource;,> ,> ,> The effect of @parameterVisibility is to disable effective PATCH optionality. If you wish,> to disable effective PATCH optionality in @typespec/http, preventing it from treating all,> properties of the request body as effectively optional, you can now do so explicitly:,> ,> tsp,> @patch(#{ implicitOptionality: false }),> op example(@bodyRoot resource: Resource): Resource;,>

@typespec/http-specs - internal ✏️

Replace use of string-based visibility modifiers with enum-based Lifecycle modifiers in tests.

@typespec/http - internal ✏️

Replace use of string-based visibility modifiers with enum-based Lifecycle modifiers in tests.

@typespec/rest - internal ✏️

Replace use of string-based visibility modifiers with enum-based Lifecycle modifiers in tests.

@typespec/openapi - internal ✏️

Remove references to string-based visibility from function documentation.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 20, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@witemple-msft
Copy link
Member Author

Azure companion PR: Azure/typespec-azure#2263

@witemple-msft witemple-msft added this pull request to the merge queue Feb 28, 2025
Merged via the queue into microsoft:main with commit 2d2f81f Feb 28, 2025
35 checks passed
@witemple-msft witemple-msft deleted the witemple-msft/visibility-1_0 branch February 28, 2025 17:34
github-merge-queue bot pushed a commit to Azure/typespec-azure that referenced this pull request Feb 28, 2025
This is the Azure companion of
microsoft/typespec#6088

- Replaces all uses in tests/samples of string visibility modifiers with
Lifecycle concepts.
- Replaces use of `@parameterVisibility()` with `@patch(#{
implicitOptionality: false })` as needed.
- Replaces all usage of deprecated visibility analysis APIs with
Lifecycle-based equivalents
- Updates lint rules to use more robust methods of detecting visibility
requirements.

Before merge:
- [x] Validate and change specs in azure-rest-api-specs as needed.
- [x] Merge microsoft/typespec PR
- [x] Reset .gitmodules to point to core repo main branch
- [x] Update `core` submodule to microsoft/typespec main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants