Skip to content

Commit

Permalink
Merge pull request #462 from StefanMaron/prerelease
Browse files Browse the repository at this point in the history
Merge 'prerelease' into master
  • Loading branch information
Arthurvdv authored Dec 20, 2023
2 parents 68ee6a3 + 141c8c0 commit c3c3ff3
Show file tree
Hide file tree
Showing 14 changed files with 1,172 additions and 124 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ jobs:
("Version(""" + ('${{ steps.create_release.outputs.tag_name }}'
-replace "v","") + """)]") | Out-File AssemblyInfo.cs
- name: Build current
run: dotnet build --no-restore
run: dotnet build --no-restore --configuration Release
- name: Upload a Build current
uses: actions/upload-artifact@v2.2.4
with:
name: BusinessCentral.LinterCop.current.dll
path: bin/Debug/netstandard2.0/BusinessCentral.LinterCop.dll
path: bin/Release/netstandard2.1/BusinessCentral.LinterCop.dll
- name: Remove a Release Asset current
uses: flcdrg/remove-release-asset-action@v1.0.13
env:
Expand All @@ -86,23 +86,23 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/Debug/netstandard2.0/BusinessCentral.LinterCop.dll
asset_path: bin/Release/netstandard2.1/BusinessCentral.LinterCop.dll
asset_name: BusinessCentral.LinterCop.current.dll
asset_content_type: application/octet-stream
- name: Clear Build output
run: Remove-Item -Path "bin/Debug" -Force -Recurse -Verbose;
run: Remove-Item -Path "bin/Release" -Force -Recurse -Verbose;
- name: Unzip vsix next
run: >
Remove-Item -Path "ms-dynamics-smb.al-latest" -Force -Recurse -Verbose;
7z x "ALLanguage_next.vsix" "-oms-dynamics-smb.al-latest" extension\bin\Analyzers -r;
- name: Build next
run: dotnet build --no-restore
run: dotnet build --no-restore --configuration Release

- name: Upload a Build next
uses: actions/upload-artifact@v2.2.4
with:
name: BusinessCentral.LinterCop.next.dll
path: bin/Debug/netstandard2.0/BusinessCentral.LinterCop.dll
path: bin/Release/netstandard2.1/BusinessCentral.LinterCop.dll
- name: Remove a Release Asset next
uses: flcdrg/remove-release-asset-action@v1.0.13
env:
Expand All @@ -117,6 +117,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/Debug/netstandard2.0/BusinessCentral.LinterCop.dll
asset_path: bin/Release/netstandard2.1/BusinessCentral.LinterCop.dll
asset_name: BusinessCentral.LinterCop.next.dll
asset_content_type: application/octet-stream
2 changes: 1 addition & 1 deletion BusinessCentral.LinterCop.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>Latest</LangVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down
9 changes: 5 additions & 4 deletions Design/Rule0004LookupPageIdAndDrillDownPageId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ public class Rule0004LookupPageIdAndDrillDownPageId : DiagnosticAnalyzer
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create<DiagnosticDescriptor>(DiagnosticDescriptors.Rule0004LookupPageIdAndDrillDownPageId);

public override void Initialize(AnalysisContext context)
=> context.RegisterSymbolAction(new Action<SymbolAnalysisContext>(this.CheckForLookupPageIdAndDrilldownPageId), SymbolKind.Page);
=> context.RegisterSymbolAction(new Action<SymbolAnalysisContext>(this.CheckForLookupPageIdAndDrillDownPageId), SymbolKind.Page);

private void CheckForLookupPageIdAndDrilldownPageId(SymbolAnalysisContext context)
private void CheckForLookupPageIdAndDrillDownPageId(SymbolAnalysisContext context)
{
if (context.Symbol.IsObsoletePending || context.Symbol.IsObsoleteRemoved) return;
IPageTypeSymbol pageTypeSymbol = (IPageTypeSymbol)context.Symbol;
if (pageTypeSymbol.PageType == PageTypeKind.List && pageTypeSymbol.RelatedTable != null)
CheckTable(pageTypeSymbol.RelatedTable, ref context);
if (pageTypeSymbol.PageType != PageTypeKind.List || pageTypeSymbol.RelatedTable == null) return;
if (pageTypeSymbol.RelatedTable.ContainingModule != context.Symbol.ContainingModule) return;
CheckTable(pageTypeSymbol.RelatedTable, ref context);
}

private void CheckTable(ITableTypeSymbol table, ref SymbolAnalysisContext context)
Expand Down
248 changes: 164 additions & 84 deletions Design/Rule0005VariableCasingShouldNotDifferFromDeclaration.cs

Large diffs are not rendered by default.

53 changes: 26 additions & 27 deletions Design/Rule0021BuiltInMethodImplementThroughCodeunit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,41 @@ public class BuiltInMethodImplementThroughCodeunit : DiagnosticAnalyzer
{
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create<DiagnosticDescriptor>(
DiagnosticDescriptors.Rule0021ConfirmImplementConfirmManagement,
DiagnosticDescriptors.Rule0022GlobalLanguageImplementTranslationHelper,
DiagnosticDescriptors.Rule0000ErrorInRule);
DiagnosticDescriptors.Rule0022GlobalLanguageImplementTranslationHelper
);

public override void Initialize(AnalysisContext context) => context.RegisterOperationAction(new Action<OperationAnalysisContext>(this.CheckBuiltInMethod), OperationKind.InvocationExpression);
public override void Initialize(AnalysisContext context)
{
context.RegisterOperationAction(new Action<OperationAnalysisContext>(this.AnalyzeConfirm), OperationKind.InvocationExpression);
context.RegisterOperationAction(new Action<OperationAnalysisContext>(this.AnalyzeGlobalLanguage), OperationKind.InvocationExpression);
}

private void AnalyzeConfirm(OperationAnalysisContext ctx)
{
if (ctx.ContainingSymbol.GetContainingObjectTypeSymbol().IsObsoletePending || ctx.ContainingSymbol.GetContainingObjectTypeSymbol().IsObsoleteRemoved) return;
if (ctx.ContainingSymbol.IsObsoletePending || ctx.ContainingSymbol.IsObsoleteRemoved) return;

IInvocationExpression operation = (IInvocationExpression)ctx.Operation;
if (operation.TargetMethod.MethodKind != MethodKind.BuiltInMethod) return;
if (!SemanticFacts.IsSameName(operation.TargetMethod.Name, "Confirm")) return;

if (ctx.ContainingSymbol.GetContainingObjectTypeSymbol().NavTypeKind == NavTypeKind.Page &&
((IPageTypeSymbol)ctx.ContainingSymbol.GetContainingObjectTypeSymbol()).PageType != PageTypeKind.API) return;

ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0021ConfirmImplementConfirmManagement, ctx.Operation.Syntax.GetLocation()));
}

private void CheckBuiltInMethod(OperationAnalysisContext ctx)
private void AnalyzeGlobalLanguage(OperationAnalysisContext ctx)
{
if (ctx.ContainingSymbol.GetContainingObjectTypeSymbol().IsObsoletePending || ctx.ContainingSymbol.GetContainingObjectTypeSymbol().IsObsoleteRemoved) return;
if (ctx.ContainingSymbol.IsObsoletePending || ctx.ContainingSymbol.IsObsoleteRemoved) return;

IInvocationExpression operation = (IInvocationExpression)ctx.Operation;
if (operation.TargetMethod.MethodKind != MethodKind.BuiltInMethod) return;
if (!SemanticFacts.IsSameName(operation.TargetMethod.Name, "GlobalLanguage")) return;
if (operation.Arguments.Length == 0) return;

switch (operation.TargetMethod.Name.ToUpper())
{
case "CONFIRM":
try
{
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0021ConfirmImplementConfirmManagement, ctx.Operation.Syntax.GetLocation()));
}
catch (ArgumentOutOfRangeException)
{
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0000ErrorInRule, ctx.Operation.Syntax.GetLocation(), new Object[] { "Rule0021", "ArgumentOutOfRangeException", "at Line 29" }));
}
break;
case "GLOBALLANGUAGE":
try
{
if (operation.Arguments.Length != 0) { ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0022GlobalLanguageImplementTranslationHelper, ctx.Operation.Syntax.GetLocation())); }
}
catch (ArgumentOutOfRangeException)
{
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0000ErrorInRule, ctx.Operation.Syntax.GetLocation(), new Object[] { "Rule0022", "ArgumentOutOfRangeException", "at Line 39" }));
}
break;
}
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0022GlobalLanguageImplementTranslationHelper, ctx.Operation.Syntax.GetLocation()));
}
}
}
2 changes: 1 addition & 1 deletion Design/Rule0040ExplicitlySetRunTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ private void AnalyzeRunTriggerParameters(OperationAnalysisContext ctx)

IInvocationExpression operation = (IInvocationExpression)ctx.Operation;
if (operation.TargetMethod.MethodKind != MethodKind.BuiltInMethod) return;
if (!(operation.Instance?.GetSymbol().GetTypeSymbol().GetNavTypeKindSafe() == NavTypeKind.Record || operation.Instance?.GetSymbol().GetTypeSymbol().GetNavTypeKindSafe() == NavTypeKind.RecordRef)) return;
if (!buildInMethodNames.Contains(operation.TargetMethod.Name.ToLowerInvariant())) return;
if (!(operation.Instance?.GetSymbol().GetTypeSymbol().GetNavTypeKindSafe() == NavTypeKind.Record || operation.Instance?.GetSymbol().GetTypeSymbol().GetNavTypeKindSafe() == NavTypeKind.RecordRef)) return;

if (operation.Arguments.Where(args => SemanticFacts.IsSameName(args.Parameter.Name, "RunTrigger")).SingleOrDefault() == null)
ctx.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0040ExplicitlySetRunTrigger, ctx.Operation.Syntax.GetLocation()));
Expand Down
Loading

0 comments on commit c3c3ff3

Please sign in to comment.