Skip to content

Commit 93f8556

Browse files
committed
* Enable analysis on all files
* Disable analysis for generated code * Fix found issues
1 parent 55d6fee commit 93f8556

File tree

74 files changed

+230
-212
lines changed

Some content is hidden

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

74 files changed

+230
-212
lines changed

src/Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@
1414

1515
</PropertyGroup>
1616

17+
<ItemGroup>
18+
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\tools-local\Microsoft.ML.CodeAnalyzer\Microsoft.ML.CodeAnalyzer.csproj">
19+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
20+
<OutputItemType>Analyzer</OutputItemType>
21+
</ProjectReference>
22+
23+
</ItemGroup>
24+
1725
</Project>

src/Microsoft.ML.Api/SchemaDefinition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ public IEnumerable<KeyValuePair<string, ColumnType>> GetMetadataTypes
287287
/// </summary>
288288
public Column this[string columnName]
289289
{
290-
#pragma warning disable TLC_NoThis // Do not use 'this' keyword for member access
290+
#pragma warning disable MSML_NoThis // Do not use 'this' keyword for member access
291291
get => this.FirstOrDefault(x => x.ColumnName == columnName);
292-
#pragma warning restore TLC_NoThis // Do not use 'this' keyword for member access
292+
#pragma warning restore MSML_NoThis // Do not use 'this' keyword for member access
293293
set
294294
{
295295
Contracts.CheckValue(value, nameof(value));

src/Microsoft.ML.Core/Microsoft.ML.Core.csproj

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,4 @@
1111
<Folder Include="Properties\" />
1212
</ItemGroup>
1313

14-
<ItemGroup>
15-
<!-- Once we validate this, we ought to move this to one of the higher level directory files. -->
16-
<ProjectReference Include="..\..\tools-local\Microsoft.ML.CodeAnalyzer\Microsoft.ML.CodeAnalyzer.csproj">
17-
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
18-
<OutputItemType>Analyzer</OutputItemType>
19-
</ProjectReference>
20-
21-
</ItemGroup>
22-
2314
</Project>

src/Microsoft.ML.Data/Commands/TrainCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ public static string MatchNameOrDefaultOrNull(IExceptionContext ectx, ISchema sc
222222
return userName;
223223
if (userName == defaultName)
224224
return null;
225-
#pragma warning disable TLC_ContractsNameUsesNameof
225+
#pragma warning disable MSML_ContractsNameUsesNameof
226226
throw ectx.ExceptUserArg(argName, $"Could not find column '{userName}'");
227-
#pragma warning restore TLC_ContractsNameUsesNameof
227+
#pragma warning restore MSML_ContractsNameUsesNameof
228228
}
229229

230230
public static IPredictor Train(IHostEnvironment env, IChannel ch, RoleMappedData data, ITrainer trainer, string name,

src/Microsoft.ML.Data/Data/DataViewUtils.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ private sealed class Splitter
286286
private enum ExtraIndex
287287
{
288288
Id,
289-
#pragma warning disable TLC_GeneralName // Allow for this private enum.
289+
#pragma warning disable MSML_GeneralName // Allow for this private enum.
290290
_Lim
291-
#pragma warning restore TLC_GeneralName
291+
#pragma warning restore MSML_GeneralName
292292
}
293293

294294
private Splitter(ISchema schema)

src/Microsoft.ML.Data/DataLoadSave/PartitionedFileLoader.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,12 @@ private bool TryTruncatePath(int dirCount, string path, out string truncPath)
682682
Ch.Warning($"Path {path} did not have {dirCount} directories necessary for parsing.");
683683
return false;
684684
}
685-
685+
686686
// Rejoin segments to create a valid path.
687687
truncPath = String.Join(Path.DirectorySeparatorChar.ToString(), segments);
688688
return true;
689689
}
690690

691-
692691
/// <summary>
693692
/// Parse all column values from the directory path.
694693
/// </summary>

src/Microsoft.ML.Data/Depricated/TGUIAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
namespace Microsoft.ML.Runtime.Internal.Internallearn
99
{
10-
#pragma warning disable TLC_GeneralName // This structure should be deprecated anyway.
10+
#pragma warning disable MSML_GeneralName // This structure should be deprecated anyway.
1111
// REVIEW: Get rid of this. Everything should be in the ArgumentAttribute (or a class
1212
// derived from ArgumentAttribute).
1313
[AttributeUsage(AttributeTargets.Field)]
1414
public class TGUIAttribute : Attribute
15-
#pragma warning restore TLC_GeneralName
15+
#pragma warning restore MSML_GeneralName
1616
{
1717
// Display parameters
1818
public string Label { get; set; }

src/Microsoft.ML.Data/Dirty/PredictorBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ protected PredictorBase(IHostEnvironment env, string name, ModelLoadContext ctx)
4141

4242
// Verify that the Float type matches.
4343
int cbFloat = ctx.Reader.ReadInt32();
44-
#pragma warning disable TLC_NoMessagesForLoadContext // This one is actually useful.
44+
#pragma warning disable MSML_NoMessagesForLoadContext // This one is actually useful.
4545
Host.CheckDecode(cbFloat == sizeof(Float), "This file was saved by an incompatible version");
46-
#pragma warning restore TLC_NoMessagesForLoadContext
46+
#pragma warning restore MSML_NoMessagesForLoadContext
4747
}
4848

4949
public virtual void Save(ModelSaveContext ctx)

src/Microsoft.ML.Data/EntryPoints/InputBuilder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ public static class Range
791791
/// </summary>
792792
public static class Deprecated
793793
{
794-
public new static string ToString() => "Deprecated";
794+
new public static string ToString() => "Deprecated";
795795
public const string Message = "Message";
796796
}
797797

@@ -800,7 +800,7 @@ public static class Deprecated
800800
/// </summary>
801801
public static class SweepableLongParam
802802
{
803-
public new static string ToString() => "SweepRange";
803+
new public static string ToString() => "SweepRange";
804804
public const string RangeType = "RangeType";
805805
public const string Max = "Max";
806806
public const string Min = "Min";
@@ -814,7 +814,7 @@ public static class SweepableLongParam
814814
/// </summary>
815815
public static class SweepableFloatParam
816816
{
817-
public new static string ToString() => "SweepRange";
817+
new public static string ToString() => "SweepRange";
818818
public const string RangeType = "RangeType";
819819
public const string Max = "Max";
820820
public const string Min = "Min";
@@ -828,14 +828,14 @@ public static class SweepableFloatParam
828828
/// </summary>
829829
public static class SweepableDiscreteParam
830830
{
831-
public new static string ToString() => "SweepRange";
831+
new public static string ToString() => "SweepRange";
832832
public const string RangeType = "RangeType";
833833
public const string Options = "Values";
834834
}
835835

836836
public static class PipelineSweeperSupportedMetrics
837837
{
838-
public new static string ToString() => "SupportedMetric";
838+
new public static string ToString() => "SupportedMetric";
839839
public const string Auc = BinaryClassifierEvaluator.Auc;
840840
public const string AccuracyMicro = Data.MultiClassClassifierEvaluator.AccuracyMicro;
841841
public const string AccuracyMacro = MultiClassClassifierEvaluator.AccuracyMacro;

src/Microsoft.ML.Data/Evaluators/EvaluatorUtils.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ public static ColumnInfo GetScoreColumnInfo(IExceptionContext ectx, ISchema sche
115115
ColumnInfo info;
116116
if (!string.IsNullOrWhiteSpace(name))
117117
{
118-
#pragma warning disable TLC_ContractsNameUsesNameof
118+
#pragma warning disable MSML_ContractsNameUsesNameof
119119
if (!ColumnInfo.TryCreateFromName(schema, name, out info))
120120
throw ectx.ExceptUserArg(argName, "Score column is missing");
121-
#pragma warning restore TLC_ContractsNameUsesNameof
121+
#pragma warning restore MSML_ContractsNameUsesNameof
122122
return info;
123123
}
124124

@@ -145,9 +145,9 @@ public static ColumnInfo GetScoreColumnInfo(IExceptionContext ectx, ISchema sche
145145
if (!string.IsNullOrWhiteSpace(defName) && ColumnInfo.TryCreateFromName(schema, defName, out info))
146146
return info;
147147

148-
#pragma warning disable TLC_ContractsNameUsesNameof
148+
#pragma warning disable MSML_ContractsNameUsesNameof
149149
throw ectx.ExceptUserArg(argName, "Score column is missing");
150-
#pragma warning restore TLC_ContractsNameUsesNameof
150+
#pragma warning restore MSML_ContractsNameUsesNameof
151151
}
152152

153153
/// <summary>
@@ -168,12 +168,12 @@ public static ColumnInfo GetOptAuxScoreColumnInfo(IExceptionContext ectx, ISchem
168168
if (!string.IsNullOrWhiteSpace(name))
169169
{
170170
ColumnInfo info;
171-
#pragma warning disable TLC_ContractsNameUsesNameof
171+
#pragma warning disable MSML_ContractsNameUsesNameof
172172
if (!ColumnInfo.TryCreateFromName(schema, name, out info))
173173
throw ectx.ExceptUserArg(argName, "{0} column is missing", valueKind);
174174
if (!testType(info.Type))
175175
throw ectx.ExceptUserArg(argName, "{0} column has incompatible type", valueKind);
176-
#pragma warning restore TLC_ContractsNameUsesNameof
176+
#pragma warning restore MSML_ContractsNameUsesNameof
177177
return info;
178178
}
179179

0 commit comments

Comments
 (0)