-
Notifications
You must be signed in to change notification settings - Fork 33
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
Warn if eventsubscribers don't use var for parameters defined as var. #676
Warn if eventsubscribers don't use var for parameters defined as var. #676
Conversation
46eb77a
to
7c296e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried a new way to add the DiagnosticDescriptors. For this rule the Descriptors is now in a nested class inside the rule itself.
The reason for this is, that I find the LinterCopAnalyzers.Generated.cs file very unclear and unreadable with these extreme long lines.
I see the difference now and absolutely agree that the new way is more clear and readable. I do have a question about the nested class inside the rule itself. There are a few exceptions where the rule and the descriptor aren't coupled, like the descriptors Rule0005VariableCasingShouldNotDifferFromDeclaration
is used in the Rule0003 and Rule0005 class. Can this then still work?
BusinessCentral.LinterCop/Design/Rule0054FollowInterfaceObjectNameGuide.cs
Outdated
Show resolved
Hide resolved
BusinessCentral.LinterCop/Design/Rule0065CheckEventSubscriberVarKeyword.cs
Show resolved
Hide resolved
As long as the nested class is accessible from other places in the code (like public or internal for the same assembly) this should be no problem. |
First I wanted to thank you contributing, really appreciatie you're taking the time to help further improve the LinterCop :-) When I was creating a example for the wiki, I've run into ArgumentNullException (due tough a typo I've created) codeunit 50100 MyBusinessLogic
{
[IntegrationEvent(false, false)]
local procedure OnBeforeMyBusinessLogic(var Customer: Record Customer; var IsHandled: Boolean)
begin
end;
}
codeunit 50501 MyEventSubscriber
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::MyBusinessLogic, NonExistingEventName, '', false, false)]
local procedure OnBeforeMyBusinessLogicOnMyBusinessLogic(Customer: Record Customer)
begin
end;
} While the AL code is wrong due to the |
That's interesting. The exceptions occurred because there was a null given as a parameter to the At first I couldn't reproduce this on my site because I was testing it with a large project (700+ files). But I was able to reproduce it with a smaller test project and added an additional null check. Edit: I removed the NRE fix from this PR and opened a seperate PR (#678) |
ValueText could be null, if the AL code is not compilable
63ce7bf
to
d28eb0f
Compare
Again, thanks for the contribution, much appreciated :-) |
This implements the idea from #654 and adds tests for the rule.
I also did some additional things:
The reason for this is, that I find the
LinterCopAnalyzers.Generated.cs
file very unclear and unreadable with these extreme long lines.I am open to suggestions, vetoes, or requests to split these changes into multiple PRs.