asc-community / asc-community/AngouriMath
Complex to implement IConvertible
- 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
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