Skip to content

Commit 6812cb5

Browse files
sfilipiTomFinley
authored andcommitted
Enabling DI framework to scan the constructors with non-public visibility
* enabling scanning the constructors with non-public visibility, and reducing the visibility of some of them to avoid confusing the users.
1 parent 044a6d3 commit 6812cb5

File tree

17 files changed

+18
-18
lines changed

17 files changed

+18
-18
lines changed

src/Microsoft.ML.Core/ComponentModel/ComponentCatalog.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,9 @@ private static bool TryGetIniters(Type instType, Type loaderType, Type[] parmTyp
454454
var parmTypesWithEnv = Utils.Concat(new Type[1] { typeof(IHostEnvironment) }, parmTypes);
455455
if (Utils.Size(parmTypes) == 0 && (getter = FindInstanceGetter(instType, loaderType)) != null)
456456
return true;
457-
if (instType.IsAssignableFrom(loaderType) && (ctor = loaderType.GetConstructor(parmTypes ?? Type.EmptyTypes)) != null)
457+
if (instType.IsAssignableFrom(loaderType) && (ctor = loaderType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, parmTypes ?? Type.EmptyTypes, null)) != null)
458458
return true;
459-
if (instType.IsAssignableFrom(loaderType) && (ctor = loaderType.GetConstructor(parmTypesWithEnv ?? Type.EmptyTypes)) != null)
459+
if (instType.IsAssignableFrom(loaderType) && (ctor = loaderType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, parmTypesWithEnv ?? Type.EmptyTypes, null)) != null)
460460
{
461461
requireEnvironment = true;
462462
return true;

src/Microsoft.ML.FastTree/FastTreeClassification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public FastTreeBinaryClassificationTrainer(IHostEnvironment env, string labelCol
142142
/// <summary>
143143
/// Initializes a new instance of <see cref="FastTreeBinaryClassificationTrainer"/> by using the legacy <see cref="Arguments"/> class.
144144
/// </summary>
145-
public FastTreeBinaryClassificationTrainer(IHostEnvironment env, Arguments args)
145+
internal FastTreeBinaryClassificationTrainer(IHostEnvironment env, Arguments args)
146146
: base(env, args, MakeLabelColumn(args.LabelColumn))
147147
{
148148
_outputColumns = new[]

src/Microsoft.ML.FastTree/FastTreeRanking.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public FastTreeRankingTrainer(IHostEnvironment env, string labelColumn, string f
8282
/// <summary>
8383
/// Initializes a new instance of <see cref="FastTreeRankingTrainer"/> by using the legacy <see cref="Arguments"/> class.
8484
/// </summary>
85-
public FastTreeRankingTrainer(IHostEnvironment env, Arguments args)
85+
internal FastTreeRankingTrainer(IHostEnvironment env, Arguments args)
8686
: base(env, args, MakeLabelColumn(args.LabelColumn))
8787
{
8888
_outputColumns = new[]

src/Microsoft.ML.FastTree/FastTreeRegression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public FastTreeRegressionTrainer(IHostEnvironment env, string labelColumn, strin
7575
/// <summary>
7676
/// Initializes a new instance of <see cref="FastTreeRegressionTrainer"/> by using the legacy <see cref="Arguments"/> class.
7777
/// </summary>
78-
public FastTreeRegressionTrainer(IHostEnvironment env, Arguments args)
78+
internal FastTreeRegressionTrainer(IHostEnvironment env, Arguments args)
7979
: base(env, args, MakeLabelColumn(args.LabelColumn))
8080
{
8181
_outputColumns = new[]

src/Microsoft.ML.FastTree/FastTreeTweedie.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public FastTreeTweedieTrainer(IHostEnvironment env, string labelColumn, string f
6767
/// <summary>
6868
/// Initializes a new instance of <see cref="FastTreeTweedieTrainer"/> by using the legacy <see cref="Arguments"/> class.
6969
/// </summary>
70-
public FastTreeTweedieTrainer(IHostEnvironment env, Arguments args)
70+
internal FastTreeTweedieTrainer(IHostEnvironment env, Arguments args)
7171
: base(env, args, MakeLabelColumn(args.LabelColumn))
7272
{
7373
Initialize();

src/Microsoft.ML.FastTree/GamClassification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public sealed class Arguments : ArgumentsBase
4646
public override PredictionKind PredictionKind => PredictionKind.BinaryClassification;
4747
private protected override bool NeedCalibration => true;
4848

49-
public BinaryClassificationGamTrainer(IHostEnvironment env, Arguments args)
49+
internal BinaryClassificationGamTrainer(IHostEnvironment env, Arguments args)
5050
: base(env, args)
5151
{
5252
_sigmoidParameter = 1;

src/Microsoft.ML.FastTree/GamRegression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public partial class Arguments : ArgumentsBase
4040

4141
public override PredictionKind PredictionKind => PredictionKind.Regression;
4242

43-
public RegressionGamTrainer(IHostEnvironment env, Arguments args)
43+
internal RegressionGamTrainer(IHostEnvironment env, Arguments args)
4444
: base(env, args) { }
4545

4646
internal override void CheckLabel(RoleMappedData data)

src/Microsoft.ML.FastTree/RandomForestClassification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public FastForestClassification(IHostEnvironment env, string labelColumn, string
158158
/// <summary>
159159
/// Initializes a new instance of <see cref="FastForestClassification"/> by using the legacy <see cref="Arguments"/> class.
160160
/// </summary>
161-
public FastForestClassification(IHostEnvironment env, Arguments args)
161+
internal FastForestClassification(IHostEnvironment env, Arguments args)
162162
: base(env, args, MakeLabelColumn(args.LabelColumn))
163163
{
164164
_outputColumns = new[]

src/Microsoft.ML.FastTree/RandomForestRegression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public FastForestRegression(IHostEnvironment env, string labelColumn, string fea
178178
/// <summary>
179179
/// Initializes a new instance of <see cref="FastForestRegression"/> by using the legacy <see cref="Arguments"/> class.
180180
/// </summary>
181-
public FastForestRegression(IHostEnvironment env, Arguments args)
181+
internal FastForestRegression(IHostEnvironment env, Arguments args)
182182
: base(env, args, MakeLabelColumn(args.LabelColumn), true)
183183
{
184184
_outputColumns = new[]

src/Microsoft.ML.StandardLearners/Standard/MultiClass/Pkpd.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public sealed class Arguments : ArgumentsBase
7373
/// Developers should instantiate <see cref="Pkpd"/> by supplying the trainer argument directly to the <see cref="Pkpd"/> constructor
7474
/// using the other public constructor.
7575
/// </summary>
76-
public Pkpd(IHostEnvironment env, Arguments args)
76+
internal Pkpd(IHostEnvironment env, Arguments args)
7777
: base(env, args, LoadNameValue)
7878
{
7979
}

0 commit comments

Comments
 (0)