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

Parent property implementation #1800

Merged
merged 20 commits into from
Mar 17, 2021
Merged

Conversation

anthony-c-martin
Copy link
Member

@anthony-c-martin anthony-c-martin commented Mar 9, 2021

Fixes #127

Copy link
Contributor

@rynowak rynowak left a comment

Choose a reason for hiding this comment

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

You'll likely need to revisit the emit code for resources w/ ancestors to handle ifs and loops differently. There are cases where we need to handle codegen differently for ancestors via parent property vs ancestors via containment. I think most of the tooling features are driven from syntax and not directly from GetAncestors().

We probably need some API that distinguishes between parent property and nested cases.

@anthony-c-martin anthony-c-martin force-pushed the antmarti/parent_property branch from 51b46f5 to 8577272 Compare March 10, 2021 14:35
@anthony-c-martin anthony-c-martin marked this pull request as ready for review March 13, 2021 14:29
@anthony-c-martin anthony-c-martin changed the title [WIP] Parent property implementation Parent property implementation Mar 13, 2021
@codecov-io
Copy link

codecov-io commented Mar 16, 2021

Codecov Report

Merging #1800 (016c843) into main (1bd5ffc) will increase coverage by 0.55%.
The diff coverage is 99.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1800      +/-   ##
==========================================
+ Coverage   95.30%   95.85%   +0.55%     
==========================================
  Files         377      375       -2     
  Lines       22696    23103     +407     
  Branches       15        0      -15     
==========================================
+ Hits        21630    22146     +516     
+ Misses       1066      957     -109     
Flag Coverage Δ
dotnet 95.85% <99.83%> (+0.13%) ⬆️
typescript ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/Bicep.Core/LanguageConstants.cs 99.08% <ø> (ø)
src/Bicep.Core/Emit/TemplateWriter.cs 98.00% <83.33%> (+0.02%) ⬆️
...Bicep.Core.IntegrationTests/NestedResourceTests.cs 100.00% <100.00%> (ø)
...re.IntegrationTests/ParentPropertyResourceTests.cs 100.00% <100.00%> (ø)
...Core.UnitTests/Diagnostics/DiagnosticExtensions.cs 100.00% <100.00%> (ø)
src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs 100.00% <100.00%> (ø)
src/Bicep.Core/Emit/EmitLimitationCalculator.cs 100.00% <100.00%> (ø)
src/Bicep.Core/Emit/ExpressionConverter.cs 93.76% <100.00%> (ø)
src/Bicep.Core/Emit/ResourceDependencyVisitor.cs 91.25% <100.00%> (ø)
src/Bicep.Core/Emit/ScopeHelper.cs 91.35% <100.00%> (+0.03%) ⬆️
... and 13 more

Copy link
Contributor

@shenglol shenglol left a comment

Choose a reason for hiding this comment

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

:shipit:

public ErrorDiagnostic ResourceTypeIsNotValidParent(string resourceType, string parentResourceType) => new(
TextSpan,
"BCP167",
$"Resource type \"{resourceType}\" is not a valid child resource of parent \"{parentResourceType}\".");
Copy link
Member

Choose a reason for hiding this comment

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

parent [](start = 84, length = 6)

Should the message also say what the permissible types would be? (I haven't yet read how this is used.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Personally I don't think we should list the available child types in the error - the inconsistency is detected via prefix matching (using the type string to check if it's a child), so it feels like it could be inconsistent or potentially misleading to try and detect possible types from the type system.

@anthony-c-martin anthony-c-martin force-pushed the antmarti/parent_property branch from 4d9b58d to 709a41f Compare March 17, 2021 00:02
Copy link
Member

@majastrz majastrz left a comment

Choose a reason for hiding this comment

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

This is awesome!

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.

Improve declarations of child resources
5 participants