Skip to content

Commit

Permalink
Merge pull request #866 from StefanMaron/prerelease
Browse files Browse the repository at this point in the history
Merge 'prerelease' into master
  • Loading branch information
Arthurvdv authored Jan 13, 2025
2 parents 317ac41 + d6b8696 commit eebd80f
Show file tree
Hide file tree
Showing 228 changed files with 8,563 additions and 4,157 deletions.
4 changes: 2 additions & 2 deletions BusinessCentral.LinterCop.Test/Rule0004.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task HasDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0004LookupPageIdAndDrillDownPageId>();
fixture.HasDiagnostic(code, Rule0004LookupPageIdAndDrillDownPageId.DiagnosticDescriptors.Rule0004LookupPageIdAndDrillDownPageId.Id);
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0004LookupPageIdAndDrillDownPageId.Id);
}

[Test]
Expand All @@ -31,6 +31,6 @@ public async Task NoDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0004LookupPageIdAndDrillDownPageId>();
fixture.NoDiagnosticAtMarker(code, Rule0004LookupPageIdAndDrillDownPageId.DiagnosticDescriptors.Rule0004LookupPageIdAndDrillDownPageId.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0004LookupPageIdAndDrillDownPageId.Id);
}
}
14 changes: 7 additions & 7 deletions BusinessCentral.LinterCop.Test/Rule0013.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ public void Setup()
}

[Test]
[TestCase("1")]
[TestCase("PrimaryKeyCodeField")]
public async Task HasDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "HasDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys>();
fixture.HasDiagnostic(code, Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.DiagnosticDescriptors.Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.Id);
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.Id);
}

[Test]
[TestCase("1")]
[TestCase("2")]
[TestCase("3")]
[TestCase("4")]
[TestCase("PrimaryKeyCodeFieldNotBlankFalse")]
[TestCase("PrimaryKeyCodeFieldNotBlankTrue")]
[TestCase("PrimaryKeyIntegerField")]
[TestCase("PrimaryKeyMultipleFields")]
public async Task NoDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys>();
fixture.NoDiagnosticAtMarker(code, Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.DiagnosticDescriptors.Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.Id);
}
}
9 changes: 7 additions & 2 deletions BusinessCentral.LinterCop.Test/Rule0017.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public void Setup()
}

[Test]
[TestCase("1")]
[TestCase("Assignment")]
[TestCase("Validate")]
public async Task HasDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "HasDiagnostic", $"{testCase}.al"))
Expand All @@ -23,7 +24,11 @@ public async Task HasDiagnostic(string testCase)
}

[Test]
[TestCase("1")]
[TestCase("AssignmentWithLeadingComment")]
[TestCase("AssignmentWithTrailingComment")]
[TestCase("ValidateWithLeadingComment")]
//TODO: The HasExplainingComment method in the Rule0017WriteToFlowField class doesn't support this scenario currently
// [TestCase("ValidateWithTrailingComment")]
public async Task NoDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al"))
Expand Down
36 changes: 36 additions & 0 deletions BusinessCentral.LinterCop.Test/Rule0023.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace BusinessCentral.LinterCop.Test;

public class Rule0023
{
private string _testCaseDir = "";

[SetUp]
public void Setup()
{
_testCaseDir = Path.Combine(Directory.GetParent(Environment.CurrentDirectory)!.Parent!.Parent!.FullName,
"TestCases", "Rule0023");
}

[Test]
[TestCase("BrickIsMissing")]
[TestCase("DropDownIsMissing")]
public async Task HasDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "HasDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0023AlwaysSpecifyFieldgroups>();
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0023AlwaysSpecifyFieldgroups.Id);
}

[Test]
[TestCase("HasBrickAndDropDown")]
public async Task NoDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0023AlwaysSpecifyFieldgroups>();
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0023AlwaysSpecifyFieldgroups.Id);
}
}
2 changes: 1 addition & 1 deletion BusinessCentral.LinterCop.Test/Rule0027.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public async Task NoDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0027RunPageImplementPageManagement>();
fixture.NoDiagnosticAtMarker(code, Rule0027RunPageImplementPageManagement.DiagnosticDescriptors.Rule0027RunPageImplementPageManagement.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0027RunPageImplementPageManagement.Id);
}
}
18 changes: 14 additions & 4 deletions BusinessCentral.LinterCop.Test/Rule0051.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,35 @@ public void Setup()
}

[Test]
#if !LessThenSpring2024
[TestCase("GetMethodStringLiteral")]
[TestCase("GetMethodStrSubstNo")]
#endif
[TestCase("SetFilterFieldCode")]
public async Task HasDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "HasDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0051SetFilterPossibleOverflow>();
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0051SetFilterPossibleOverflow.Id);
var fixture = RoslynFixtureFactory.Create<Rule0051PossibleOverflowAssigning>();
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0051PossibleOverflowAssigning.Id);
}

[Test]
#if !LessThenSpring2024
[TestCase("GetMethodCompanyName")]
[TestCase("GetMethodStringLiteral")]
[TestCase("GetMethodStrSubstNo")]
[TestCase("GetMethodUserId")]
#endif
[TestCase("SetFilterFieldRef")]
public async Task NoDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0051SetFilterPossibleOverflow>();
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0051SetFilterPossibleOverflow.Id);
var fixture = RoslynFixtureFactory.Create<Rule0051PossibleOverflowAssigning>();
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0051PossibleOverflowAssigning.Id);
}
}
#endif
4 changes: 2 additions & 2 deletions BusinessCentral.LinterCop.Test/Rule0065.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task HasDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0065CheckEventSubscriberVarKeyword>();
fixture.HasDiagnostic(code, Rule0065CheckEventSubscriberVarKeyword.DiagnosticDescriptors.Rule0065EventSubscriberVarCheck.Id);
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0065EventSubscriberVarCheck.Id);
}

[Test]
Expand All @@ -30,6 +30,6 @@ public async Task NoDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0065CheckEventSubscriberVarKeyword>();
fixture.NoDiagnosticAtMarker(code, Rule0065CheckEventSubscriberVarKeyword.DiagnosticDescriptors.Rule0065EventSubscriberVarCheck.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0065EventSubscriberVarCheck.Id);
}
}
4 changes: 2 additions & 2 deletions BusinessCentral.LinterCop.Test/Rule0067.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task HasDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys>();
fixture.HasDiagnostic(code, Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.DiagnosticDescriptors.Rule0067DisableNotBlankOnSingleFieldPrimaryKey.Id);
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0067DisableNotBlankOnSingleFieldPrimaryKey.Id);
}

[Test]
Expand All @@ -35,6 +35,6 @@ public async Task NoDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys>();
fixture.NoDiagnosticAtMarker(code, Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.DiagnosticDescriptors.Rule0067DisableNotBlankOnSingleFieldPrimaryKey.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0067DisableNotBlankOnSingleFieldPrimaryKey.Id);
}
}
4 changes: 2 additions & 2 deletions BusinessCentral.LinterCop.Test/Rule0068.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task HasDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0068CheckObjectPermission>();
fixture.HasDiagnostic(code, Rule0068CheckObjectPermission.DiagnosticDescriptors.Rule0068CheckObjectPermission.Id);
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0068CheckObjectPermission.Id);
}

[Test]
Expand All @@ -47,6 +47,6 @@ public async Task NoDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0068CheckObjectPermission>();
fixture.NoDiagnosticAtMarker(code, Rule0068CheckObjectPermission.DiagnosticDescriptors.Rule0068CheckObjectPermission.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0068CheckObjectPermission.Id);
}
}
4 changes: 2 additions & 2 deletions BusinessCentral.LinterCop.Test/Rule0070.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task HasDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0070ListObjectsAreOneBased>();
fixture.HasDiagnostic(code, Rule0070ListObjectsAreOneBased.DiagnosticDescriptors.Rule0070ListObjectsAreOneBased.Id);
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0070ListObjectsAreOneBased.Id);
}

[Test]
Expand All @@ -32,6 +32,6 @@ public async Task NoDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0070ListObjectsAreOneBased>();
fixture.NoDiagnosticAtMarker(code, Rule0070ListObjectsAreOneBased.DiagnosticDescriptors.Rule0070ListObjectsAreOneBased.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0070ListObjectsAreOneBased.Id);
}
}
4 changes: 2 additions & 2 deletions BusinessCentral.LinterCop.Test/Rule0073.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task HasDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0073EventPublisherIsHandledByVar>();
fixture.HasDiagnostic(code, Rule0073EventPublisherIsHandledByVar.DiagnosticDescriptors.Rule0073EventPublisherIsHandledByVar.Id);
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0073EventPublisherIsHandledByVar.Id);
}

[Test]
Expand All @@ -32,6 +32,6 @@ public async Task NoDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0073EventPublisherIsHandledByVar>();
fixture.NoDiagnosticAtMarker(code, Rule0073EventPublisherIsHandledByVar.DiagnosticDescriptors.Rule0073EventPublisherIsHandledByVar.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0073EventPublisherIsHandledByVar.Id);
}
}
4 changes: 2 additions & 2 deletions BusinessCentral.LinterCop.Test/Rule0074.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task HasDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0074FlowFilterAssignment>();
fixture.HasDiagnostic(code, Rule0074FlowFilterAssignment.DiagnosticDescriptors.Rule0074FlowFilterAssignment.Id);
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0074FlowFilterAssignment.Id);
}

[Test]
Expand All @@ -31,6 +31,6 @@ public async Task NoDiagnostic(string testCase)
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0074FlowFilterAssignment>();
fixture.NoDiagnosticAtMarker(code, Rule0074FlowFilterAssignment.DiagnosticDescriptors.Rule0074FlowFilterAssignment.Id);
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0074FlowFilterAssignment.Id);
}
}
65 changes: 65 additions & 0 deletions BusinessCentral.LinterCop.Test/Rule0075.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#if !LessThenSpring2024
namespace BusinessCentral.LinterCop.Test;

public class Rule0075
{
private string _testCaseDir = "";

[SetUp]
public void Setup()
{
_testCaseDir = Path.Combine(Directory.GetParent(Environment.CurrentDirectory)!.Parent!.Parent!.FullName,
"TestCases", "Rule0075");
}

[Test]
[TestCase("ImplicitConversiontCodeToEnum")]
[TestCase("ImplicitConversiontEnumToAnotherEnum")]
[TestCase("RecordGetCodeFieldLengthTooLong")]
[TestCase("RecordGetGlobalVariable")]
[TestCase("RecordGetLocalVariable")]
[TestCase("RecordGetMethod")]
[TestCase("RecordGetParameter")]
[TestCase("RecordGetReportDataItem")]
[TestCase("RecordGetReturnValue")]
[TestCase("RecordGetSetupTableIncorrectArgumentsProvided")]
[TestCase("RecordGetSetupTableNoArgumentsProvided")]
[TestCase("RecordGetXmlPortTableElement")]
public async Task HasDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "HasDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0075RecordGetProcedureArguments>();
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0075RecordGetProcedureArguments.Id);
}

[Test]
[TestCase("ImplicitConversiontIntegerToEnum")]
[TestCase("ImplicitConversiontLabelToCode")]
[TestCase("RecordGetBuiltInMethodRecordId")]
[TestCase("RecordGetCode10ToCode20")]
[TestCase("RecordGetFieldRecordId")]
[TestCase("RecordGetGlobalVariable")]
[TestCase("RecordGetLocalVariable")]
[TestCase("RecordGetLocalVariableRecordId")]
[TestCase("RecordGetMethod")]
[TestCase("RecordGetMethodRecordId")]
[TestCase("RecordGetParameter")]
[TestCase("RecordGetParameterRecordId")]
[TestCase("RecordGetReportDataItem")]
[TestCase("RecordGetReturnValue")]
[TestCase("RecordGetReturnValueRecordId")]
[TestCase("RecordGetSetupTableCorrectArgumentsProvided")]
[TestCase("RecordGetSetupTableNoArgumentsProvided")]
[TestCase("RecordGetXmlPortTableElement")]
public async Task NoDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0075RecordGetProcedureArguments>();
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0075RecordGetProcedureArguments.Id);
}
}
#endif
44 changes: 44 additions & 0 deletions BusinessCentral.LinterCop.Test/Rule0076.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace BusinessCentral.LinterCop.Test;

public class Rule0076
{
private string _testCaseDir = "";

[SetUp]
public void Setup()
{
_testCaseDir = Path.Combine(Directory.GetParent(Environment.CurrentDirectory)!.Parent!.Parent!.FullName,
"TestCases", "Rule0076");
}

[Test]
[TestCase("TableRelationLonger")]
[TestCase("TableRelationImplicitFieldPrimaryKey")]
#if !LessThenSpring2024
[TestCase("TableExtRelationLonger")]
#endif
public async Task HasDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "HasDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0076TableRelationTooLong>();
fixture.HasDiagnostic(code, DiagnosticDescriptors.Rule0076TableRelationTooLong.Id);
}

[Test]
[TestCase("TableRelationEqual")]
[TestCase("TableRelationShorter")]
#if !LessThenSpring2024
[TestCase("TableExtRelationEqual")]
[TestCase("TableExtRelationShorter")]
#endif
public async Task NoDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al"))
.ConfigureAwait(false);

var fixture = RoslynFixtureFactory.Create<Rule0076TableRelationTooLong>();
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0076TableRelationTooLong.Id);
}
}
Loading

0 comments on commit eebd80f

Please sign in to comment.