Support for `T4ParameterValues`
- Dominant language
- C#
- Stars
- 58
- Forks
- 13
- Avg merge
- 5h 4m
- Merged PRs (30d)
- 7
Description
Would it be possible to get external parameter values using `T4ParameterValues` items and `<#@ parameter #>` directives? I'm looking to get a value from a MSBuild property.
Maybe I'm wrong, but as far as I can tell, properties are generated for declared parameters, but they're always null.
If I want to declare a `RefAsmPath` parameter, the generated `Initialize` method looks like this (decompiled):
```csharp
public virtual void Initialize()
{
if (((TextTransformation)this).Errors.HasErrors)
return;
bool RefAsmPathValueAcquired = false;
if (((TextTransformation)this).Session.ContainsKey("RefAsmPath"))
{
_RefAsmPathField = (string)((TextTransformation)this).Session["RefAsmPath"];
RefAsmPathValueAcquired = true;
}
if (!RefAsmPathValueAcquired)
{
string parameterValue = Host.ResolveParameterValue("Property", "PropertyDirectiveProcessor", "RefAsmPath");
if (!string.IsNullOrEmpty(parameterValue))
{
TypeConverter tc = TypeDescriptor.GetConverter(typeof(string));
if (tc != null && tc.CanConvertFrom(typeof(string)))
{
_RefAsmPathField = (string)tc.ConvertFrom(parameterValue);
RefAsmPathValueAcquired = true;
}
else
((TextTransformation)this).Error("The type 'System.String' of the parameter 'RefAsmPath' did not match the type of the data passed to the template.");
}
}
if (!RefAsmPathValueAcquired)
{
object data = CallContext.LogicalGetData("RefAsmPath");
if (data != null)
_RefAsmPathField = (string)data;
}
}
```
Except...
- `Initialize` is never called
- `Session` is null, so `Initialize` would throw anyway
- `Host.ResolveParameterValue` always returns `string.Empty`
- `CallContext.LogicalGetData("RefAsmPath")` returns null...
So I guess there's a lot to do in order to add support 😬
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.