microsoft / alguidelines

Best Practices and Design Patterns for the AL Language
https://alguidelines.dev/
MIT License
128 stars 48 forks source link

WITH Scope Name Collision #191

Open Ji-Peter opened 2 years ago

Ji-Peter commented 2 years ago

Since with either implicit or explicit are being deprecated, shouldn't this recommend not using with at all?

JeremyVyska commented 2 years ago

Are there pages recommending use of with?

I found this archive one: https://alguidelines.dev/docs/navpatterns/3-cal-coding-guidelines/readability/nested-withs/

christianbraeunlich commented 1 year ago

There are some rules that would throw an error in the future:

Use of implicit 'with' will be removed in the future. Qualify with '{0}': https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/diagnostics/diagnostic-al604

The 'with' statement is deprecated and will be removed for cloud development in a future release: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/diagnostics/diagnostic-al606

So, yes - would be recommended to not use them any longer and to convert, see: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-deprecating-with-statements-overview

With Business Central 2022 release wave 2, the AL:Go! template for creating new AL projects in Visual Studio Code, now enables explicit with statements by default, by adding the NoImplicitWith option to the features property in the generated app.json file.