That makes a lot of sense to just have the script inside the transformation as opposed to loading it in the system for use.
I apologize for being unfamiliar with the nuances of the script itself, but I have encountered this error
error CS1529: A using clause must precede all other elements defined in the namespace except extern alias declarations[TempITemplate.Template]:
when I pasted the script provided and then called the function in the transformation.
Category: <%# GetDocumentCategories(Eval<int>("DocumentID"), null) %>
The only thing preceding the script is:
<%@ Control Language="C#" AutoEventWireup="true" Inherits="CBA.WebControls.BaseCMSTransformation" %>
<%@ Import Namespace="CBA" %>