Skip to content

Commit 2a029ea

Browse files
authored
Movement and Internalization Phase 1 (#1587)
* Move Sweeper types out of Core into Sweeper project. * Internalization of Utils. * Internalize command line related infrastructure. * Internalize base cursor classes. * Internalize PFA support. * Internalize ONNX support. * Internalize creation of model save/load contexts. * Internalize ITree and related types. * Internalize Contracts. * Remove a handful of pointless interfaces.
1 parent 851558d commit 2a029ea

File tree

130 files changed

+1400
-1420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1400
-1420
lines changed

src/Microsoft.ML.Core/CommandLine/ArgumentAttribute.cs

Lines changed: 16 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
// This is separated from CmdParser.cs
6-
75
using System;
86
using System.Linq;
97

@@ -15,7 +13,8 @@ namespace Microsoft.ML.Runtime.CommandLine
1513
/// as the destination of command line argument parsing.
1614
/// </summary>
1715
[AttributeUsage(AttributeTargets.Field)]
18-
public class ArgumentAttribute : Attribute
16+
[BestFriend]
17+
internal class ArgumentAttribute : Attribute
1918
{
2019
public enum VisibilityType
2120
{
@@ -24,35 +23,23 @@ public enum VisibilityType
2423
EntryPointsOnly
2524
}
2625

27-
private ArgumentType _type;
2826
private string _shortName;
29-
private string _helpText;
30-
private bool _hide;
31-
private double _sortOrder;
32-
private string _nullName;
33-
private bool _isInputFileName;
34-
private string _specialPurpose;
35-
private VisibilityType _visibility;
3627
private string _name;
37-
private Type _signatureType;
3828

3929
/// <summary>
4030
/// Allows control of command line parsing.
4131
/// </summary>
4232
/// <param name="type"> Specifies the error checking to be done on the argument. </param>
4333
public ArgumentAttribute(ArgumentType type)
4434
{
45-
_type = type;
46-
_sortOrder = 150;
35+
Type = type;
36+
SortOrder = 150;
4737
}
4838

4939
/// <summary>
5040
/// The error checking to be done on the argument.
5141
/// </summary>
52-
public ArgumentType Type
53-
{
54-
get { return _type; }
55-
}
42+
public ArgumentType Type { get; }
5643

5744
/// <summary>
5845
/// The short name(s) of the argument.
@@ -64,7 +51,7 @@ public ArgumentType Type
6451
/// </summary>
6552
public string ShortName
6653
{
67-
get { return _shortName; }
54+
get => _shortName;
6855
set
6956
{
7057
Contracts.Check(value == null || !(this is DefaultArgumentAttribute));
@@ -75,54 +62,26 @@ public string ShortName
7562
/// <summary>
7663
/// The help text for the argument.
7764
/// </summary>
78-
public string HelpText
79-
{
80-
get { return _helpText; }
81-
set { _helpText = value; }
82-
}
65+
public string HelpText { get; set; }
8366

84-
public bool Hide
85-
{
86-
get { return _hide; }
87-
set { _hide = value; }
88-
}
67+
public bool Hide { get; set; }
8968

90-
public double SortOrder
91-
{
92-
get { return _sortOrder; }
93-
set { _sortOrder = value; }
94-
}
69+
public double SortOrder { get; set; }
9570

96-
public string NullName
97-
{
98-
get { return _nullName; }
99-
set { _nullName = value; }
100-
}
71+
public string NullName { get; set; }
10172

102-
public bool IsInputFileName
103-
{
104-
get { return _isInputFileName; }
105-
set { _isInputFileName = value; }
106-
}
73+
public bool IsInputFileName { get; set; }
10774

10875
/// <summary>
10976
/// Allows the GUI or other tools to inspect the intended purpose of the argument and pick a correct custom control.
11077
/// </summary>
111-
public string Purpose
112-
{
113-
get { return _specialPurpose; }
114-
set { _specialPurpose = value; }
115-
}
78+
public string Purpose { get; set; }
11679

117-
public VisibilityType Visibility
118-
{
119-
get { return _visibility; }
120-
set { _visibility = value; }
121-
}
80+
public VisibilityType Visibility { get; set; }
12281

12382
public string Name
12483
{
125-
get { return _name; }
84+
get => _name;
12685
set { _name = string.IsNullOrWhiteSpace(value) ? null : value; }
12786
}
12887

@@ -136,15 +95,8 @@ public string[] Aliases
13695
}
13796
}
13897

139-
public bool IsRequired
140-
{
141-
get { return ArgumentType.Required == (_type & ArgumentType.Required); }
142-
}
98+
public bool IsRequired => ArgumentType.Required == (Type & ArgumentType.Required);
14399

144-
public Type SignatureType
145-
{
146-
get { return _signatureType; }
147-
set { _signatureType = value; }
148-
}
100+
public Type SignatureType { get; set; }
149101
}
150102
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Microsoft.ML.Runtime.CommandLine
8+
{
9+
/// <summary>
10+
/// Used to control parsing of command line arguments.
11+
/// </summary>
12+
[Flags]
13+
[BestFriend]
14+
internal enum ArgumentType
15+
{
16+
/// <summary>
17+
/// Indicates that this field is required. An error will be displayed
18+
/// if it is not present when parsing arguments.
19+
/// </summary>
20+
Required = 0x01,
21+
22+
/// <summary>
23+
/// Only valid in conjunction with Multiple.
24+
/// Duplicate values will result in an error.
25+
/// </summary>
26+
Unique = 0x02,
27+
28+
/// <summary>
29+
/// Inidicates that the argument may be specified more than once.
30+
/// Only valid if the argument is a collection
31+
/// </summary>
32+
Multiple = 0x04,
33+
34+
/// <summary>
35+
/// The default type for non-collection arguments.
36+
/// The argument is not required, but an error will be reported if it is specified more than once.
37+
/// </summary>
38+
AtMostOnce = 0x00,
39+
40+
/// <summary>
41+
/// For non-collection arguments, when the argument is specified more than
42+
/// once no error is reported and the value of the argument is the last
43+
/// value which occurs in the argument list.
44+
/// </summary>
45+
LastOccurenceWins = Multiple,
46+
47+
/// <summary>
48+
/// The default type for collection arguments.
49+
/// The argument is permitted to occur multiple times, but duplicate
50+
/// values will cause an error to be reported.
51+
/// </summary>
52+
MultipleUnique = Multiple | Unique,
53+
}
54+
}

src/Microsoft.ML.Core/CommandLine/CharCursor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Microsoft.ML.Runtime.CommandLine
88
{
9-
public sealed class CharCursor
9+
internal sealed class CharCursor
1010
{
1111
private readonly string _text;
1212
private readonly int _ichLim;

src/Microsoft.ML.Core/CommandLine/CmdLexer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
65
using System.Text;
7-
using Microsoft.ML.Runtime.Internal.Utilities;
86

97
namespace Microsoft.ML.Runtime.CommandLine
108
{
11-
public sealed class CmdLexer
9+
[BestFriend]
10+
internal sealed class CmdLexer
1211
{
1312
private CharCursor _curs;
1413

0 commit comments

Comments
 (0)