Click here to Skip to main content
15,896,338 members
Articles / Programming Languages / C#

Static Code Analysis

Rate me:
Please Sign up or sign in to vote.
4.97/5 (34 votes)
15 Mar 2010CPOL16 min read 87.2K   1.1K   63  
A static code analyzer building method call networks + sample applications
This article describes the operation of a method-based static code analyzer for .NET that constructs in-memory method call networks of compiled assemblies. You will also see a concrete application of static code analysis to generate a website providing easy insights on a sample application.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.4200
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("ToDoSample.Service.Entities", "FK_ToDos_Users", "Users", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(ToDoSample.Service.User), "ToDos", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(ToDoSample.Service.ToDoItem))]

// Original file name:
// Generation date: 14/01/2010 18:19:00
namespace ToDoSample.Service
{
    
    /// <summary>
    /// There are no comments for ToDoObjectContext in the schema.
    /// </summary>
    public partial class ToDoObjectContext : global::System.Data.Objects.ObjectContext
    {
        /// <summary>
        /// Initializes a new ToDoObjectContext object using the connection string found in the 'ToDoObjectContext' section of the application configuration file.
        /// </summary>
        public ToDoObjectContext() : 
                base("name=ToDoObjectContext", "ToDoObjectContext")
        {
            this.OnContextCreated();
        }
        /// <summary>
        /// Initialize a new ToDoObjectContext object.
        /// </summary>
        public ToDoObjectContext(string connectionString) : 
                base(connectionString, "ToDoObjectContext")
        {
            this.OnContextCreated();
        }
        /// <summary>
        /// Initialize a new ToDoObjectContext object.
        /// </summary>
        public ToDoObjectContext(global::System.Data.EntityClient.EntityConnection connection) : 
                base(connection, "ToDoObjectContext")
        {
            this.OnContextCreated();
        }
        partial void OnContextCreated();
        /// <summary>
        /// There are no comments for ToDoItemSet in the schema.
        /// </summary>
        public global::System.Data.Objects.ObjectQuery<ToDoItem> ToDoItemSet
        {
            get
            {
                if ((this._ToDoItemSet == null))
                {
                    this._ToDoItemSet = base.CreateQuery<ToDoItem>("[ToDoItemSet]");
                }
                return this._ToDoItemSet;
            }
        }
        private global::System.Data.Objects.ObjectQuery<ToDoItem> _ToDoItemSet;
        /// <summary>
        /// There are no comments for UserSet in the schema.
        /// </summary>
        public global::System.Data.Objects.ObjectQuery<User> UserSet
        {
            get
            {
                if ((this._UserSet == null))
                {
                    this._UserSet = base.CreateQuery<User>("[UserSet]");
                }
                return this._UserSet;
            }
        }
        private global::System.Data.Objects.ObjectQuery<User> _UserSet;
        /// <summary>
        /// There are no comments for ToDoItemSet in the schema.
        /// </summary>
        public void AddToToDoItemSet(ToDoItem toDoItem)
        {
            base.AddObject("ToDoItemSet", toDoItem);
        }
        /// <summary>
        /// There are no comments for UserSet in the schema.
        /// </summary>
        public void AddToUserSet(User user)
        {
            base.AddObject("UserSet", user);
        }
    }
    /// <summary>
    /// There are no comments for ToDoSample.Service.Entities.ToDoItem in the schema.
    /// </summary>
    /// <KeyProperties>
    /// Id
    /// </KeyProperties>
    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="ToDoSample.Service.Entities", Name="ToDoItem")]
    [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
    [global::System.Serializable()]
    public partial class ToDoItem : global::System.Data.Objects.DataClasses.EntityObject
    {
        /// <summary>
        /// Create a new ToDoItem object.
        /// </summary>
        /// <param name="id">Initial value of Id.</param>
        /// <param name="text">Initial value of Text.</param>
        /// <param name="createdDate">Initial value of CreatedDate.</param>
        public static ToDoItem CreateToDoItem(int id, string text, global::System.DateTime createdDate)
        {
            ToDoItem toDoItem = new ToDoItem();
            toDoItem.Id = id;
            toDoItem.Text = text;
            toDoItem.CreatedDate = createdDate;
            return toDoItem;
        }
        /// <summary>
        /// There are no comments for Property Id in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public int Id
        {
            get
            {
                return this._Id;
            }
            set
            {
                this.OnIdChanging(value);
                this.ReportPropertyChanging("Id");
                this._Id = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("Id");
                this.OnIdChanged();
            }
        }
        private int _Id;
        partial void OnIdChanging(int value);
        partial void OnIdChanged();
        /// <summary>
        /// There are no comments for Property Text in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string Text
        {
            get
            {
                return this._Text;
            }
            set
            {
                this.OnTextChanging(value);
                this.ReportPropertyChanging("Text");
                this._Text = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
                this.ReportPropertyChanged("Text");
                this.OnTextChanged();
            }
        }
        private string _Text;
        partial void OnTextChanging(string value);
        partial void OnTextChanged();
        /// <summary>
        /// There are no comments for Property CreatedDate in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.DateTime CreatedDate
        {
            get
            {
                return this._CreatedDate;
            }
            set
            {
                this.OnCreatedDateChanging(value);
                this.ReportPropertyChanging("CreatedDate");
                this._CreatedDate = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("CreatedDate");
                this.OnCreatedDateChanged();
            }
        }
        private global::System.DateTime _CreatedDate;
        partial void OnCreatedDateChanging(global::System.DateTime value);
        partial void OnCreatedDateChanged();
        /// <summary>
        /// There are no comments for Property DueDate in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Nullable<global::System.DateTime> DueDate
        {
            get
            {
                return this._DueDate;
            }
            set
            {
                this.OnDueDateChanging(value);
                this.ReportPropertyChanging("DueDate");
                this._DueDate = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("DueDate");
                this.OnDueDateChanged();
            }
        }
        private global::System.Nullable<global::System.DateTime> _DueDate;
        partial void OnDueDateChanging(global::System.Nullable<global::System.DateTime> value);
        partial void OnDueDateChanged();
        /// <summary>
        /// There are no comments for Property DoneDate in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Nullable<global::System.DateTime> DoneDate
        {
            get
            {
                return this._DoneDate;
            }
            set
            {
                this.OnDoneDateChanging(value);
                this.ReportPropertyChanging("DoneDate");
                this._DoneDate = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("DoneDate");
                this.OnDoneDateChanged();
            }
        }
        private global::System.Nullable<global::System.DateTime> _DoneDate;
        partial void OnDoneDateChanging(global::System.Nullable<global::System.DateTime> value);
        partial void OnDoneDateChanged();
        /// <summary>
        /// There are no comments for Owner in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("ToDoSample.Service.Entities", "FK_ToDos_Users", "Users")]
        [global::System.Xml.Serialization.XmlIgnoreAttribute()]
        [global::System.Xml.Serialization.SoapIgnoreAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public User Owner
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("ToDoSample.Service.Entities.FK_ToDos_Users", "Users").Value;
            }
            set
            {
                ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("ToDoSample.Service.Entities.FK_ToDos_Users", "Users").Value = value;
            }
        }
        /// <summary>
        /// There are no comments for Owner in the schema.
        /// </summary>
        [global::System.ComponentModel.BrowsableAttribute(false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Data.Objects.DataClasses.EntityReference<User> OwnerReference
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<User>("ToDoSample.Service.Entities.FK_ToDos_Users", "Users");
            }
            set
            {
                if ((value != null))
                {
                    ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<User>("ToDoSample.Service.Entities.FK_ToDos_Users", "Users", value);
                }
            }
        }
    }
    /// <summary>
    /// There are no comments for ToDoSample.Service.Entities.User in the schema.
    /// </summary>
    /// <KeyProperties>
    /// Id
    /// </KeyProperties>
    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="ToDoSample.Service.Entities", Name="User")]
    [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
    [global::System.Serializable()]
    public partial class User : global::System.Data.Objects.DataClasses.EntityObject
    {
        /// <summary>
        /// Create a new User object.
        /// </summary>
        /// <param name="id">Initial value of Id.</param>
        /// <param name="name">Initial value of Name.</param>
        public static User CreateUser(int id, string name)
        {
            User user = new User();
            user.Id = id;
            user.Name = name;
            return user;
        }
        /// <summary>
        /// There are no comments for Property Id in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public int Id
        {
            get
            {
                return this._Id;
            }
            set
            {
                this.OnIdChanging(value);
                this.ReportPropertyChanging("Id");
                this._Id = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("Id");
                this.OnIdChanged();
            }
        }
        private int _Id;
        partial void OnIdChanging(int value);
        partial void OnIdChanged();
        /// <summary>
        /// There are no comments for Property Name in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this.OnNameChanging(value);
                this.ReportPropertyChanging("Name");
                this._Name = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
                this.ReportPropertyChanged("Name");
                this.OnNameChanged();
            }
        }
        private string _Name;
        partial void OnNameChanging(string value);
        partial void OnNameChanged();
        /// <summary>
        /// There are no comments for ToDoItems in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("ToDoSample.Service.Entities", "FK_ToDos_Users", "ToDos")]
        [global::System.Xml.Serialization.XmlIgnoreAttribute()]
        [global::System.Xml.Serialization.SoapIgnoreAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Data.Objects.DataClasses.EntityCollection<ToDoItem> ToDoItems
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<ToDoItem>("ToDoSample.Service.Entities.FK_ToDos_Users", "ToDos");
            }
            set
            {
                if ((value != null))
                {
                    ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<ToDoItem>("ToDoSample.Service.Entities.FK_ToDos_Users", "ToDos", value);
                }
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect AREBIS
Belgium Belgium
Senior Software Architect and independent consultant.

Comments and Discussions