Skip to content

Commit

Permalink
Merge pull request #372 from StefanMaron/development
Browse files Browse the repository at this point in the history
Rule0035 Check for Enabled and Obsolete
  • Loading branch information
Arthurvdv authored Nov 27, 2023
2 parents 1b29397 + 1809a70 commit b0e0bc5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Design/Rule0035ExplicitSetAllowInCustomizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ private void AnalyzeAllowInCustomization(SymbolAnalysisContext ctx)
if (manifest.Runtime < RuntimeVersion.Fall2023) return;

ICollection<IFieldSymbol> tableFields = GetTableFields(ctx.Symbol).Where(x => x.Id > 0 && x.Id < 2000000000)
.Where(x => x.GetBooleanPropertyValue(PropertyKind.Enabled) != false)
.Where(x => x.GetProperty(PropertyKind.AllowInCustomizations) is null)
.Where(x => x.GetProperty(PropertyKind.ObsoleteState) is null)
.ToList();
if (!tableFields.Any()) return;

Expand All @@ -46,7 +48,7 @@ private static ICollection<IFieldSymbol> GetTableFields(ISymbol symbol)
{
switch (symbol.GetContainingObjectTypeSymbol().GetNavTypeKindSafe())
{
case NavTypeKind.Table:
case NavTypeKind.Record:
return ((ITableTypeSymbol)symbol).Fields;
case NavTypeKind.TableExtension:
return ((ITableExtensionTypeSymbol)symbol).AddedFields;
Expand All @@ -60,7 +62,7 @@ private static ICollection<IFieldSymbol> GetPageFields(NavTypeKind navTypeKind,
ICollection<IFieldSymbol> pageFields = new Collection<IFieldSymbol>();
switch (navTypeKind)
{
case NavTypeKind.Table:
case NavTypeKind.Record:
foreach (IPageTypeSymbol page in relatedPages.Cast<IPageTypeSymbol>())
{
IEnumerable<IFieldSymbol> fields = page.FlattenedControls.Where(x => x.ControlKind == ControlKind.Field && x.RelatedFieldSymbol != null)
Expand All @@ -87,7 +89,7 @@ private static IEnumerable<IApplicationObjectTypeSymbol> GetRelatedPages(SymbolA
{
switch (ctx.Symbol.GetContainingObjectTypeSymbol().GetNavTypeKindSafe())
{
case NavTypeKind.Table:
case NavTypeKind.Record:
return ctx.Compilation.GetDeclaredApplicationObjectSymbols()
.Where(x => x.GetNavTypeKindSafe() == NavTypeKind.Page)
.Where(x => ((IPageTypeSymbol)x.GetTypeSymbol()).PageType != PageTypeKind.API)
Expand Down

0 comments on commit b0e0bc5

Please sign in to comment.