token plugin throwing errors under 10.x

I created a plugin to add a token to a rule. It broke under 10 and I don't understand why.

The basic structure of the token is this: there is an ITokenizedTemplatePrimitiveToken class that declares the token, and a ITokenRegistrar class that contains the RegisterTokens method, that accepts the ITokenizedTemplateTokenController and calls the Register method on it, with a new instance of the aforementioned class as its argument.

The error I am seeing is the iTokenRegistrar class is throwing an error when I try to enable the token, Object reference not set to an instance of an object. at (class name here)..ctor()

The resulting stack trace made little sense, except that something very strange is happening.

I tried to make it "future proof" and not use deprecated APIs, eg I think Evolution.Extensibility.Apis.Get<IUsers>().ContentTypeId is the correct way to get the ContentTypeId. Also as a constructor-less class I'm befuddled.

Any pointers on how this could have broken from 9->10? My original question on this is at https://community.telligent.com/community/10/f/ask-the-community/1146486/tokens-and-extending-rule-support

Thanks,

Parents
  • If the issue is in the constructor (.ctor()), are you initializing any variables within your plugin class that require the Community API? The Community API should only be accessed in IPlugin.Initialize() or later--accessing the API earlier could result in null APIs being returned since the Community is not initialized.

Reply
  • If the issue is in the constructor (.ctor()), are you initializing any variables within your plugin class that require the Community API? The Community API should only be accessed in IPlugin.Initialize() or later--accessing the API earlier could result in null APIs being returned since the Community is not initialized.

Children
  • i rearranged the code a little and got it into a state where it activates and is in the UI now. However when it fires, I get an error like:

    InternalException: No token was found to match '${token:84f9a0bb-645b-4cd6-b992-83f223668407:sub-template=}'
       at Telligent.Evolution.Components.TokenizedTemplates.TokenParser.EvaluateToken(Match match, TemplateContext context)

    (that is my token GUID.)

    Presumably, my token isn't working? Ie what I'm passing to tokenController.Register() is not valid, somehow?

    Also interesting in the backtrace is this:

    at Telligent.Evolution.Api.Rules.RuleExecutionJob.Execute(JobData jobData)
       at Telligent.Evolution.Components.Jobs.DynamicEvolutionJobRunner.SubExecute(JobExecutionContext context)
       at Telligent.Evolution.Components.Jobs.BaseJobRunner.Execute(JobExecutionContext job)
       at ...()
       at System.Threading.Tasks.Task.InnerInvoke()
       at System.Threading.Tasks.Task.Execute()
       at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)

    That ... isn't rendering in the comment box. It looks like this in Chrome:

  • Presumably, my token isn't working? Ie what I'm passing to tokenController.Register() is not valid, somehow?

    This may be a side-effect of some of the code reorganization. Are you still registering the token when you're given the tokenController? It should be done there.

    at ...()

    This is because private classes/members are obfuscated. Makes for some interesting stack traces sometimes.