Skip to content

Make ExpressionPromoter plugable#212

Merged
StefH merged 6 commits intozzzprojects:masterfrom
david-garcia-garcia:fix-expression-promoter
Oct 27, 2018
Merged

Make ExpressionPromoter plugable#212
StefH merged 6 commits intozzzprojects:masterfrom
david-garcia-garcia:fix-expression-promoter

Conversation

@david-garcia-garcia
Copy link
Copy Markdown
Contributor

Now that the library allows to instantiate more .Net types easily, Expression promoter needs to be more powerful depending on the needs of the destination types.

This PR makes it plugable and replaceable from outside the library.

Copy link
Copy Markdown
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

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

can you take a look please?

/// <param name="typeName">The typename to resolve.</param>
/// <returns>A resolved <see cref="Type"/> or null when not found.</returns>
Type ResolveType([NotNull] string typeName);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please remove this empty line.

namespace System.Linq.Dynamic.Core.Parser
{
internal static class ExpressionPromoter
internal class ExpressionPromoter : IExpressionPromoter
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
internal class ExpressionPromoter : IExpressionPromoter
maybe if you have time ; can you create a simple test which tests this ExpressionPromoter?

internal class ExpressionPromoter : IExpressionPromoter
{
public static Expression Promote(Expression expr, Type type, bool exact, bool convertExpr)
public Expression Promote(Expression expr, Type type, bool exact, bool convertExpr)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Add /// <inheritdoc cref="IExpressionPromoter.Promote(Expression, Type, bool, bool)"/> here.

namespace System.Linq.Dynamic.Core.Parser
{
/// <summary>
/// Expression promoter is used whe matching
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Typo and maybe add some more text to explain what this is doing.

/// Promote an expression
/// </summary>
/// <param name="expr">Source expression.</param>
/// <param name="type">Destionation data type to promote to.</param>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

typo

/// <param name="parsingConfig"></param>
public MethodFinder(ParsingConfig parsingConfig)
{
this._parsingConfig = parsingConfig;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this. not needed

/// <summary>
/// Gets or sets the <see cref="IExpressionPromoter"/>.
/// </summary>
public IExpressionPromoter ExpressionPromoter
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please add a unit test where you implement a different ExpressionPromoter or use Mock<IExpressionPromoter>

};

/// <summary>
/// The custom type provider.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

comment is not required for private

private IDynamicLinkCustomTypeProvider _customTypeProvider;

/// <summary>
/// The expression promoter.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

comment is not required for private

{
public static bool ContainsMethod(Type type, string methodName, bool staticAccess, Expression[] args)
/// <summary>
/// The parsing config
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

comment is not required for private

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 23, 2018

Codecov Report

Merging #212 into master will increase coverage by 0.2%.
The diff coverage is 63.63%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #212     +/-   ##
=========================================
+ Coverage   82.49%   82.69%   +0.2%     
=========================================
  Files          37       37             
  Lines        3702     3716     +14     
  Branches      508      509      +1     
=========================================
+ Hits         3054     3073     +19     
  Misses        501      501             
+ Partials      147      142      -5
Impacted Files Coverage Δ
...tem.Linq.Dynamic.Core/Parser/ExpressionPromoter.cs 90.19% <ø> (ø) ⬆️
...namic.Core/Parser/SupportedMethods/MethodFinder.cs 90.13% <100%> (+0.26%) ⬆️
...ystem.Linq.Dynamic.Core/Parser/ExpressionParser.cs 78.61% <42.1%> (+0.18%) ⬆️
src/System.Linq.Dynamic.Core/ParsingConfig.cs 92.59% <88.88%> (-1.86%) ⬇️
src/System.Linq.Dynamic.Core/Parser/TypeHelper.cs 87.26% <0%> (+0.47%) ⬆️
...c/System.Linq.Dynamic.Core/Tokenizer/TextParser.cs 98.03% <0%> (+0.98%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a6bf6c...4ad90d1. Read the comment docs.

@StefH
Copy link
Copy Markdown
Collaborator

StefH commented Oct 25, 2018

@david-garcia-garcia Can you take a look at my review comments?

@david-garcia-garcia
Copy link
Copy Markdown
Contributor Author

Took care of all comments + added some very basic test coverage.

@StefH StefH merged commit 81a4c0f into zzzprojects:master Oct 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants