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

LC0035 - Diagnostic for fields where base table has page set #670

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ private void AnalyzeAllowInCustomization(SymbolAnalysisContext ctx)
if (!tableFields.Any()) return;

IEnumerable<IApplicationObjectTypeSymbol> relatedPages = GetRelatedPages(ctx);
if (!relatedPages.Any()) return;

if (!relatedPages.Any())
{
if (ctx.Symbol.GetTypeSymbol().Kind != SymbolKind.TableExtension)
return;
ITableExtensionTypeSymbol tableExtension = (ITableExtensionTypeSymbol)ctx.Symbol;
if (!LookupOrDrillDownPageIsSet((ITableTypeSymbol)tableExtension.Target))
return;
// allows diagnostic for table extension fields where base table has lookup or drilldown page set
// even if no relatedPages exist directly
}

NavTypeKind navTypeKind = ctx.Symbol.GetContainingObjectTypeSymbol().GetNavTypeKindSafe();
ICollection<IFieldSymbol> pageFields = GetPageFields(navTypeKind, relatedPages);
Expand Down Expand Up @@ -118,6 +128,11 @@ private static bool IsSupportedType(NavTypeKind navTypeKind)
return true;
}
}

private static bool LookupOrDrillDownPageIsSet(ITableTypeSymbol table)
{
return table.Properties.Any(e => e.PropertyKind == PropertyKind.DrillDownPageId || e.PropertyKind == PropertyKind.LookupPageId);
}
}
}
#endif