waldo1001 / crs-al-language-extension

Make working with the (Dynamics NAV / 365) AL Language easier and more efficient.
MIT License
34 stars 43 forks source link

Prefix missing for Names containing % or brackets ( ) #210

Closed pri-kise closed 2 years ago

pri-kise commented 2 years ago

Recently I've seen a strange behaviour. A prefix isn't added on field that contain a %, e.g. Discount % Base. If I checked the source code correct then this regex is causing this problem. return /.(field( "?([ a-zA-Z0-9./&-]+)"? ; ([" a-zA-Z0-9./&-]+) *))/g;

https://github.com/waldo1001/crs-al-language-extension/blob/4935d4cb5645152c4b6a2655de2f061a0241177a/src/NAVObject.ts#L532

christianbraeunlich commented 2 years ago

I can reproduce this on the Table object in the field name, as you described. For example: the prefix/suffix is not added to field(86000; "My % (Otter)"; Blob).

Personally speaking I'm not a big fan of writing special characters into the name of a field (nor object name). Otherwise my field names would look like this: field(86000; "🦦 Quantity (CHB)"; Integer) :D.

However, a quick look into the Base App discovers that they use the following characters . ( ) % / - and for example in report objects _ on columns aswell.

Thank you for reporting this issue and pointing out the specific line in the code @pri-kise!

waldo1001 commented 2 years ago

Thanks so much, @christianbraeunlich - I published the fix in Version 1.5.8!

christianbraeunlich commented 2 years ago

Case closed?

pri-kise commented 2 years ago

@christianbraeunlich looks okay. We could discuss if there are any other characters the BaseApp might use and therefore others are using them too, but in our apps the mentioned special characters are sufficient.

kaspermoerch commented 2 years ago

This fix is causing me major headaches.

In an existing solution with 600+ objects fields where the suffix has not been added (but should have been at creation) are suddenly renamed. I do want to fix the naming of the fields at some point (probably when we upgrade to a newer version) but at the moment it is a huge inconvenience.

Is there any way to disable the rename for a single field?

waldo1001 commented 2 years ago

Would this be of any help? image

Probably not.

Can I ask a bit more info on why this is such an inconvenience?

kaspermoerch commented 2 years ago

Skip String Manipulation works like a charm. Thanks :-)

It is an inconvenience because we often have multiple developers working on the same project and if they all make modifications to the same table extension, they will all get the same (valid) rename of existing fields (not related to the change they are implementing) causing them to have to make changes to a load of other objects where the renamed fields are used. All of this additional work was not included in the estimated costs provided to the customer (which means time has not been allocated for it).

waldo1001 commented 2 years ago

I get it .. . So - can I conclude that the "skip string manipulation" is a solution? :-)

kaspermoerch commented 2 years ago

Yes. It works :)