Skip to content

Commit

Permalink
#305 - support extension objects with individual names
Browse files Browse the repository at this point in the history
  • Loading branch information
waldo1001 committed Jul 5, 2024
1 parent b550ca0 commit c000be1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log
All notable changes to the "crs-al-language-extension" extension:
## [1.5.32] - 2024-07-15
Made it possible to have multiple extension objects names (thanks for [reporting](https://github.com/waldo1001/crs-al-language-extension/issues/305), [Natalie](https://github.com/NKarolak)).
The way it works: It's regarding setting `ExtensionObjectNamePattern`.
If you, as deverlop, would add extra characters after this pattern, the extension will accept them. For example, if you would have a setting `<BaseNameShort> Ext`, and you would have an extension object named `MyTable Ext 2`, the extension will accept this as a valid object name and not change it bak to `MyTable Ext`.

## [1.5.31] - 2023-11-27
Fixed snippets (removed ";" after procedure).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ This extension contributes the following settings:
* `CRS.WinServerInstance`: Serverinstance where the windows client is connecting to
* `CRS.WinServerInstancePort`: Portnumber of the serverinstance where the windows client is connecting to
* `CRS.PublicWebBaseUrl`: Override Launch.json settings with this setting if necessary to run objects from VSCode
* `CRS.ExtensionObjectNamePattern`: The pattern for the object name. If set (it's not set by default), it will perform an automatic object name for extension objects
* `CRS.ExtensionObjectNamePattern`: The pattern for the object name. If set (it's not set by default), it will perform an automatic object name for extension objects. To support multiple extensions per app, the system will accept manually added characters at the end of the pattern as well. These vars can be used:
- `<Prefix>`
- `<Suffix>`
- `<ObjectType>`
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "crs-al-language-extension",
"displayName": "waldo's CRS AL Language Extension",
"description": "Make working with the (Dynamics NAV / 365) AL Language easier and more efficient.",
"version": "1.5.31",
"version": "1.5.32",
"publisher": "waldo",
"icon": "images/waldo.png",
"author": {
Expand Down Expand Up @@ -174,7 +174,7 @@
"CRS.ExtensionObjectNamePattern": {
"Type": "string",
"default": "",
"description": "The pattern of the objectname for extension objects (PageExtension or TableExtension). These vars can be used: <Prefix>,<Suffix>,<ObjectType>,<ObjectTypeShort>,<ObjectTypeShortPascalCase>,<ObjectTypeShortUpper>,<ObjectId>,<BaseName>,<BaseNameShort>,<BaseId>",
"description": "The pattern of the objectname for extension objects. These vars can be used: <Prefix>,<Suffix>,<ObjectType>,<ObjectTypeShort>,<ObjectTypeShortPascalCase>,<ObjectTypeShortUpper>,<ObjectId>,<BaseName>,<BaseNameShort>,<BaseId>. Remark: the system will accept manually added characters following this pattern.",
"scope": "resource"
},
"CRS.FileNamePattern": {
Expand Down
4 changes: 4 additions & 0 deletions src/NAVObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export class NAVObject {
if (objectNameFixed == this.objectName.trim().toString()) {
objectNameFixed = this.AddPrefixAndSuffixToObjectNameFixed(objectNameFixed);
}
//Accept original value when characters added to the end of the objectname
if (this.objectName.startsWith(objectNameFixed)) {
objectNameFixed = this.objectName;
}

return objectNameFixed;
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/suite/NAVObject.FilePattern.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,18 @@ suite("NAVObject FilePattern Tests", () => {
+ navObject.extendedObjectId)
})

test("TableExtension - Dont Change Name is not necessary", () => {
let testSettings = Settings.GetConfigSettings(null)
testSettings[Settings.ExtensionObjectNamePattern] = '<BaseNameShort> Ext';

let navTestObject = NAVTestObjectLibrary.getTableExtensionWithDecentNameAlready()
let navObject = new NAVObject(navTestObject.ObjectText, testSettings, navTestObject.ObjectFileName)

assert.strictEqual(
navObject.objectNameFixed,
navObject.objectName)
})


test("FileName - Extension Object with which would be too", () => {
let testSettings = Settings.GetConfigSettings(null)
Expand Down
15 changes: 15 additions & 0 deletions src/test/suite/NAVTestObjectLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,21 @@ export function getTableExtensionWrongFileNameAndKeyWord(): NAVTestObject {
}
}
}
`
return object;
}
export function getTableExtensionWithDecentNameAlready(): NAVTestObject {
let object = new NAVTestObject;

object.ObjectFileName = 'SomeTableExt.al'
object.ObjectText = `tableextension 50100 "Customer Ext 2" extends Customer //18
{
fields
{
}
}
`
return object;
Expand Down

0 comments on commit c000be1

Please sign in to comment.