Skip to content

Commit

Permalink
Merge pull request #377 from StefanMaron/development
Browse files Browse the repository at this point in the history
Merge from 'Development' into prelease
  • Loading branch information
Arthurvdv authored Nov 28, 2023
2 parents 046addd + 175d7de commit 11c5637
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
6 changes: 2 additions & 4 deletions Design/Rule0011AccessPropertyShouldAlwaysBeSet.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Dynamics.Nav.Analyzers.Common.AppSourceCopConfiguration;
using Microsoft.Dynamics.Nav.CodeAnalysis;
using Microsoft.Dynamics.Nav.CodeAnalysis;
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using System.Collections.Immutable;
using BusinessCentral.LinterCop.Helpers;
Expand All @@ -16,8 +15,7 @@ public override void Initialize(AnalysisContext context)

private void CheckForMissingAccessProperty(SymbolAnalysisContext context)
{
var manifest = AppSourceCopConfigurationProvider.GetManifest(context.Compilation);
if (manifest.Runtime < RuntimeVersion.Spring2021 && (context.Symbol.Kind == SymbolKind.Enum || context.Symbol.Kind == SymbolKind.Interface))
if (!VersionChecker.IsSupported(context.Symbol, VersionCompatibility.Spring2021OrGreater) && (context.Symbol.Kind == SymbolKind.Enum || context.Symbol.Kind == SymbolKind.Interface))
return;

if (context.Symbol.IsObsoletePending || context.Symbol.IsObsoleteRemoved) return;
Expand Down
1 change: 1 addition & 0 deletions Design/Rule0016CheckForMissingCaptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private bool CaptionIsMissing(ISymbol Symbol, SymbolAnalysisContext context)

private static bool SuppressCaptionWarning(SymbolAnalysisContext context)
{
if (context.Symbol.GetContainingObjectTypeSymbol().GetTypeSymbol().GetNavTypeKindSafe() != NavTypeKind.Page) return false;
IPageTypeSymbol pageTypeSymbol = (IPageTypeSymbol)context.Symbol.GetContainingObjectTypeSymbol();
if (pageTypeSymbol.GetNavTypeKindSafe() != NavTypeKind.Page || pageTypeSymbol.PageType != PageTypeKind.API) return false;
LinterSettings.Create(context.Compilation.FileSystem.GetDirectoryPath());
Expand Down
7 changes: 2 additions & 5 deletions Design/Rule0031RecordInstanceIsolationLevel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.Dynamics.Nav.Analyzers.Common.AppSourceCopConfiguration;
using Microsoft.Dynamics.Nav.CodeAnalysis;
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using System.Collections.Immutable;
Expand All @@ -14,6 +13,8 @@ public class Rule0031RecordInstanceIsolationLevel : DiagnosticAnalyzer

private void CheckLockTable(OperationAnalysisContext ctx)
{
if (!VersionChecker.IsSupported(ctx.ContainingSymbol, VersionCompatibility.Spring2023OrGreater)) return;

if (ctx.ContainingSymbol.GetContainingObjectTypeSymbol().IsObsoletePending || ctx.ContainingSymbol.GetContainingObjectTypeSymbol().IsObsoleteRemoved) return;
if (ctx.ContainingSymbol.IsObsoletePending || ctx.ContainingSymbol.IsObsoleteRemoved) return;

Expand All @@ -22,10 +23,6 @@ private void CheckLockTable(OperationAnalysisContext ctx)

if (!SemanticFacts.IsSameName(operation.TargetMethod.Name, "LockTable")) return;

// ReadIsolation is supported from runtime versions 11.0 or greater.
var manifest = AppSourceCopConfigurationProvider.GetManifest(ctx.Compilation);
if (manifest.Runtime < RuntimeVersion.Spring2023) return;

ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0031RecordInstanceIsolationLevel, ctx.Operation.Syntax.GetLocation()));
}
}
Expand Down
7 changes: 2 additions & 5 deletions Design/Rule0034ExtensiblePropertyShouldAlwaysBeSet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.Dynamics.Nav.Analyzers.Common.AppSourceCopConfiguration;
using Microsoft.Dynamics.Nav.CodeAnalysis;
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using Microsoft.Dynamics.Nav.CodeAnalysis.Symbols;
Expand All @@ -20,17 +19,15 @@ public override void Initialize(AnalysisContext context)

private void CheckForMissingExtensibleProperty(SymbolAnalysisContext ctx)
{
if (!VersionChecker.IsSupported(ctx.Symbol, VersionCompatibility.Fall2019OrGreater)) return;

if (ctx.Symbol.IsObsoletePending || ctx.Symbol.IsObsoleteRemoved) return;

if (ctx.Symbol.GetTypeSymbol().Kind == SymbolKind.Table && ctx.Symbol.DeclaredAccessibility != Accessibility.Public) return;
if (ctx.Symbol.GetTypeSymbol().Kind == SymbolKind.Page && ((IPageTypeSymbol)ctx.Symbol.GetTypeSymbol()).PageType == PageTypeKind.API) return;

if (ctx.Symbol.GetProperty(PropertyKind.Extensible) != null) return;

// The Extensible property (and DeclaredAccessibility) is supported from runtime versions 4.0 or greater.
var manifest = AppSourceCopConfigurationProvider.GetManifest(ctx.Compilation);
if (manifest.Runtime < RuntimeVersion.Fall2019) return;

ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0034ExtensiblePropertyShouldAlwaysBeSet, ctx.Symbol.GetLocation(), new object[] { Accessibility.Public.ToString().ToLower() }));
}
}
Expand Down
7 changes: 2 additions & 5 deletions Design/Rule0035ExplicitSetAllowInCustomizations.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.Dynamics.Nav.Analyzers.Common.AppSourceCopConfiguration;
using Microsoft.Dynamics.Nav.CodeAnalysis;
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using Microsoft.Dynamics.Nav.CodeAnalysis.Symbols;
Expand All @@ -20,13 +19,11 @@ public override void Initialize(AnalysisContext context)

private void AnalyzeAllowInCustomization(SymbolAnalysisContext ctx)
{
if (!VersionChecker.IsSupported(ctx.Symbol, Feature.AddPageControlInPageCustomization)) return;

if (ctx.Symbol.IsObsoletePending || ctx.Symbol.IsObsoleteRemoved) return;
if (ctx.Symbol.GetContainingObjectTypeSymbol().IsObsoletePending || ctx.Symbol.GetContainingObjectTypeSymbol().IsObsoleteRemoved) return;

// The AllowInCustomizations property is supported from runtime versions 12.0 or greater.
var manifest = AppSourceCopConfigurationProvider.GetManifest(ctx.Compilation);
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)
Expand Down

0 comments on commit 11c5637

Please sign in to comment.