asc-community / asc-community/AngouriMath

Complex to implement IConvertible

Open
#378 6 comments 0 reactions 0 assignees View on GitHub
Opinions wanted Proposal
Dominant language
C#
Stars
831
Forks
79
Avg merge
3h 23m
Merged PRs (30d)
309

Description

Hi,

I have a scenario where the return type of a formula is not known in advance.
Hence, I would like to write something like this :
```C#
Type t = GetTheReturnType(); // ex: typeof(int)
return Convert.ChangeType(resultAsComplex.ToNumber(), t);
```

This would require the Complex type to implement IConvertible.
```C#
public partial record Complex : Number, IConvertible
```
I noticed that implicit operators for conversion are already in place so implementing the interface is feasible.
Anyone has some feedback on this proposition ?

Contributor guide

Open the contributing guide

Research direction

Start by reading the Complex type and its existing implicit conversion operators, then compare the proposed IConvertible implementation with Convert.ChangeType's expected behavior. Done means the supported conversions are clearly defined and the example conversion works without changing unrelated Complex behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.