Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion BusinessCentral.LinterCop/Helpers/HelperFunctions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Dynamics.Nav.CodeAnalysis;
using Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics;
using Microsoft.Dynamics.Nav.CodeAnalysis.Symbols;
using Microsoft.Dynamics.Nav.CodeAnalysis.Syntax;
using System.Text.RegularExpressions;
using Microsoft.Dynamics.Nav.CodeAnalysis.Text;
Expand All @@ -22,7 +23,7 @@ public static bool MethodImplementsInterfaceMethod(IApplicationObjectTypeSymbol?

foreach (var implementedInterface in codeunitSymbol.ImplementedInterfaces)
{
if (implementedInterface.GetMembers().OfType<IMethodSymbol>().Any(interfaceMethodSymbol => MethodImplementsInterfaceMethod(methodSymbol, interfaceMethodSymbol)))
if (MethodImplementsInterfaceMethod(implementedInterface, methodSymbol))
{
return true;
}
Expand All @@ -31,6 +32,25 @@ public static bool MethodImplementsInterfaceMethod(IApplicationObjectTypeSymbol?
return false;
}

public static bool MethodImplementsInterfaceMethod(IInterfaceTypeSymbol interfaceTypeSymbol, IMethodSymbol methodSymbol)
{
if (interfaceTypeSymbol.GetMembers().OfType<IMethodSymbol>().Any(interfaceMethodSymbol => MethodImplementsInterfaceMethod(methodSymbol, interfaceMethodSymbol)))
{
return true;
}
#if !LessThenFall2024
foreach (var extendedInterface in interfaceTypeSymbol.ExtendedInterfaces)
{
if (MethodImplementsInterfaceMethod(extendedInterface, methodSymbol))
{
return true;
}
}
#endif

return false;
}

public static bool MethodImplementsInterfaceMethod(IMethodSymbol methodSymbol, IMethodSymbol interfaceMethodSymbol)
{
if (methodSymbol.Name != interfaceMethodSymbol.Name)
Expand Down