- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Debugging
CodeModeler considers that during a project's lifetime, developers will have to debug the generated application. Therefore, the out-of-the-box producers add two technical items to each generated class:
- 
All generated classes are marked with the DebuggerDisplayAttribute, 
- 
All generated classes contain a Trace method. 
All Business Object Model (BOM) generated classes are marked with this attribute, however its content differs from a class to another:
Entity classes are marked with a string holding the EntityKey, then the CollectionKey of the current class:
// Attribute placed on the entity class
[System.Diagnostics.DebuggerDisplayAttribute("EK={EntityKey}, Name={Name}")]Collection classes are marked with a string holding the item count of the current collection:
// Attribute placed on the collection class
[System.Diagnostics.DebuggerDisplayAttribute("Count={Count}")]This way when debugging the BOM in Visual Studio, placing your cursor on a CodeModeler-generated class instance will display this information in a contextual menu.
Another default feature which makes it easier for developers to debug their application with CodeModeler-generated classes, is the fact that every one of those generated classes have a Trace method generated. This method is public, doesn't take any parameters, and will return a string giving a full representation of the current instance. For instance, for this model:

The Customer entity class will hold tracing methods such as:
public string Trace()
{
    System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
    System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder, System.Globalization.CultureInfo.CurrentCulture);
    System.CodeDom.Compiler.IndentedTextWriter writer = new System.CodeDom.Compiler.IndentedTextWriter(stringWriter);
    this.BaseTrace(writer);
    writer.Flush();
    ((System.IDisposable)(writer)).Dispose();
    ((System.IDisposable)(stringWriter)).Dispose();
    string sr = stringBuilder.ToString();
    return sr;
}
 
protected virtual void BaseTrace(System.CodeDom.Compiler.IndentedTextWriter writer)
{
    writer.Write("[");
    writer.Write("Id=");
    writer.Write(this.Id);
    writer.Write(",");
    writer.Write("Name=");
    writer.Write(this.Name);
    writer.Write(",");
    writer.Write("Address=");
    writer.Write(this.Address);
    writer.Write(",");
    writer.Write("Products=");
    if ((this._products != null))
    {
        ((CodeModeler.Runtime.ICodeModelerObject)(this._products)).Trace(writer);
    }
    else
    {
        writer.Write("<null>");
    }
    writer.Write(", EntityState=");
    writer.Write(this.EntityState);
    writer.Write("]");
}In collection classes, the BaseTrace method only prints the count of contained items.
- Introduction
- Architect Guide
- Concepts
- Using Visual Studio
- Overview
- Creating a CodeModeler Project
- Visual Environment
- Project Hierarchy
- Design Surface
- Customizing Design Surfaces
- Ribbon Bar
- Property Grid
- Member Format Expressions
- Model Grid
- Method Editor
- View Editor
- Instance Editor and Grid
- Resources Editor
- Inferred Model Viewer
- Building
- Project Physical Layout
- Source Control Support
 
- Generating
- Aspect Oriented Design (AOD)
 
- Developer Guide
- The Business Object Model (BOM)
- CodeModeler Query Language (CMQL)
- Starting Guide - Tutorial
 
- Upgrade From CFE