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

Added a function overload builder #1126

Merged
merged 3 commits into from
Dec 14, 2020
Merged

Added a function overload builder #1126

merged 3 commits into from
Dec 14, 2020

Conversation

majastrz
Copy link
Member

Refactored code that constructs all the function overloads to be more fluent. To support signature help (#284), I will need to update function metadata to have descriptions on indvidual overloads as well as add names and descriptions to each parameters. The previous pattern wouldn't support the additional information very well.

There are no functional changes in this PR.

@codecov-io
Copy link

codecov-io commented Dec 12, 2020

Codecov Report

Merging #1126 (9835986) into main (9f31166) will increase coverage by 0.08%.
The diff coverage is 99.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1126      +/-   ##
==========================================
+ Coverage   94.22%   94.30%   +0.08%     
==========================================
  Files         329      330       +1     
  Lines       15904    16180     +276     
  Branches       14       14              
==========================================
+ Hits        14985    15258     +273     
- Misses        919      922       +3     
Flag Coverage Δ
dotnet 94.87% <99.18%> (+0.07%) ⬆️
typescript 27.20% <ø> (ø)

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

Impacted Files Coverage Δ
src/Bicep.Core/Semantics/FunctionOverload.cs 94.23% <ø> (-0.94%) ⬇️
...rc/Bicep.Core/Semantics/FunctionOverloadBuilder.cs 93.18% <93.18%> (ø)
...cep.Core/Semantics/Namespaces/AzNamespaceSymbol.cs 100.00% <100.00%> (ø)
...Core/Semantics/Namespaces/SystemNamespaceSymbol.cs 100.00% <100.00%> (ø)

Comment on lines +79 to +83
this.fixedParameterTypes.Clear();
foreach (TypeSymbol parameterType in parameterTypes)
{
this.fixedParameterTypes.Add(parameterType);
}
Copy link
Member

Choose a reason for hiding this comment

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

What's the benefit of using the builder here? The only places I can see it being used is to do a full replace - feels like it would be more straightforward to just do this.fixedParameterTypes = parameterTypes.ToImmutableArray(); similar to the way other props are being set.

Copy link
Member Author

@majastrz majastrz Dec 14, 2020

Choose a reason for hiding this comment

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

Mostly felt kind of weird to create a list and then throw it out immediately. There is also a slight memory optimization (likely not noticeable in any way) because we avoid an extra allocation from ToImmutableArray().

@majastrz majastrz merged commit fc0536e into main Dec 14, 2020
@majastrz majastrz deleted the majastrz/function-metadata branch December 14, 2020 23:31
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.

3 participants