Hi! Thanks for reporting this bug!
Please fill in the relevant information from this template so that we can help you best.
Smart.Format version:
3.5.1
Framework version: (e.g. net5.0)
net9.0
- Please provide a working source code example to reproduce the bug
using SmartFormat;
using SmartFormat.Extensions;
var formatter = Smart.CreateDefaultSmartFormat(); // https://github.com/axuno/SmartFormat/wiki/Templates-_-TemplateFormatter
var templates = new TemplateFormatter();
formatter.AddExtensions(templates);
templates.Register("SomeTemplate", "The template content");
formatter.Format("{0:t(SomeTemplate)}:"); // This line throws.
- What is the current result?
SmartFormat.Core.Formatting.FormattingException: 'Error parsing format string: No source extension could handle the selector named "0" at 1
{0:t(SomeTemplate)}:
-^'
- What is the expected result?
no exception
- Please post full exception details if applicable (message, stacktrace, inner exceptions)
- Did you find a workaround? yes/no
yes, pass redundant new object() argument
- Is there a version in which it worked?
- Can you help us by writing an unit test?
Our actual use case is for sms templates and looks more like this:
var filePaths = Directory.GetFiles(path);
foreach (string filePath in filePaths)
{
string fileName = Path.GetFileNameWithoutExtension(filePath);
string fileText = await File.ReadAllTextAsync(filePath);
templates.Register(fileName, fileText);
}
and I found some smses don't need a model.
Hi! Thanks for reporting this bug!
Please fill in the relevant information from this template so that we can help you best.
Smart.Format version:
3.5.1
Framework version: (e.g. net5.0)
net9.0
no exception
yes, pass redundant
new object()argumentOur actual use case is for sms templates and looks more like this:
and I found some smses don't need a model.