-
Notifications
You must be signed in to change notification settings - Fork 759
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
Fix unhandled exception and stack overflow for resource parent property assignments #4384
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Linq; | ||
using Bicep.Core.Extensions; | ||
using Bicep.Core.Resources; | ||
|
||
namespace Bicep.Core.TypeSystem | ||
{ | ||
public class ResourceParentType : TypeSymbol | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @anthony-c-martin I ended up adding a new type for the parent property and doing validation in |
||
{ | ||
public ResourceParentType(ResourceTypeReference childTypeReference) | ||
: base(GetFullyQualifiedParentTypeName(childTypeReference)) | ||
{ | ||
this.ChildTypeReference = childTypeReference; | ||
} | ||
|
||
public ResourceTypeReference ChildTypeReference { get; } | ||
|
||
public override TypeKind TypeKind => TypeKind.Resource; | ||
|
||
private static string GetFullyQualifiedParentTypeName(ResourceTypeReference childTypeReference) => | ||
$"{childTypeReference.Namespace}/{childTypeReference.Types.Take(childTypeReference.Types.Length - 1).ConcatString("/")}"; | ||
} | ||
} |
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.
The test failed to catch the stack overflow when the name property is present because of this if condition in ResourceMetadataCache: https://github.com/Azure/bicep/pull/4384/files#diff-150614dce0ae8e84ce370301fb8495c5226eaceac78046576ed656b0e41d498aR47