Possible to change naming and default value forms? #4500
-
Hi, is it possible to change what transformation is used when replacing Edit: After posting this, I realize that I could probably use a derived symbol from |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
@JohanPetersson which In case you need safe namespace form to be applied in template content, use |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I fully understand those tables :( My "symbols": {
"safeFilename": {
"type": "derived",
"valueSource": "name",
"valueTransform": "replaceHyphensWithUnderscore",
"fileRename": "Test.Test",
"description": "Renames files with underscores instead of hyphens so it matches the names in e.g. appSettings.json"
},
},
"forms": {
"replaceHyphensWithUnderscore": {
"identifier": "replace",
"pattern": "(-)+",
"replacement": "_"
}
} Unfortunately, this touches all files with the matching |
Beta Was this translation helpful? Give feedback.
-
I have a file called e.g. Test.Test.mdf and a connection string in appSettings.json: "ConnectionStrings": {
"db": "Data Source=(LocalDb)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\Test.Test.mdf;Initial Catalog=Test.Test;Integrated Security=True;Connect Timeout=30"
} Given the "ConnectionStrings": {
"db": "Data Source=(LocalDb)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\new_name.mdf;Initial Catalog=new_name;Integrated Security=True;Connect Timeout=30"
} With my fix above the mdf file gets named new_name.mdf so the connection string is correct. Do you mean I could name my file Test._Test.mdf instead and use the same format (Test._Test) in the connection string and then it replaces with the same format? |
Beta Was this translation helpful? Give feedback.
-
This did not work. So, I don't know how to interpret the tables here https://github.com/dotnet/templating/wiki/Naming-and-default-value-forms, other than that they describe which transformation will happen, but you cannot decide which one to use. My file ended up with the name Test._Test.mdf and not new_name.mdf. Same thing in the json file. Am I missing something? |
Beta Was this translation helpful? Give feedback.
@JohanPetersson which
sourceName
do you use in your template configuration?By using unambiguous source name (as
Template.1
from https://github.com/dotnet/templating/wiki/Naming-and-default-value-forms) you can control applied value forms.In case you need safe namespace form to be applied in template content, use
Template._1
in the content.In case you need name as stated by user (identity form) in template content, use
Template.1
in the content.