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

Add AdditionalPropertiesDescription property to ObjectType #15990

Merged
merged 7 commits into from
Jan 7, 2025

Conversation

levimatheri
Copy link
Contributor

@levimatheri levimatheri commented Jan 2, 2025

Resolves #13893.

@levimatheri levimatheri requested a review from Copilot January 2, 2025 22:54

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 18 changed files in this pull request and generated no comments.

Files not reviewed (13)
  • src/Bicep.Core/TypeSystem/Providers/MicrosoftGraph/MicrosoftGraphResourceTypeProvider.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/ResourceDerivedTypeResolver.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/ThirdParty/ExtensibilityResourceTypeFactory.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/ThirdParty/ThirdPartyResourceTypeProvider.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/DeclaredTypeManager.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/Az/AzResourceTypeFactory.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/Az/AzResourceTypeProvider.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/K8s/K8sResourceTypeProvider.cs: Evaluated as low risk
  • src/Bicep.LangServer.IntegrationTests/HoverTests.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Types/NamespaceType.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/TypeValidator.cs: Evaluated as low risk
  • src/Bicep.Core.UnitTests/Utils/BuiltInTestTypes.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/TypeHelper.cs: Evaluated as low risk
Comments suppressed due to low confidence (2)

src/Bicep.Core/Emit/CompileTimeImports/ArmDeclarationToExpressionConverter.cs:385

  • Ensure that the new behavior of setting additionalPropertiesDescription is covered by tests.
additionalPropertiesDescription: addlProperties?.Description is StringLiteralExpression stringLiteral ? stringLiteral.Value : null),

src/Bicep.Core/Semantics/SymbolHelper.cs:61

  • The objectType.AdditionalPropertiesDescription might be null. Ensure that null values are handled appropriately.
return new PropertySymbol("*", objectType.AdditionalPropertiesDescription, objectType.AdditionalPropertiesType.Type);
Copy link
Contributor

github-actions bot commented Jan 2, 2025

Test this change out locally with the following install scripts (Action run 12657034838)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 12657034838
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 12657034838"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 12657034838
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 12657034838"

Copy link
Contributor

github-actions bot commented Jan 2, 2025

Dotnet Test Results

    77 files   -     38      77 suites   - 38   31m 41s ⏱️ - 17m 13s
11 581 tests  -     20  11 581 ✅  -     20  0 💤 ±0  0 ❌ ±0 
26 894 runs   - 13 421  26 894 ✅  - 13 421  0 💤 ±0  0 ❌ ±0 

Results for commit b7c1de9. ± Comparison against base commit 73f3473.

This pull request removes 1840 and adds 636 tests. Note that renamed tests count towards both.

		nestedProp1: 1
		nestedProp2: 2
		prop1: true
		prop2: false
	1
	2
	\$'")
	prop1: true
	prop2: false
…
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
�Խ
�0\u0010\u0000��>E�\u0003��4?V� 8X�*\u0008�\u0012l�
��V(�\uda58\udcf8���G0ߘ;��玸{]�\u0013\u001d'EI\u0018��%�o`H�[�\u001b�+D�\u001b PBH�p�{%-\u001ee�\u000bS�\u0018{� 6ǺJ�$�ʓ\u000c|�>\u0001�$erfb�\u0018��]W� ��&��7�YW��Ǵ:|�o�+����823�S���;\u0008�\u0010&\u001b�ғ���O'���m�:m\u000e��Y`3���ɲ,�\u001a�\u000b�$V�\u0000\u000c\u0000\u0000,"'7' is an invalid end of a number. Expected a delimiter. Path: $.INVALID_JSON | LineNumber: 0 | BytePositionInLine: 20.")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
��K
�0\u0010\u0000Ь=E�\u0001�ͧ\u0015�w#��\u0000�\u001d�bki+\u0014Ļ�.�M��~\u0004�V!3��g��{�nѤX��\u0017J�\u0019\u0019\u001bXJ���\u000e\u0017�p�\u0006\u0004���\u0010ڎ^I�{ݘʖ2�Z?�\u000f�i�\u001cc�\u0003�C\u0004<b`�Q\u0010�l,\u0019�\ud8e1\udda69�Y�b�.���������\u000c���tG���!\u0010��\u0001�\u0006���!�����g��?��\u0007�\u000e\u0005�%&
�;̏Xy\u001bz2�\u001a�K��8��L�\u0005_���\u0000\u000c\u0000\u0000,"Value cannot be null. (Parameter 'source')")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
��K\u000e�0\u0010\u0006�=EOPf�@a�ޥWh��G(\u0006J$1��aa�\u0002�\u0006��~�i&�>~\u0015�l�-��lZ�)�H��\u0001K�F�\u0003LP�y\u0001\u0001&ነ�쓌�Zo\u001b\u001ee��~�Τ���,�ĩ�\u001c0W�Y�\u0019mxm?���j������7��m톆j�a�\u0006����[W�)�\u0000Z �؀A�9��$Σ\$�����c�	� \u0008�5<\u0001���\u001f\u0000\u000c\u0000\u0000,"The path: index.json was not found in artifact contents")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003��K
�0\u0010\u0006�=E�\u0001�yY�{7�\u001b\u000f\u0010툊���\u0010\u0010�n�\u00107-n�\u0003̷�\u000c̄��MW�/�\u0016�8&�ʦ��
\u0002-e�y�KC�y\u0000\u0002F��M������6a�O��A���Pb΍�)�2!\u0019H��)���v��3Z�v�\u001f�\u0002=;�sյ�C�߾f4��~��*� $	��0`8HM@+���#����_i���׸m�Xb��&�ӝ=9�}{�(���}�\u0005]�N\u0000\u000c\u0000\u0000,"Value cannot be null. (Parameter 'source')")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003��K
�0\u0010\u0006�{
O\u0010g�c��}��Bh�>0\u0016�T(�{�Ѕҍ�B�-3\u000c3a�y�������i�P*O9�\u001b\u0004Z���\u0001*dH/���"ƒ~�MFt��MXe�Y?(3����,�����B�\u001c�\u0011RoBm?Y��j������7��m톆j�a�F�����\u0019��\u000f�1�$\u0008\u0008A���\u0014:���L�y�7��(���\u0004��6A\u0000\u000c\u0000\u0000,"The path: index.json was not found in artifact contents")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003���\u000b�0\u0014\u0007��+�?`��\�!�\u0011\u0016\u0004]c� \u0003-�@�o\u001e���E-h����1�\u000f\u0006;ݬ�NMYAʹ
 \u0018\u001a�\u0004c��-�$��\u0005\u0001$���^3�$\u001d�U�K;�\u0014�~\u0010	=]g������PQ
�P$���ޝ���n�>GY��\u0006^�kі�}��~����������D\u0018�;�J$1b\u001c �9���$�����\u001f'��&^\u001e��m��=���=��8�3�'\u0005؀�\u0000\u000c\u0000\u0000,"'7' is an invalid end of a number. Expected a delimiter. Path: $.INVALID_JSON | LineNumber: 0 | BytePositionInLine: 20.")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Repository_not_found_in_registry (ArtifactRegistryAddress { RegistryAddress = mcr.microsoft.com, RepositoryPath = unknown/path/az, ExtensionVersion = 0.0.0-placeholder },Azure.RequestFailedException: The artifact does not exist in the registry.
   at Bicep.Core.Registry.AzureContainerRegistryManager.DownloadManifestAndLayersAsync(IOciArtifactReference artifactReference, ContainerRegistryContentClient client) in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs:line 138
   at Bicep.Core.Registry.AzureContainerRegistryManager.DownloadManifestAndLayersAsync(IOciArtifactReference artifactReference, ContainerRegistryContentClient client) in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs:line 138,[(BCP192, Error, Unable to restore the artifact with reference "br:mcr.microsoft.com/unknown/path/az:0.0.0-placeholder": The artifact does not exist in the registry.)])
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Repository_not_found_in_registry (ArtifactRegistryAddress { RegistryAddress = mcr.microsoft.com, RepositoryPath = unknown/path/az, ExtensionVersion = 0.0.0-placeholder },Azure.RequestFailedException: The artifact does not exist in the registry.
   at Bicep.Core.Registry.AzureContainerRegistryManager.DownloadManifestAndLayersAsync(IOciArtifactReference artifactReference, ContainerRegistryContentClient client) in D:\a\bicep\bicep\src\Bicep.Core\Registry\AzureContainerRegistryManager.cs:line 138
   at Bicep.Core.Registry.AzureContainerRegistryManager.DownloadManifestAndLayersAsync(IOciArtifactReference artifactReference, ContainerRegistryContentClient client) in D:\a\bicep\bicep\src\Bicep.Core\Registry\AzureContainerRegistryManager.cs:line 138,[(BCP192, Error, Unable to restore the artifact with reference "br:mcr.microsoft.com/unknown/path/az:0.0.0-placeholder": The artifact does not exist in the registry.)])
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Repository_not_found_in_registry (ArtifactRegistryAddress { RegistryAddress = unknown.registry.azurecr.io, RepositoryPath = bicep/extensions/az, ExtensionVersion = 0.0.0-placeholder },System.AggregateException: Retry failed after 4 tries. Retry settings can be adjusted in ClientOptions.Retry or by configuring a custom retry policy in ClientOptions.RetryPolicy. (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443))
   at Bicep.Core.Registry.AzureContainerRegistryManager.DownloadManifestAndLayersAsync(IOciArtifactReference artifactReference, ContainerRegistryContentClient client) in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs:line 138
   at Bicep.Core.Registry.AzureContainerRegistryManager.<>c__DisplayClass4_0.<<PullArtifactAsync>g__DownloadManifestInternalAsync|0>d.MoveNext() in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs:line 44
--- End of stack trace from previous location ---
   at Bicep.Core.Registry.AzureContainerRegistryManager.PullArtifactAsync(RootConfiguration configuration, IOciArtifactReference artifactReference) in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs:line 51
   at Bicep.Core.Registry.AzureContainerRegistryManager.DownloadManifestAndLayersAsync(IOciArtifactReference artifactReference, ContainerRegistryContentClient client) in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs:line 138
   at Bicep.Core.Registry.AzureContainerRegistryManager.<>c__DisplayClass4_0.<<PullArtifactAsync>g__DownloadManifestInternalAsync|0>d.MoveNext() in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs:line 44
--- End of stack trace from previous location ---
   at Bicep.Core.Registry.AzureContainerRegistryManager.PullArtifactAsync(RootConfiguration configuration, IOciArtifactReference artifactReference) in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/AzureContainerRegistryManager.cs:line 63
   at Bicep.Core.Registry.OciArtifactRegistry.TryRestoreArtifactAsync(RootConfiguration configuration, OciArtifactReference reference) in /home/runner/work/bicep/bicep/src/Bicep.Core/Registry/OciArtifactRegistry.cs:line 495,[(BCP192, Error, Unable to restore the artifact with reference "br:unknown.registry.azurecr.io/bicep/extensions/az:0.0.0-placeholder": Retry failed after 4 tries. Retry settings can be adjusted in ClientOptions.Retry or by configuring a custom retry policy in ClientOptions.RetryPolicy. (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)))])
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Repository_not_found_in_registry (ArtifactRegistryAddress { RegistryAddress = unknown.registry.azurecr.io, RepositoryPath = bicep/extensions/az, ExtensionVersion = 0.0.0-placeholder },System.AggregateException: Retry failed after 4 tries. Retry settings can be adjusted in ClientOptions.Retry or by configuring a custom retry policy in ClientOptions.RetryPolicy. (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443))
   at Bicep.Core.Registry.AzureContainerRegistryManager.DownloadManifestAndLayersAsync(IOciArtifactReference artifactReference, ContainerRegistryContentClient client) in D:\a\bicep\bicep\src\Bicep.Core\Registry\AzureContainerRegistryManager.cs:line 138
   at Bicep.Core.Registry.AzureContainerRegistryManager.<>c__DisplayClass4_0.<<PullArtifactAsync>g__DownloadManifestInternalAsync|0>d.MoveNext() in D:\a\bicep\bicep\src\Bicep.Core\Registry\AzureContainerRegistryManager.cs:line 44
--- End of stack trace from previous location ---
   at Bicep.Core.Registry.AzureContainerRegistryManager.PullArtifactAsync(RootConfiguration configuration, IOciArtifactReference artifactReference) in D:\a\bicep\bicep\src\Bicep.Core\Registry\AzureContainerRegistryManager.cs:line 51
   at Bicep.Core.Registry.AzureContainerRegistryManager.DownloadManifestAndLayersAsync(IOciArtifactReference artifactReference, ContainerRegistryContentClient client) in D:\a\bicep\bicep\src\Bicep.Core\Registry\AzureContainerRegistryManager.cs:line 138
   at Bicep.Core.Registry.AzureContainerRegistryManager.<>c__DisplayClass4_0.<<PullArtifactAsync>g__DownloadManifestInternalAsync|0>d.MoveNext() in D:\a\bicep\bicep\src\Bicep.Core\Registry\AzureContainerRegistryManager.cs:line 44
--- End of stack trace from previous location ---
   at Bicep.Core.Registry.AzureContainerRegistryManager.PullArtifactAsync(RootConfiguration configuration, IOciArtifactReference artifactReference) in D:\a\bicep\bicep\src\Bicep.Core\Registry\AzureContainerRegistryManager.cs:line 63
   at Bicep.Core.Registry.OciArtifactRegistry.TryRestoreArtifactAsync(RootConfiguration configuration, OciArtifactReference reference) in D:\a\bicep\bicep\src\Bicep.Core\Registry\OciArtifactRegistry.cs:line 495,[(BCP192, Error, Unable to restore the artifact with reference "br:unknown.registry.azurecr.io/bicep/extensions/az:0.0.0-placeholder": Retry failed after 4 tries. Retry settings can be adjusted in ClientOptions.Retry or by configuring a custom retry policy in ClientOptions.RetryPolicy. (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)) (No such host is known. (unknown.registry.azurecr.io:443)))])
…

♻️ This comment has been updated with latest results.

@levimatheri levimatheri marked this pull request as ready for review January 3, 2025 16:20
@levimatheri levimatheri requested a review from Copilot January 3, 2025 16:54

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 21 changed files in this pull request and generated no comments.

Files not reviewed (15)
  • src/Bicep.Core/TypeSystem/Providers/MicrosoftGraph/MicrosoftGraphResourceTypeProvider.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/Az/AzResourceTypeFactory.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/Az/AzResourceTypeProvider.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/K8s/K8sResourceTypeProvider.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/ThirdParty/ThirdPartyResourceTypeProvider.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/ArmTemplateTypeLoader.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/DeclaredTypeManager.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Providers/ThirdParty/ExtensibilityResourceTypeFactory.cs: Evaluated as low risk
  • src/Bicep.LangServer.IntegrationTests/HoverTests.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/Types/NamespaceType.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/TypeValidator.cs: Evaluated as low risk
  • src/Bicep.Core.UnitTests/Utils/BuiltInTestTypes.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/TypeHelper.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/TypeCollapser.cs: Evaluated as low risk
  • src/Bicep.Core/TypeSystem/ResourceDerivedTypeResolver.cs: Evaluated as low risk
@levimatheri levimatheri merged commit 145639f into main Jan 7, 2025
42 of 47 checks passed
@levimatheri levimatheri deleted the muriukilevi/add-additional-properties-description branch January 7, 2025 18:22
levimatheri added a commit that referenced this pull request Jan 27, 2025
Follow up to [PR
feedback](#15990 (comment)).

With the current `ObjectType` signature, it's technically possible for
`AdditionalPropertiesDescription` to be non-null even if
`AdditionalPropertiesType` is null. This PR creates a new
`NamedTypeProperty` record that represents a property with a name and a
type, which is used for the `ObjectType.Properties` property.
The `TypeProperty` record encapsulates the type ref, flags and
description, preventing a non-null description with a null type ref
being passed into `ObjectType`.

New `ObjectType` signature:
`public ObjectType(string name, TypeSymbolValidationFlags
validationFlags, IEnumerable<NamedTypeProperty> properties,
TypeProperty? additionalProperties, Func<ObjectType, FunctionResolver>
methodResolverBuilder)`

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/16053)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Description information not shown for any property name
2 participants