To start, I know how to reference System.Numerics to give the compiler access to the Complex type it's asking for, I just don't understand why it's necessary.
I have this basic struct:
/// <summary>
/// Describes a single point on a spectrum.
/// </summary>
public struct SpectrumPoint
{
public SpectrumPoint(double wavelength, double intensity)
{
Wavelength = wavelength;
Intensity = intensity;
}
public double Intensity { get; }
public double Wavelength { get; }
}
It is used in a class that needs double[] arrays to use as arguments to third party dependency. I use this LINQy lambda chain construct them:
using Accord.Math;
// ...
double[] _wavelengths = points.Select(point => point.Wavelength).ToArray();
double[] _intensities = points.Select(point => point.Intensity).ToArray();
This is the error caused by those LINQ expressions:
Error CS0012
The typeComplexis defined in an assembly that is not referenced.
You must add a reference to assembly
System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
I know this sort of error can be caused by unused method overloads that reference external assemblies, like here, but neither .Select() nor .ToArray() have any overloads that refer to Complex. What's going on?
EDIT:
This exactly replicates the compilation problem, which goes away if using Accord.Math; is removed:
using System.Linq;
using Accord.Math;
public class A
{
public A(IEnumerable<double> d)
{
double[] arr = d.ToArray();
}
}
(Here is Accord.Math.)