Closed gregveres closed 1 year ago
There was a breaking change, IAttributeArgument.Value
is now of ITypedConstant
or ITypedConstant[]
.
So, smth like that should work:
public static string ExtractTypescriptType(IAttribute attr)
{
if (attr.Name == "TypescriptType")
{
var attrType = attr.Arguments.FirstOrDefault()?.Value as ITypedConstant;
if (attrType != null) return attrType.Value as string;
}
return string.Empty;
}
Yes, thanks. I just figured that out and changed my code to something very similar to this. I was about to post something similar.
I seem to remember there was a way to do an equivalent of a console.log() in the scriban script, but I can't find any reference to it and I didn't leave myself a note in my code. Is there such a thing or am I dreaming? Haivng fixed this issue, I am still running into a null reference in another script. I think another user created an issue for that one.
Version 0.4.4.1 with fixed null reference problem is published, hopefully, there is not another one.
closing since this is due toa breaking change that can be handled in my code.
I accidentally upgraded to the lastest version of NTypewriter and my scripts started failing. I have narrowed it down to this custom function:
The failure happens with the statement
return attrType as string;
. In previous versions this used to properly take the attrType and convert it to a string and return it. In the lastest version this always returns null.In the debugger, I can see that attrType is of type: For more context, the IAttribute is
object {NTypewriter.CodeModel.Roslyn.TypedConstant}
with a value of "string|null" and a type of{string}
I am defining the attribute in my project like this:
In the Summary text you can see how it is used.
It looks like I used to be on version 0.4.1 and I have upgraded to 0.4.4.