Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix boolean conversion for Rule0032 #677

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

dannoe
Copy link
Contributor

@dannoe dannoe commented Jul 7, 2024

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 has SingleInstance = 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:

codeunit 54104 MyCodeunit
{
    var
        LogInManagement: Codeunit LogInManagement;

    procedure DoSomething()
    begin
        // This will not trigger the Rule0032 as GetMembers() does not work for
        // codeunits that are referenced by app/symbols and not by source code.
        // and singleInstanceProperty.Value will return "1" as a string instead of a boolean
        ClearAll(); 
    end;
}

I tried to mitigate this problem by accessing internal methods (like the GlobalVariables property of ReferenceCodeunitTypeSymbol) via reflection, but decided against it since I would have needed even more reflection to cast the return types correctly.

Fixes #523

@Arthurvdv
Copy link
Collaborator

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!

@Arthurvdv Arthurvdv merged commit 6400d1c into StefanMaron:prerelease Jul 8, 2024
41 checks passed
@dannoe dannoe deleted the fix-523 branch July 8, 2024 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants