c# - Error In Visual Studio 2012 architecture Code Generate With T4 -
i use vs2012 design uml diagram , use t4 generate custom class , interface.
and use tfs source controler.
but since yesterday i'm getting error , codes not generated.
5/13/2013 8:18:59 am: code generation or text transformation started. 5/13/2013 8:19:51 am: errors encountered in 'classtemplate.t4' while generating code 'andish.css.modeling.umldiagram::model::andish.css.domain::businessdomain::calculator::grou pprecalculatingresult' - (class). 5/13/2013 8:19:58 am: code generation complete. errors: 1. warnings: 0. 5/13/2013 8:19:58 am: unable write log file: f:\andish\andishmandframwork\modeling\andish.css.modeling.umldiagram\codegeneration.log.xml - access path 'f:\andish\andishmandframwork\modeling\andish.css.modeling.umldiagram\codegeneration.log.xm l' denied.
this pic vs2012
and 1 error down :
error 44 errors generated when initializing transformation object. transformation not run. following exception thrown: system.nullreferenceexception: object reference not set instance of object. @ microsoft.visualstudio.texttemplating5dc31bf3c568533e6a5135685cf1d48cee628c2d066e9f2e28996b 26fb846e02d5a1b9165e6b13eeeea7bba99e06465e913189341f3d59ce816f2ceb52faeba8.generatedtexttra nsformation.appliestoelement() @ microsoft.visualstudio.architecturetools.texttransformation.modelingtexttransformation.init ialize() @ callsite.target(closure , callsite , object ) @ system.dynamic.updatedelegates.updateandexecutevoid1[t0](callsite site, t0 arg0) @ microsoft.visualstudio.texttemplating.transformationrunner.performtransformation()
and use t4 class down
<#@ include file="templateheader.t4" #> <#@ modeling elementtype="microsoft.visualstudio.uml.classes.iclass" processor="modelingprocessor" applystereotypes="csharp" #> <#@ import namespace="microsoft.visualstudio.uml.auxiliaryconstructs" #> <#@ import namespace="microsoft.visualstudio.uml.classes" #> <#@ import namespace="microsoft.visualstudio.architecturetools.extensibility.uml" #> <#@ include file="csharpcommenthelpers.t4" #> <#@ include file="csharphelpers.t4" #> <#@ output extension=".cs" #> <# writeautogeneratedwarningheader(); writeline("using system.runtime.serialization;"); writeline("using system.servicemodel;"); string classnamespace = getnamespace(this.element.namespace); if(!string.isnullorempty(classnamespace)) { #> namespace <#= classnamespace #> { <# pushindent("\t"); } writeusingstatements(this.element); writeline(""); system.globalization.persiancalendar pdate=new system.globalization.persiancalendar(); datetime befordate=new datetime(pdate.getyear(system.datetime.now),pdate.getmonth(system.datetime.now),pdate.getdayofmonth(system.datetime.now),pdate.gethour(system.datetime.now),pdate.getminute(system.datetime.now),pdate.getsecond(system.datetime.now)); string date=string.format("{0:yyyy/mm/dd hh:mm:ss}",befordate); writesinglelinedoccomment("author","name = \"t4generator\"",""); writesinglelinedoccomment("createdate","date = \"" + date+"\"",""); writesinglelinedoccomment("lastmodifyuser","name = \"t4generator\"",""); writesinglelinedoccomment("lastmodifydate","date = \"" + date+"\"",""); writesinglelinedoccomment("version","number = \"1\"",""); writesinglelinedoccomment("release","number = \"1\"",""); writesummarycomment(this.element.description); writetemplatetypeparametercomments(templateparameternamedescriptionpairs(this.element)); //writeline("[serviceerrorbehaviour(typeof(httperrorhandler))]"); foreach(var comment in this.element.getmodelstore().allinstances<icomment>().where(c => c.annotatedelements.contains(this.element))) { writeremarkscomment(comment.body); } #> <# writeclassclrattributes(this.element); #> <#= classvisibility(this.element) #><#= classunsafeoption(this.element) #><#= classstaticoption(this.element) #><#= classabstractoption(this.element) #><#= classsealedoption(this.element) #><#= classpartialoption(this.element) #>class <#= classifiername(this.element) #><#= implementedandinheritedlist(this.element) #><# writeclassifierconstraintoption(this.element); #> { <# pushindent("\t"); // write attributes var ownedattributes = this.element.ownedattributes; foreach(iproperty attribute in ownedattributes) { writesummarycomment(attribute.description); writeclassumlpropertydefinition(attribute); writeline(""); } #> <# // write associations var navigableownedends = getnavigableownedends(this.element, ownedattributes); foreach(iproperty ownedend in navigableownedends) { writesummarycomment(ownedend.owningassociation.description); writesummarycomment(ownedend.description); writeclassumlpropertydefinition(ownedend); writeline(""); } #> <# // write operations foreach(ioperation operation in this.element.ownedoperations) { writesinglelinedoccomment("author","name = \"t4generator\"",""); writesinglelinedoccomment("createdate","date = \"" + date+"\"",""); writesinglelinedoccomment("lastmodifyuser","name = \"t4generator\"",""); writesinglelinedoccomment("lastmodifydate","date = \"" + date+"\"",""); writesinglelinedoccomment("version","number = \"1\"",""); writesinglelinedoccomment("release ","number = \"1\"",""); writesummarycomment(operation.description + getcommentofglobalmethod(operation.name)); foreach (iparameter parameter in operation.ownedparameters.where(p => p.direction != parameterdirectionkind.return)) { writeparametercomment(parameter.name, parameter.description); } writesinglelinedoccomment("returns","",""); if(getstereotype(operation) == "method") { writemethodclrattributes(operation); if(isconstructor(operation) || isdestructor(operation)) { #> <#= methodvisibility(operation) #><#= operation.name #>(<# writemethodparameterlist(operation); #>) { } <# } else { #> <#= methodvisibility(operation) #><#= methodunsafeoption(operation) #><#= operationstaticoption(operation) #><#= classmethodoverloadoption(operation, this.element) #><#= methodpartialoption(operation) #><#= methodtype(operation) #> <#= operation.name #>(<# writemethodparameterlist(operation); #>)<# writeclassmethodbody(operation); #> <# } writeline(""); } else if(getstereotype(operation) == "indexer") { writeindexerclrattributes(operation); #> <#= indexervisibility(operation) #><#= indexerunsafeoption(operation) #><#= operationstaticoption(operation) #><#= classindexeroverloadoption(operation, this.element) #><#= indexertype(operation) #> this[<# writeindexerparameterlist(operation); #>] { <# pushindent("\t"); #> <#= indexergetvisibility(operation) #>get<# writeclassindexeraccessorbody(operation); #> <#= indexersetvisibility(operation) #>set<# writeclassindexeraccessorbody(operation); #> <# popindent(); #> } <# writeline(""); } } popindent(); #> } <# clearindent(); if(!string.isnullorempty(classnamespace)) { #> } <# } #> <#+ #region inheritance /// <summary> /// gets implemented , inherited types of given class. /// </summary> /// <param name="aclass">the given class</param> /// <returns>implementedandinherted types</returns> private static string implementedandinheritedlist(iclass aclass) { var list = implementedandinheritedtypes(aclass); if(list.any()) { return " : " + string.join(", ", list.select(t => elementtype(t))); } else { return string.empty; } } #endregion inheritance #region polymorphism /// <summary> /// gets overload option of indexer. /// </summary> /// <param name="operation">the operation</param> /// <param name="owner">the class</param> /// <returns>the overload option operation</returns> private static string classindexeroverloadoption(ioperation operation, iclass owner) { return classoperationoverloadoption(operation, owner); } /// <summary> /// gets overload option of method. /// </summary> /// <param name="operation">the operation</param> /// <param name="owner">the class</param> /// <returns>the overload option operation</returns> private static string classmethodoverloadoption(ioperation operation, iclass owner) { if(string.isnullorempty(methodpartialoption(operation))) { return classoperationoverloadoption(operation, owner); } else { return string.empty; } } /// <summary> /// gets overload option of operation. /// </summary> /// <param name="operation">the operation</param> /// <param name="owner">the class</param> /// <returns>the overload option operation</returns> private static string classoperationoverloadoption(ioperation operation, iclass owner) { string overload = string.empty; if(!string.isnullorempty(operationabstractoption(operation))) { overload += "abstract "; } else if(isinheritedmember(operation, owner)) { overload += "override "; if(!string.isnullorempty(operationsealedoption(operation))) { overload += "sealed "; } } //دلیل کامنت شدن حذف کلمه virctual از تعریف متد // else if(isoverridable(operation, owner)) // { // overload += "virtual "; // } return overload; } /// <summary> /// gets overload option of property. /// </summary> /// <param name="property">the property</param> /// <param name="owner">the class</param> /// <returns>the overload option property</returns> private static string classpropertyoverloadoption(iproperty property, iclass owner) { string overload = string.empty; if(isinheritedmember(property, owner)) { overload = "override "; if(!string.isnullorempty(propertysealedoption(property))) { overload += "sealed "; } } else if(isoverridable(property, owner)) { overload += "virtual "; } return overload; } /// <summary> /// checks if operation overridable. /// </summary> /// <param name="operation">the operation</param> /// <param name="owner">the class</param> /// <returns>true if operation inherited member.</returns> private static bool isoverridable(ioperation operation, iclass owner) { bool isprivate = methodvisibility(operation) == "private " || indexervisibility(operation) == "private "; return !isprivate && string.isnullorempty(operationstaticoption(operation)) && string.isnullorempty(operationsealedoption(operation)) && hasvirtualmembers(owner); } /// <summary> /// checks if property overridable. /// </summary> /// <param name="property">the property</param> /// <param name="owner">the class</param> /// <returns>true if property inherited member.</returns> private static bool isoverridable(iproperty property, iclass owner) { bool isprivate = fieldvisibility(property) == "private " || propertyvisibility(property) == "private "; return !isprivate && string.isnullorempty(attributestaticoption(property)) && string.isnullorempty(propertysealedoption(property)) && hasvirtualmembers(owner); } /// <summary> /// checks if classifier have virtual memebers. /// </summary> /// <param name="aclass">the class</param> /// <returns>true if property inherited member.</returns> private static bool hasvirtualmembers(iclass aclass) { return string.isnullorempty(classsealedoption(aclass)) && string.isnullorempty(classstaticoption(aclass)); } /// <summary> /// checks if property inherited member. /// </summary> /// <param name="property">the property</param> /// <param name="owner">the owner class of property</param> /// <returns>true if property inherited member.</returns> private static bool isinheritedmember(iproperty property, iclass owner) { var types = implementedorinheritedtypes(owner); foreach(itype type in types) { iclassifier baseclassifier = type iclassifier; if(baseclassifier != null) { itemplatebinding templatebinding = gettemplatebinding(baseclassifier); iclassifier bindingclassifier = getbindingclassifier(templatebinding); if(bindingclassifier != null) { baseclassifier = bindingclassifier; } foreach(iproperty propertyinbase in getownedproperties(baseclassifier)) { bool isinheritedmember = isinheritedmember(propertyinbase, property, templatebinding); if(isinheritedmember) { return true; } } } } return false; } /// <summary> /// checks if property inherited member. /// </summary> /// <param name="propertyinbase">the property in base</param> /// <param name="propertyinsubclass">the property in subclass</param> /// <param name="templatebinding">the template binding</param> /// <returns>true if property in subclass inherited member; false if not or base interface</returns> private static bool isinheritedmember(iproperty propertyinbase, iproperty propertyinsubclass, itemplatebinding templatebinding) { var propertyinbaseowner = propertyinbase.owner; if(propertyinbaseowner iassociation) { propertyinbaseowner = ((iassociation)propertyinbaseowner).sourceelement; } if(propertyinbaseowner iinterface) { return false; } else if(propertyinbaseowner iclass) { bool isinheritedproperty = isinheritedproperty(propertyinsubclass, propertyinbase, templatebinding); bool isoverridable = isoverridable(propertyinbase, (iclass)propertyinbaseowner); return isinheritedproperty && isoverridable; } return false; } /// <summary> /// checks if operation inherited member. /// </summary> /// <param name="operation">the operation</param> /// <param name="owner">the owning class of operation</param> /// <returns>true if operation inherited member.</returns> private static bool isinheritedmember(ioperation operation, iclass owner) { var types = implementedorinheritedtypes(owner); foreach(itype type in types) { iclassifier baseclassifier = type iclassifier; if(baseclassifier != null) { itemplatebinding templatebinding = gettemplatebinding(baseclassifier); iclassifier bindingclassifier = getbindingclassifier(templatebinding); if(bindingclassifier != null) { baseclassifier = bindingclassifier; } foreach(ioperation operationinbase in getownedoperations(baseclassifier)) { bool isinheritedmember = isinheritedmember(operationinbase, operation, templatebinding); if(isinheritedmember) { return true; } } } } return false; } /// <summary> /// checks if operation inherited member. /// </summary> /// <param name="operationinbase">the operation in base</param> /// <param name="operationinsubclass">the operation in subclass</param> /// <param name="templatebinding">the template binding</param> /// <returns>true if operation in subclass inherited member; false if not or base interface</returns> private static bool isinheritedmember(ioperation operationinbase, ioperation operationinsubclass, itemplatebinding templatebinding) { var operationinbaseowner = operationinbase.owner; if(operationinbaseowner iassociation) { operationinbaseowner = ((iassociation)operationinbaseowner).sourceelement; } if(operationinbaseowner iinterface) { return false; } else if(operationinbaseowner iclass) { bool isinheritedoperation = isinheritedoperation(operationinsubclass, operationinbase, templatebinding); bool isoverridable = isoverridable(operationinbase, (iclass)operationinbaseowner); return isinheritedoperation && isoverridable; } return false; } /// <summary> /// checks if operation in subclass inherited operation in base. /// </summary> /// <param name="operationinsubclass">the operation in subclass</param> /// <param name="operationinbase">the operation in base</param> /// <param name="templatebinding">the template binding</param> /// <returns>if operation in subclass inherited operation in base.</returns> private static bool isinheritedoperation(ioperation operationinsubclass, ioperation operationinbase, itemplatebinding templatebinding) { if(templatebinding == null) { return operationinsubclass.signature == operationinbase.signature; } if(operationinsubclass.name != operationinbase.name) { return false; } var subclassoperationownedparametersinorder = getownedparametersinorder(operationinsubclass); var baseclassoperationownedparametersinorder = getownedparametersinorder(operationinbase); int numofsubclassoperationownedparameters = subclassoperationownedparametersinorder.count(); if(numofsubclassoperationownedparameters != baseclassoperationownedparametersinorder.count()) { return false; } var parametersubstitutions = templatebinding.parametersubstitutions; // find newly defined template parameters var baseclassifier = (iclassifier)operationinbase.owner; var subclassifier = (iclassifier)operationinsubclass.owner; var subclassnewlydefinedtemplateparameternames = getnewlydefinedtemplateparameternamesinsubclass(baseclassifier, subclassifier, parametersubstitutions); for(int i=0; < numofsubclassoperationownedparameters; i++) { var subclassoperationownedparameter = subclassoperationownedparametersinorder.elementat(i); var baseclassoperationownedparameter = baseclassoperationownedparametersinorder.elementat(i); if(subclassoperationownedparameter.direction != baseclassoperationownedparameter.direction) { return false; } bool isparameterinbaseenumerable = isenumerable(baseclassoperationownedparameter); bool isparameterinsubclassenumerable = isenumerable(subclassoperationownedparameter); if(isparameterinbaseenumerable != isparameterinsubclassenumerable) { return false; } if(!onetypeoverridestheother(baseclassoperationownedparameter.type, subclassoperationownedparameter.type, parametersubstitutions, subclassnewlydefinedtemplateparameternames)) { return false; } } return true; } /// <summary> /// gets owned parameters in order: first parameter of return type, , rest of parameters. /// </summary> /// <param name="operation">the operation</param> /// <returns>list of owned parameters in order</returns> private static list<iparameter> getownedparametersinorder(ioperation operation) { var orderedset = enumerable.union<iparameter>(operation.ownedparameters.where(parameter => parameter.direction == parameterdirectionkind.return), operation.ownedparameters.where(parameter => parameter.direction != parameterdirectionkind.return)); return orderedset.tolist(); } /// <summary> /// checks if 2 type names equal considering of template binding substitutions. /// </summary> /// <param name="propertyinsubclass">the property in subclass</param> /// <param name="propertyinbase">the property in base</param> /// <param name="templatebinding">the template binding</param> /// <returns>if property in subclass inherited property in base.</returns> .........
i can not copy code of t4 template because max length in post 30000 carachter.
the error message says access 'f:\andish\andishmandframwork\modeling\andish.css.modeling.umldiagram\codegeneration.log.xm l' denied.
maybe file locked tfs. try checking out file before generating.
Comments
Post a Comment