Skip to content

Commit

Permalink
StefanMaron#744 Fix XMLPort additional properties
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanMaron committed Sep 3, 2024
1 parent 86bf4a8 commit d3f8e94
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
3 changes: 2 additions & 1 deletion BusinessCentral.LinterCop.Test/Rule0068.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public async Task HasDiagnostic(string testCase)
#if Fall2023RV1
[TestCase("ProcedureCallsPermissionsPropertyFullyQualified")]
#endif
[TestCase("IntegerTable")]
// [TestCase("IntegerTable")]
[TestCase("XMLPortWithTableElementProps")]
public async Task NoDiagnostic(string testCase)
{
var code = await File.ReadAllTextAsync(Path.Combine(_testCaseDir, "NoDiagnostic", $"{testCase}.al"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
xmlport 50000 MyXmlport
{
Direction = Import;

schema
{
textelement(NodeName1)
{
[|tableelement(NodeName2; MyTable)|]
{
AutoReplace = false; // modify permissions
AutoSave = false; // insert permissions
AutoUpdate = false; //modify permissions

fieldattribute(NodeName3; NodeName2.MyField)
{

}
}
}
}
}

table 50000 MyTable
{
Caption = '', Locked = true;

fields
{
field(1; MyField; Integer)
{
Caption = '', Locked = true;
DataClassification = ToBeClassified;
}
field(2; MyField2; Integer)
{
Caption = '', Locked = true;
DataClassification = ToBeClassified;
}
}
}
14 changes: 12 additions & 2 deletions BusinessCentral.LinterCop/Design/Rule0068CheckObjectPermission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,22 @@ private void CheckXmlportNodeObjectPermission(SymbolAnalysisContext ctx)
else
direction = directionProperty.ValueText;

bool? AutoReplace = (bool?)ctx.Symbol.Properties.FirstOrDefault(property => property.PropertyKind == PropertyKind.AutoReplace)?.Value; // modify permissions
bool? AutoUpdate = (bool?)ctx.Symbol.Properties.FirstOrDefault(property => property.PropertyKind == PropertyKind.AutoUpdate)?.Value; // modify permissions
bool? AutoSave = (bool?)ctx.Symbol.Properties.FirstOrDefault(property => property.PropertyKind == PropertyKind.AutoSave)?.Value; // insert permissions

AutoReplace ??= true;
AutoUpdate ??= true;
AutoSave ??= true;

direction = direction.ToLowerInvariant();

if (direction == "import" || direction == "both")
{
CheckProcedureInvocation(objectPermissions, targetSymbol, 'm', ctx.ReportDiagnostic, ctx.Symbol.GetLocation(), (ITableTypeSymbol)targetSymbol.OriginalDefinition);
CheckProcedureInvocation(objectPermissions, targetSymbol, 'i', ctx.ReportDiagnostic, ctx.Symbol.GetLocation(), (ITableTypeSymbol)targetSymbol.OriginalDefinition);
if (AutoReplace == true || AutoUpdate == true)
CheckProcedureInvocation(objectPermissions, targetSymbol, 'm', ctx.ReportDiagnostic, ctx.Symbol.GetLocation(), (ITableTypeSymbol)targetSymbol.OriginalDefinition);
if (AutoSave == true)
CheckProcedureInvocation(objectPermissions, targetSymbol, 'i', ctx.ReportDiagnostic, ctx.Symbol.GetLocation(), (ITableTypeSymbol)targetSymbol.OriginalDefinition);
}
if (direction == "export" || direction == "both")
CheckProcedureInvocation(objectPermissions, targetSymbol, 'r', ctx.ReportDiagnostic, ctx.Symbol.GetLocation(), (ITableTypeSymbol)targetSymbol.OriginalDefinition);
Expand Down

0 comments on commit d3f8e94

Please sign in to comment.