Closed dannoe closed 2 months ago
This issue was driving me crazy and couldn't create a repo for this.
As this rule is fairly a specific use case which only occurs in an exceptional situation, preventing the exception seems enough and fair. Thank you for researching on this!
This is a partial fix for issue #523. It is only partial, because it prevents the exception, but the rule (still) can not detect problems with codeunits, that are only available as symbol/app and not as source code.
The reason for the previous exception:
singleInstanceProperty.Value
returns "1" if the codeunit hasSingleInstance = true
set and is referenced via app/symbol.The reason why it is not fully fixable: The
codeunitTypeSymbol.GetMembers()
call does not return global variables for codeunits that are only available as symbol/app and not in "real" source code. We are only getting procedures and triggers. Here's an example:I tried to mitigate this problem by accessing internal methods (like the
GlobalVariables
property ofReferenceCodeunitTypeSymbol
) via reflection, but decided against it since I would have needed even more reflection to cast the return types correctly.Fixes #523