Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Microsoft.ML/TextLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void SetCustomStringFromType(bool useHeader, string separator,
{
var mappingAttr = field.GetCustomAttribute<ColumnAttribute>();
if(mappingAttr == null)
throw Contracts.ExceptParam(nameof(field.Name), " is missing ColumnAttribute");
throw Contracts.ExceptParam(field.Name, $"{field.Name} is missing ColumnAttribute");

schemaBuilder.AppendFormat("col={0}:{1}:{2} ",
mappingAttr.Name ?? field.Name,
Expand Down
13 changes: 13 additions & 0 deletions test/Microsoft.ML.Tests/TextLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.ML.Runtime.Api;
using Microsoft.ML.Runtime.Data;
using Microsoft.ML.TestFramework;
using System;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -219,6 +220,13 @@ public void CanSuccessfullyTrimSpaces()
}
}

[Fact]
public void ThrowsExceptionWithPropertyName()
{
Exception ex = Assert.Throws<ArgumentOutOfRangeException>( () => new TextLoader<ModelWithoutColumnAttribute>("fakefile.txt") );
Assert.StartsWith("String1 is missing ColumnAttribute", ex.Message);
}

public class QuoteInput
{
[Column("0")]
Expand Down Expand Up @@ -254,5 +262,10 @@ public class Input
[Column("1")]
public float Number1;
}

public class ModelWithoutColumnAttribute
{
public string String1;
}
}
}