This is a migrated thread and some comments may be shown as answers.

Help with "Need context for this rendered construct in order to render it's text"

1 Answer 29 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jim
Top achievements
Rank 2
Jim asked on 21 Mar 2013, 07:12 PM
I have been trying to clear this error for a couple of days and have no idea what could be causing it.  It appears that it's having a problem rendering the CodeMarker for the exception that it has found. 

I can upload the entire method, if necessary.    This is causing justCode Problems and the exception window to open.  I don't think that I need to send this to Telerik as I think that it may be my code causing the problem.

Please help!

Jim Evans
Application Architect, company name withheld

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Exception:

System.Exception: Need context for this rendered construct in order to render it's text
   at Telerik.JustCode.CommonLanguageModel.FrontendBase.ConstructBase.GetText(ConstructRenderContext context) in c:\Jenkins\Production JustCode\workspace\src\CommonLanguageModel\FrontendBase\ConstructBase.cs:line 423
   at Telerik.JustCode.CommonLanguageModel.FrontendBase.TypeNameBase.GetText(ConstructRenderContext context) in c:\Jenkins\Production JustCode\workspace\src\CommonLanguageModel\FrontendBase\ConstructBase.cs:line 1821
   at Telerik.JustCode.CommonLanguageModel.FrontendBase.ConstructBase.get_Text() in c:\Jenkins\Production JustCode\workspace\src\CommonLanguageModel\FrontendBase\ConstructBase.cs:line 400
   at CLARIFIREJCExt.InlineSQL.<AddCodeMarkers>b__0(IMethodDeclaration method) in c:\inetpub\wwwroot\DEVTFS\eMASONSourceCode\Architecture\JustCode\JustCode Extensions\JustCodeExtension3\InlineSQL.cs:line 36
   at Telerik.JustCode.CommonLanguageModel.ConstructEnumerableExtensions.#p.#8Z.MoveNext() in c:\Jenkins\Production JustCode\workspace\src\CommonLanguageModel\IConstructEnumerable.cs:line 213
   at #2W.#wZ.MoveNext() in c:\Jenkins\Production JustCode\workspace\src\CommonLanguageModel\IConstructEnumerable.cs:line 31
   at CLARIFIREJCExt.InlineSQL.AddCodeMarkers(FileModel fileModel) in c:\inetpub\wwwroot\DEVTFS\eMASONSourceCode\Architecture\JustCode\JustCode Extensions\JustCodeExtension3\InlineSQL.cs:line 36
   at Telerik.JustCode.CommonLanguageModel.CodeMarkerProviderModuleBase.#Q0(FileModel fileModel) in c:\Jenkins\Production JustCode\workspace\src\CommonLanguageModel\CodeMarkerProviderModuleBase.cs:line 83
   at Telerik.JustCode.CommonLanguageModel.Engine.CLMEngine.#fW(FileEntry file) in c:\Jenkins\Production JustCode\workspace\src\CommonLanguageModel.Engine\CLMEngine.cs:line 1912

Offending code:
foreach (IMethodDeclaration md in fileModel.All<IMethodDeclaration>().Where(method => method.TypeName.Type.IsPrimitiveType == true ||<br>                                                                                                 
                                                                                method.TypeName.Text.Equals(
"Object") == true ||<br>                                                                                                 
                                                                                method.TypeName.Text.Equals(
"String") == true))


1 Answer, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 22 Mar 2013, 08:47 AM
Hello,

Thank you for your feedback. Such exception can occur if you have created a new method in the file model and then you are trying to get its text.
I would like to suggest to not use the "Text" property of a IConstruct if not absolutely necessary. It can be slow and potentially can cause problems like the one you have right now. In your case there are two ways to check whether a given type equals another.
  1. Use the "Is" method of IType:
var hasObjectType = method.TypeName.Type.Is("System.Object");
var hasStringType = method.TypeName.Type.Is("System.String");
string myFullyQualifiedType = "MyCompany.SomeNamespace.NeededType"
var hasNeededType = method.TypeName.Type.Is(myFullyQualifiedType);

     2.  Use the "Equals" method of IType

var hasObjectType = method.TypeName.Type.Equals(method.ObjectTypeAtThisLocation());

If you, however, want to use the "Text" property, you can send us your extension so we can identify your problem and help you with it.
If you have any questions or remarks, please do not hesitate to contact us again!

Greetings,
Ivan
the Telerik team
Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
Tags
Code Analysis
Asked by
Jim
Top achievements
Rank 2
Answers by
Ivan
Telerik team
Share this question
or