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

Add Dependency Injection support #160

Merged
merged 24 commits into from
May 25, 2024
Merged

Conversation

gumbarros
Copy link
Member

@gumbarros gumbarros commented May 23, 2024

This closes #154
This closes #163
This closes #148

@gumbarros gumbarros marked this pull request as ready for review May 24, 2024 01:58
@gumbarros gumbarros requested a review from Bykiev May 24, 2024 01:58
@gumbarros
Copy link
Member Author

gumbarros commented May 24, 2024

@Bykiev ready for review. Still needs docs, it's 11pm here, time for some sleep :)


public required Dictionary<string, object?> Parameters { get; set; }
Copy link
Member Author

@gumbarros gumbarros May 23, 2024

Choose a reason for hiding this comment

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

@Beckdotan this PR will also solve your problem.

Comment on lines +19 to +26
public static implicit operator ExpressionContext(ExpressionOptions options)
{
return new ExpressionContext { Options = options };
}

public static implicit operator ExpressionContext(CultureInfo cultureInfo)
{
return new ExpressionContext { CultureInfo = cultureInfo };
Copy link
Member Author

@gumbarros gumbarros May 24, 2024

Choose a reason for hiding this comment

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

Just context for reviewers, this prevent a breaking change in the Expression constructors (the proof is the unit tests are untouched).

It's what Microsoft do with LocalizedString->string at Microsoft.Extensions.Localization with IStringLocalizer<T>

@Bykiev
Copy link
Collaborator

Bykiev commented May 24, 2024

Great job, I'll review it carefully at evening. These changes seems too complex and breaking, I'd say it's for NCalc v5. What do you think?

@gumbarros
Copy link
Member Author

Great job, I'll review it carefully at evening. These changes seems too complex and breaking, I'd say it's for NCalc v5. What do you think?

I'm in doubt, if we were to follow semver, it would really be v5, but I consider the breaking change nearly irrelevant, I think is very hard someone using LogicalExpressionVisitor, and in the scenario of using, just a I prefix solve the breaking change.

Ohhh, wait, typing this I just discovered how we workaround and not have breaking changes, maybe I can just add LogicalExpressionVisitor again and implement the interface.

So, without breaking changes, I vote in 4.1.

@gumbarros
Copy link
Member Author

Now No Breaking Changes, in a v5 we can remove the class (also added ObsoleteAttribute) to help in a clean migration any consumer of this class. (very hard to use, but breaking change prevented)

Copy link
Collaborator

@Bykiev Bykiev left a comment

Choose a reason for hiding this comment

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

Looking good, can you please add some plugin tests? Also we need to update the docs. When you'll merge, can you please create a separate branch, not in the master. I think this feature will be ready for production in NCalc v4.2 and v4.1 will include bug fixes and a new features - semicolon as argument delimeter and compare with null parameters

@gumbarros
Copy link
Member Author

@Bykiev I made unit tests for the MemoryCache, I'm going to sextou here, tomorrow I will finish the docs

@gumbarros
Copy link
Member Author

@Bykiev ready to merge. But I vote in a single release of 4.1, it will be maintenance hell of both 4.1 an 4.2 with different feats I think. This PR does not introduce any breaking changes, and I already wants to use this at my project.

@gumbarros
Copy link
Member Author

Finished my self-review, LGTM now.

@Bykiev
Copy link
Collaborator

Bykiev commented May 25, 2024

Agreed, as there is no any breaking changes, let's include it in v4.1. Don't see any issues, can be merged

@gumbarros gumbarros merged commit e34f7aa into master May 25, 2024
3 checks passed
@gumbarros gumbarros deleted the gumbarros/dependency-injection branch May 26, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: Document the ExpressionOptions enum values Dependency Injection Error when migrating to 4.0
2 participants