.net - T4 templates: any way to make ToStringWithCulture() convert null to string.Empty instead of throwing exception? -


when provide object t4 template nullable properties, unless explicitly write <#= obj.property ?? string.empty #> tostringwithculture(object objecttoconvert) method generated template throws argumentnullexception if property null. there neat or elegant way override behavior don't have pepper null coalescing on templates?

mnaoumov's solution. change base template class

public string tostringwithculture(object objecttoconvert) {     if (objecttoconvert == null)         return "";     ... } 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -