From cdb2c312e93b1d59f43a34f1d606fe7e31ab6f5b Mon Sep 17 00:00:00 2001 From: StefanMaron Date: Sat, 22 Jan 2022 15:55:19 +0100 Subject: [PATCH 1/3] Bugfix for #130 --- BusinessCentral.LinterCop.csproj | 1 + .../Rule0003DoNotUseObjectIDsInVariablesOrProperties.cs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/BusinessCentral.LinterCop.csproj b/BusinessCentral.LinterCop.csproj index 88f6487a..83d8caaf 100644 --- a/BusinessCentral.LinterCop.csproj +++ b/BusinessCentral.LinterCop.csproj @@ -21,6 +21,7 @@ true full false + portable bin\Debug\ DEBUG;TRACE prompt diff --git a/Design/Rule0003DoNotUseObjectIDsInVariablesOrProperties.cs b/Design/Rule0003DoNotUseObjectIDsInVariablesOrProperties.cs index 4c1cc081..5ba62211 100644 --- a/Design/Rule0003DoNotUseObjectIDsInVariablesOrProperties.cs +++ b/Design/Rule0003DoNotUseObjectIDsInVariablesOrProperties.cs @@ -1,10 +1,7 @@ using Microsoft.Dynamics.Nav.CodeAnalysis; using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics; -using Microsoft.Dynamics.Nav.CodeAnalysis.Syntax; using System; using System.Collections.Immutable; -using System.Linq; -using System.Text.RegularExpressions; using System.Threading; namespace BusinessCentral.LinterCop.Design @@ -92,7 +89,10 @@ private void CheckForObjectIDsInVariablesOrProperties(SyntaxNodeAnalysisContext if (ctx.Node.GetLocation().SourceSpan.End == parameter.DeclaringSyntaxReference.GetSyntax(CancellationToken.None).Span.End) { - correctName = GetCorrectName(parameter.ParameterType.NavTypeKind.ToString(), parameter.ParameterType.ToString()); + if (parameter.ParameterType.NavTypeKind == NavTypeKind.Array) + correctName = ((IArrayTypeSymbol)(parameter.ParameterType)).ElementType.Name.ToString(); + else + correctName = GetCorrectName(parameter.ParameterType.NavTypeKind.ToString(), parameter.ParameterType.ToString()); if (ctx.Node.ToString().Trim('"').ToUpper() != correctName.ToUpper()) ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0003DoNotUseObjectIDsInVariablesOrProperties, ctx.Node.GetLocation(), new object[] { ctx.Node.ToString().Trim('"'), correctName })); From b61bc63053067c6d9992972cffe73179672e3f00 Mon Sep 17 00:00:00 2001 From: StefanMaron Date: Sat, 22 Jan 2022 16:16:29 +0100 Subject: [PATCH 2/3] #128 and #127 --- Design/Rule0015PermissionSetCoverage.cs | 15 +++++---- LinterCopAnalyzers.resx | 44 ++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/Design/Rule0015PermissionSetCoverage.cs b/Design/Rule0015PermissionSetCoverage.cs index 7cec6253..392116d4 100644 --- a/Design/Rule0015PermissionSetCoverage.cs +++ b/Design/Rule0015PermissionSetCoverage.cs @@ -2,16 +2,17 @@ using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics; using System; using System.Collections.Immutable; -using Microsoft.Dynamics.Nav.Analyzers.Common.AppSourceCopConfiguration; using Microsoft.Dynamics.Nav.Analyzers.Common; using System.Collections.Generic; using System.Linq; using System.Xml.Linq; using System.Xml.XPath; -namespace BusinessCentral.LinterCop.Design { +namespace BusinessCentral.LinterCop.Design +{ [DiagnosticAnalyzer] - class Rule0015PermissionSetCoverage : DiagnosticAnalyzer { + class Rule0015PermissionSetCoverage : DiagnosticAnalyzer + { public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(DiagnosticDescriptors.Rule0015PermissionSetCoverage); public override void Initialize(AnalysisContext context) @@ -39,7 +40,7 @@ private void CheckPermissionSetCoverage(SymbolAnalysisContext context) { ISymbol current = enumerator.Current; IApplicationObjectTypeSymbol appObjTypeSymbol = (IApplicationObjectTypeSymbol)current; - PermissionObjectKind permObjectKind = PermissionObjectKind.TableData; + PermissionObjectKind permObjectKind = PermissionObjectKind.Table; int permObjectId = appObjTypeSymbol.Id; switch (appObjTypeSymbol.NavTypeKind) @@ -57,7 +58,7 @@ private void CheckPermissionSetCoverage(SymbolAnalysisContext context) permObjectKind = PermissionObjectKind.Report; break; case NavTypeKind.Table: - permObjectKind = PermissionObjectKind.TableData; + permObjectKind = PermissionObjectKind.Table; break; case NavTypeKind.XmlPort: permObjectKind = PermissionObjectKind.Xmlport; @@ -68,12 +69,12 @@ private void CheckPermissionSetCoverage(SymbolAnalysisContext context) { continue; } - if (permissionSymbols.Contains((permObjectKind, permObjectId)) || XmlPermissionExistsForObject(permissionSetDocuments, permObjectKind, permObjectId)) + if (permissionSymbols.Contains((permObjectKind, permObjectId)) || permissionSymbols.Contains((permObjectKind, 0)) || XmlPermissionExistsForObject(permissionSetDocuments, permObjectKind, permObjectId)) { continue; } - context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0015PermissionSetCoverage, current.GetLocation(), new Object[] { appObjTypeSymbol.NavTypeKind.ToString(), appObjTypeSymbol.Name })); + context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0015PermissionSetCoverage, current.GetLocation(), new Object[] { permObjectKind.ToString(), appObjTypeSymbol.Name })); } } diff --git a/LinterCopAnalyzers.resx b/LinterCopAnalyzers.resx index fec696a7..bdf64590 100644 --- a/LinterCopAnalyzers.resx +++ b/LinterCopAnalyzers.resx @@ -119,129 +119,171 @@ LC + FlowFields should not be editable. + FlowFields should not be editable. + FlowFields should not be editable. + Commit() needs a comment to justify its existance. Either a leading or a trailing comment. + Commit() needs a comment to justify its existance. Either a leading or a trailing comment. + Commit() needs a comment to justify its existance. Either a leading or a trailing comment. + Do not use an Object ID for properties or variables declaration. + Do not use an Object ID for properties or variables declaration. Use {1} instead. + Do not use an Object ID for properties or variables declaration. + Property "LookupPageID" and "DrilldownPageID" must be filled in table because it is used in list page + Property "LookupPageID" and "DrilldownPageID" must be filled in table "{1}" because it is used in page "{2}" (list) + Property "LookupPageID" and "DrilldownPageID" must be filled in table because it is used in list page + Wrong casing detected! + Wrong casing detected! Use {0} instead. + Wrong casing detected! + AutoIncrement fields are not possible in temporary tables! + AutoIncrement fields are not possible in temporary tables! + AutoIncrement fields are not possible in temporary tables! + DataPerCompany is missing! + DataPerCompany is missing! + DataPerCompany is missing! + Filter operators should not be used in SetRange. Use SetFilter instead. + Filter operators should not be used in SetRange. Use SetFilter instead. + Filter operators should not be used in SetRange. Use SetFilter instead. + Cyclomatic complexity and Maintainability index + Cyclomatic complexity: {0}, Maintainability index: {1} + Cyclomatic complexity and Maintainability index + Access property is missing! + Access property is missing! + Access property is missing! + Wrong Parameter detected. + Wrong Parameter detected. Select the correct object with "{0}::" instead. + Wrong Parameter detected. + NotBlank should be set explicitly for tables with a single-field primary key. + NotBlank should be set explicitly for tables with a single-field primary key. + NotBlank should be set explicitly for tables with a single-field primary key. + The Caption of permissionset objects should not exceed the maximum length. + The Caption of permissionset objects should not exceed {0} characters. Use MaxLength={0} or Locked=true to ensure there are no translations that exceed this limit. + The Caption of permissionset objects should not exceed the maximum length. + All application objects should be covered by at least one permission set in the extension. + - The application object {0} {1} is not covered by any permission set in the extension. + The application object {0} "{1}" is not covered by any permission set in the extension. + All application objects should be covered by at least one permission set in the extension. From f2ca0bf6d244071cfe3817c5e91a9d8d358f9ee5 Mon Sep 17 00:00:00 2001 From: StefanMaron Date: Sat, 22 Jan 2022 16:18:53 +0100 Subject: [PATCH 3/3] switch to new compiler --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47768108..9fbe7704 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,10 +23,10 @@ jobs: uses: actions/cache@v2 with: path: ALLanguage.vsix - key: vsix-19.2.32968.34478 + key: vsix-19.3.34541.35210 - name: Download platform artifact if: steps.cache-vsix.outputs.cache-hit != 'true' - run: Invoke-WebRequest https://bcartifacts.blob.core.windows.net/sandbox/19.2.32968.34478/platform -OutFile platform.zip + run: Invoke-WebRequest https://bcartifacts.azureedge.net/sandbox/19.3.34541.35210/platform -OutFile platform.zip - name: Unzip platform if: steps.cache-vsix.outputs.cache-hit != 'true' run: 7z x platform.zip *.vsix -r