Skip to content

Commit

Permalink
Resolve InvalidCastException on Rule0044 (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthurvdv authored Nov 1, 2024
1 parent 01adc03 commit 9c9f05f
Show file tree
Hide file tree
Showing 6 changed files with 519 additions and 431 deletions.
41 changes: 41 additions & 0 deletions BusinessCentral.LinterCop.Test/Rule0044.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace BusinessCentral.LinterCop.Test;

public class Rule0044
{
private string _testCaseDir = "";

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

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

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

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

var fixture = RoslynFixtureFactory.Create<Rule0044AnalyzeTransferFields>();
fixture.NoDiagnosticAtMarker(code, DiagnosticDescriptors.Rule0044AnalyzeTransferFields.Id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
tableextension 50100 Customer extends Customer
{
fields
{
[|field(50100; MyField; Code[20]) { }|]
}
}

tableextension 50101 Contact extends Contact
{
fields
{
field(50100; MyField; Integer) { }
}
}

table 18 Customer
{
fields
{
field(1; "No."; Code[20]) { }
}
}
table 5050 Contact
{
fields
{
field(1; "No."; Code[20]) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
codeunit 50100 MyCodeunit
{
procedure MyProcedure()
var
MyTableA: Record MyTableA;
MyTableB: Record MyTableB;
begin
[|MyTableA.TransferFields(MyTableB)|];
end;
}

table 50100 MyTableA
{
fields
{
field(1; "No."; Code[10]) { }
}
}
table 50101 MyTableB
{
fields
{
field(1; "No."; Code[20]) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
tableextension 50100 Customer extends Customer
{
fields
{
[|field(50100; MyField; Integer) { }|]
}
}

tableextension 50101 Contact extends Contact
{
fields
{
field(50100; MyField; Integer) { }
}
}

table 18 Customer
{
fields
{
field(1; "No."; Code[20]) { }
}
}
table 5050 Contact
{
fields
{
field(1; "No."; Code[20]) { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
codeunit 50100 MyCodeunit
{
procedure MyProcedure()
var
MyTableA: Record MyTableA;
MyTableB: Record MyTableB;
begin
[|MyTableA.TransferFields(MyTableB)|];
end;
}

table 50100 MyTableA
{
fields
{
field(1; "No."; Code[20]) { }
}
}
table 50101 MyTableB
{
fields
{
field(1; "No."; Code[20]) { }
}
}
Loading

0 comments on commit 9c9f05f

Please sign in to comment.