-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #327 from StefanMaron/AccessInternalForInstallOrUp…
…gradeCodeunits Rule0030AccessInternalForInstallAndUpgradeCodeunit
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
Design/Rule0030AccessInternalForInstallOrUpgradeCodeunits.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.Dynamics.Nav.CodeAnalysis; | ||
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics; | ||
using System.Collections.Immutable; | ||
using Microsoft.Dynamics.Nav.CodeAnalysis.Symbols; | ||
|
||
namespace BusinessCentral.LinterCop.Design | ||
{ | ||
[DiagnosticAnalyzer] | ||
class Rule0030AccessInternalForInstallAndUpgradeCodeunits : DiagnosticAnalyzer | ||
{ | ||
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create<DiagnosticDescriptor>(DiagnosticDescriptors.Rule0030AccessInternalForInstallAndUpgradeCodeunits); | ||
|
||
public override void Initialize(AnalysisContext context) => context.RegisterSymbolAction(new Action<SymbolAnalysisContext>(this.CheckAccessOnInstallAndUpgradeCodeunits), SymbolKind.Codeunit); | ||
|
||
private void CheckAccessOnInstallAndUpgradeCodeunits(SymbolAnalysisContext context) | ||
{ | ||
if (context.Symbol.IsObsoletePending || context.Symbol.IsObsoleteRemoved) return; | ||
|
||
ICodeunitTypeSymbol symbol = (ICodeunitTypeSymbol)context.Symbol; | ||
if (symbol.Subtype != CodeunitSubtypeKind.Install && symbol.Subtype != CodeunitSubtypeKind.Upgrade) | ||
return; | ||
|
||
if (symbol.DeclaredAccessibility == Accessibility.Public) | ||
context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.Rule0030AccessInternalForInstallAndUpgradeCodeunits, symbol.GetLocation())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters