Conversation
5a49560 to
cd10b2c
Compare
1c8efee to
4100b25
Compare
|
|
||
| public void Validate(DecoratorSyntax decoratorSyntax, TypeSymbol targetType, ITypeManager typeManager, IBinder binder, IDiagnosticWriter diagnosticWriter) | ||
| { | ||
| targetType = RemoveImplicitNull(targetType); |
There was a problem hiding this comment.
I'm not sure if this is the right approach. All existing ARM constraints (except type) are no-ops if invoked on a value of null, but extensibility providers may have a need to block usage of an unforeseen decorator on nullable params or types.
The alternative is to update all the decorator definitions with assignability restrictions in SystemNamespaceType so that they accept nullable types (e.g., @minValue would need to be assignable to int | null instead of just int). This might make us more likely to accidentally block a future decorator's usage on nullable params, though, and is more verbose.
There was a problem hiding this comment.
It's a little quirky, but in the interest of not changing existing behavior, and with the fact that decorators are very infrequently added, I think it's OK - as long as you explain this well in a comment to avoid future surprises.
# Conflicts: # src/Bicep.Core.IntegrationTests/UserDefinedTypeTests.cs # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.bicep # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.diagnostics.bicep # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.formatted.bicep # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.json # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.sourcemap.bicep # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.symbolicnames.json # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.symbols.bicep # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.syntax.bicep # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.tokens.bicep # src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs # src/Bicep.Core/Parsing/BaseParser.cs # src/Bicep.Core/TypeSystem/ObjectTypeNameBuilder.cs
# Conflicts: # src/Bicep.Core.Samples/Files/LoopsIndexed_LF/main.symbolicnames.json # src/Bicep.Core.Samples/Files/Loops_LF/main.symbolicnames.json # src/Bicep.Core.Samples/Files/ResourcesTenant_CRLF/main.symbolicnames.json # src/Bicep.Core.Samples/Files/user_submitted/201/wvd-create-hostpool/main.symbolicnames.json # src/Bicep.Core.Samples/Files/user_submitted/301/sql-database-with-management/main.symbolicnames.json # src/Bicep.Core.Samples/Files/user_submitted/301/sql-database-with-management/modules/sql-logical-servers.symbolicnames.json
…anticModel (#9621) * Spin off a small refactor from #9454 * Update src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs Co-authored-by: Anthony Martin <38542602+anthony-c-martin@users.noreply.github.com> * Incorporate PR feedback Co-authored-by: Anthony Martin <38542602+anthony-c-martin@users.noreply.github.com>
4e2ce09 to
5a2f59d
Compare
# Conflicts: # src/Bicep.Cli.IntegrationTests/packages.lock.json # src/Bicep.Cli.UnitTests/packages.lock.json # src/Bicep.Cli/packages.lock.json # src/Bicep.Core.IntegrationTests/packages.lock.json # src/Bicep.Core.Samples/packages.lock.json # src/Bicep.Core.UnitTests/Semantics/ArmTemplateSemanticModelTests.cs # src/Bicep.Core.UnitTests/packages.lock.json # src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs # src/Bicep.Core/Semantics/ArmTemplateSemanticModel.cs # src/Bicep.Decompiler.IntegrationTests/packages.lock.json # src/Bicep.Decompiler.UnitTests/packages.lock.json # src/Bicep.Decompiler/packages.lock.json # src/Bicep.LangServer.IntegrationTests/packages.lock.json # src/Bicep.LangServer.UnitTests/packages.lock.json # src/Bicep.LangServer/packages.lock.json # src/Bicep.RegistryModuleTool.IntegrationTests/packages.lock.json # src/Bicep.RegistryModuleTool.TestFixtures/packages.lock.json # src/Bicep.RegistryModuleTool.UnitTests/packages.lock.json # src/Bicep.RegistryModuleTool/packages.lock.json # src/Bicep.Tools.Benchmark/packages.lock.json # src/Bicep.Wasm/packages.lock.json
5a2f59d to
94efbea
Compare
# Conflicts: # src/Bicep.Core.IntegrationTests/UserDefinedTypeTests.cs # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.json # src/Bicep.Core.Samples/Files/TypeDeclarations_LF/main.symbolicnames.json # src/Bicep.Core.Samples/Files/Variables_LF/main.symbolicnames.json # src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs # src/Bicep.Core/Parsing/BaseParser.cs # src/Bicep.LangServer/Completions/BicepCompletionProvider.cs
|
|
||
| public override void VisitObjectTypePropertySyntax(ObjectTypePropertySyntax syntax) | ||
| public override void VisitNullableTypeSyntax(NullableTypeSyntax syntax) | ||
| { |
There was a problem hiding this comment.
As discussed offline, might be worth exploring an approach which utilizes the visitor state itself rather than an ad-hoc check using the syntax hierarchy.
There was a problem hiding this comment.
I couldn't find a reasonable way to implement this check in CyclicCheckVisitor without reimplementing some of the model's type manager, but the check can be made much simpler if it's performed after type checking has been performed. I added a second cyclic checker that runs as part of EmitLimitationCalculator.
Resolves #8973 and resolves #8807
This PR adds a
?type postfix operator that identifies any type expression as nullable, meaning that in addition to values matching the unmodified type, a missing or explicitnullvalue will be accepted.For example, the following statement will declare a parameter,
foo, for which a deployment may submit a string, an explicitnull, or no value or at all:For the consumer of a template, a nullable param is indistinguishable from a regular param with a default value. For the example of
fooabove, the experience of deploying the containing template is the same as if it had been declared with a default value (param foo string = ''). In both cases, thefooparam is optional, and a string, anull, or no value at all will be accepted at deployment time.Template authors should use a nullable parameter when they are not responsible for deciding what to do in case a param is omitted. A good use case is when a module has an optional param and it is the module's responsibility to assign a default. For example, in the following set of templates,
main.bicepserves as an orchestrator,mod.bicepdeploys a subsystem, andstorage.bicepis a utility module that deploys a storage account:main.bicep
mod.bicep
storage.bicep
Because nullable params are meant to provide a means of making a
paramoptional without needing to supply a default value, they are not compatible with default values.Nullable type expressions may also be used in
typestatements and in aggregate user-defined types. To avoid creating an artificial distinction betweennullvalues and omitted values, nullable types replace optional properties. Once this PR is merged, the following will no longer be valid Bicep:and would need to instead be expressed as
This PR requires an update to the ARM runtime that has not finished rolling out (included in w02 release).The rollout has completed; this PR is no longer blocked.Microsoft Reviewers: Open in CodeFlow