Skip to content

Commit 24f1cca

Browse files
Issue 4120, add reasonable exception when user try to use OnnxSequenceType attribute without specify sequence type (dotnet#4272)
* fix issue 4120, add reasonable exception when user try to use OnnxSequenceType attribute without specify sequence type * rename function for better readibility * take comments and modify accordingly * take eric's comments, comment out default constructor instead of throw exception * refine comments * remove unnecessary code change * Make default constructor of OnnxSequenceType attribute obsolete
1 parent 18394c4 commit 24f1cca

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Microsoft.ML.OnnxTransformer/OnnxSequenceType.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ public sealed class OnnxSequenceTypeAttribute : DataViewTypeAttribute
5656
{
5757
private Type _elemType;
5858

59-
/// <summary>
60-
/// Create a sequence type.
61-
/// </summary>
59+
// Make default constructor obsolete.
60+
// Use default constructor will left the _elemType field empty and cause exception in methods using _elemType.
61+
// User will receive compile error when try to use [OnnxSequenceType] attribute directly without specify sequence type
62+
[Obsolete("Please specify sequence type when use OnnxSequenceType Attribute", true)]
6263
public OnnxSequenceTypeAttribute()
6364
{
6465
}

test/Microsoft.ML.Tests/OnnxSequenceTypeWithAttributesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ public void OnnxSequenceTypeWithColumnNameAttributeTest()
6565

6666
}
6767
}
68-
}
68+
}

0 commit comments

Comments
 (0)