Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issue on TableRelation to "No. Series" including the PK field #661

Merged
merged 7 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Design/Rule0013CheckForNotBlankOnSingleFieldPrimaryKeys.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BusinessCentral.LinterCop.AnalysisContextExtension;
using Microsoft.Dynamics.Nav.CodeAnalysis;
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using Microsoft.Dynamics.Nav.CodeAnalysis.Symbols;
using Microsoft.Dynamics.Nav.CodeAnalysis.Utilities;
using System.Collections.Immutable;

Expand Down Expand Up @@ -43,11 +44,17 @@ private static bool GetExitCondition(IFieldSymbol field)

private static bool TableContainsNoSeries(ITableTypeSymbol table)
{
return table.Fields.Any(field =>
return table.Fields
.Where(x => x.Id > 0 && x.Id < 2000000000)
.Where(x => x.FieldClass == FieldClassKind.Normal)
#if Fall2024
.Where(x => x.Type.GetNavTypeKindSafe() == NavTypeKind.Code)
#endif
.Any(field =>
{
var property = field.GetProperty(PropertyKind.TableRelation);
if (property != null)
return field.GetProperty(PropertyKind.TableRelation).ValueText.UnquoteIdentifier().StartsWith("No. Series");
IPropertySymbol propertySymbol = field.GetProperty(PropertyKind.TableRelation);
if (propertySymbol != null && propertySymbol.ContainingSymbol != null)
return SemanticFacts.IsSameName(propertySymbol.ContainingSymbol.Name.UnquoteIdentifier(), "No. Series");
return false;
});
}
Expand Down
4 changes: 2 additions & 2 deletions Design/Rule0039ArgumentDifferentTypeThenExpected.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void AnalyzeTableReferencePageProvider(SymbolAnalysisContext ctx)
if (pageSourceTable == null) continue;

if (!AreTheSameNavObjects(table, pageSourceTable))
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0039ArgumentDifferentTypeThenExpected, pageReference.GetLocation(), new object[] { 1, table.GetTypeSymbol().GetNavTypeKindSafe() + ' ' + table.Name.QuoteIdentifierIfNeeded(), pageSourceTable.GetNavTypeKindSafe().ToString() + ' ' + pageSourceTable.Name.QuoteIdentifierIfNeeded() }));
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0039ArgumentDifferentTypeThenExpected, pageReference.GetLocation(), new object[] { 1, table.GetTypeSymbol().GetNavTypeKindSafe().ToString() + ' ' + table.Name.QuoteIdentifierIfNeeded(), pageSourceTable.GetNavTypeKindSafe().ToString() + ' ' + pageSourceTable.Name.QuoteIdentifierIfNeeded() }));
}
}

Expand All @@ -125,7 +125,7 @@ private void AnalyzeTableExtensionReferencePageProvider(SymbolAnalysisContext ct
if (pageSourceTable == null) continue;

if (!AreTheSameNavObjects(table, pageSourceTable))
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0039ArgumentDifferentTypeThenExpected, pageReference.GetLocation(), new object[] { 1, table.GetTypeSymbol().GetNavTypeKindSafe() + ' ' + table.Name.QuoteIdentifierIfNeeded(), pageSourceTable.GetNavTypeKindSafe() + ' ' + pageSourceTable.Name.QuoteIdentifierIfNeeded() }));
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0039ArgumentDifferentTypeThenExpected, pageReference.GetLocation(), new object[] { 1, table.GetTypeSymbol().GetNavTypeKindSafe().ToString() + ' ' + table.Name.QuoteIdentifierIfNeeded(), pageSourceTable.GetNavTypeKindSafe().ToString() + ' ' + pageSourceTable.Name.QuoteIdentifierIfNeeded() }));
}
}

Expand Down