Opened 4 months ago

Last modified 2 weeks ago

#2723 new defect

Providing variable values as double[] to Dataset fails at runtime

Reported by: abeham Owned by:
Priority: medium Milestone: HeuristicLab 3.3.15
Component: Problems.DataAnalysis Version: 3.3.14
Keywords: Cc:


In the Dataset class an IList is accepted as variable values, however later on this IList is cast as a List<T>.

public Dataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues)
  : base() {

  // line 199:
  List<T> values = list as List<T>;
  if (values == null) throw new ArgumentException("The variable " + variableName + " is not a " + typeof(T) + " variable.");

Now, a double[] is an IList, but not a List<double>. The compiler is happy, but the program crashes at runtime. In my opinion, it should be checked if it's a T[] in case List<T> fails or otherwise prevent accepting double[] in the constructor.

Change History (1)

comment:1 Changed 2 weeks ago by bburlacu

r14857: Add DatasetUtil static class with useful methods for dealing with Datasets. Add input validation to Dataset constructor.

Note: See TracTickets for help on using tickets.