-
-
Notifications
You must be signed in to change notification settings - Fork 104
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 extension to evaluate mathematical expressions inside a format string #299
Comments
@karljj1 @Begounet |
I had not considered a math expression evaluator but it does sound like an interesting idea. Using it to replace the Choose and Conditional Formatter would be good. I noticed you do
From what I can see we already have a lot of How does NCalc perform when compared against the ChooseFormatter and ConditionalFormatters? How does it compare with memory, does it allocate much? |
@karljj1
Performance: Still not sure, whether The Performance project of the branch contains a BenchmarkDotNet test, bringing the following results:
|
Looks interesting. I think keeping it as its own extension makes sense, still, keep the existing Cond and Choose extensions as they seem lighter to use for both perf and allocations. |
After evaluating the following OSS solutions the best choice in terms of Smart.Format still seems to be NCalc |
How is this feature coming along? |
Actually I'm not yet satisfied with the current implementation, which is rather a POC. |
@axunonb Currently I'm trying to write a "custom formula & format string" and this library is most fit for me on "format" feature, but it doesn't support "formula" now, so I have to do some magic to achieve what I need. |
@Flithor In this case you should give |
Just updated NCalc package reference
|
I was looking into using this, and it looks very cool, but since it requires changes into the core package and internal classes or a custom build it is really difficult to fit into the toolchain. It does not look like it easily could be an external extension? |
@petero-dk @Flithor Currently this is a proof of concept. The necessary changes to the core package must still be be reviewed and streamlined. |
I built it and directly referenced the assemblies. Not really happy with that. If you would like I can make a PR for the core with changes so the plugin can be completely in a different repository. But it will require some changes as it uses protected methods. That way it can use an official core and we/you can create a pre release version of the calc plugin. I think that would be a clean way of doing it and also show the community that it is not supported but allow usage for brave souls. |
@petero-dk Please let's first discuss how to deal with the
|
Hi @axunonb I spent a lot of time thinking about this, and I think the thing I keep coming back to is why the need for the strong name assembly? I can see that it is used to provide private access for testing and plugins, but I don't like that at all. Because that allows some plugins to have more capabilities than others and does not make it easy for other to expand upon it. And then comes the point of the whole thing, no matter what we do with ncalc, it is a workaround for the strong naming, and it should not really be required for a plugin based system, especially one where we would like to utilize other nuget packages. Then I may assume that the strong name is required upstream by some already, so it might be a non-negotiable thing, however as I read it, it has no real impact in .Net 5 and after (except for the private access) What I would suggest "to start with" is to make everything needed in the SmartFormat base library public so even non-signed plugins can use them. The strong naming should not be a hindering for development, which it is now. Then I would build the plugin completely separate without need for signing, because if ncalc does not come signed, then there are only two correct ways of handling it:
|
Thank you, @petero-dk, for sharing your thoughts on the necessity of strong-naming the Your points are valid, and indeed, strong naming does present challenges, particularly in plugin-based systems where interoperability with other NuGet packages is advantageous. On the other hand, publishing I did examine other packages closely, but came back to Following your 'unsigned proposal', a pragmatic approach could be, to limit the strong-named |
Actually I think my unsigned proposal would be to split out the Calculator plugin in its completely own repository and Nuget package, and keep that completely unsigned and for all targets. That would would allow everybody to use it, but obviously if people are using below .Net 6 they would have to be unsigned themselves. Keep the main repository as is and signed. This would be completely backwards compatible. |
@petero-dk @Flithor Just submitted a PR to publish a signed version besides the unsigned version of |
@petero-dk @Flithor The PR for a signed version of |
Add a math formatter extensions that allows the following:
NCalc might be a good candidate for a Mathematical Expressions Evaluator.
The text was updated successfully, but these errors were encountered: