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.
- codeanalyzerandtodosample.zip
- CodeAnalyzer and Sample Solution.sln
- Generate.cmd
- Generator
- Output
- Blank.html
- co_CreateToDoItem(int,string,Nullable[DateTime])_ToDoItem.html
- co_DeleteToDoItem(int)_void.html
- co_FindUserByName(string)_User.html
- co_GetToDoItem(int)_ToDoItem.html
- co_GetUser(int)_User.html
- co_ListAllToDoItems()_IEnumerable[ToDoItem].html
- co_ListAllUsers()_IEnumerable[User].html
- co_ListDoneItemsForUser(int)_IEnumerable[ToDoItem].html
- co_ListToDoItemsForUser(int)_IEnumerable[ToDoItem].html
- co_ListUsersMatching(string)_IEnumerable[User].html
- co_MarkToDoItemDone(int)_void.html
- co_UpdateToDoItem(int,string,Nullable[DateTime])_void.html
- CodeModel.css
- CodeModel.js
- Content.html
- Index.html
- IndexTop.html
- so_CreateToDoItem(int,string,Nullable[DateTime])_ToDoItem.html
- so_DeleteToDoItem(int)_void.html
- so_FindUserByName(string)_User.html
- so_GetUser(int)_User.html
- so_ListAllUsers()_List[User].html
- so_ListDoneItemsForUser(int)_List[ToDoItem].html
- so_ListToDoItemsForUser(int)_List[ToDoItem].html
- so_ListUsersMatching(string)_List[User].html
- so_MarkToDoItemDone(int)_void.html
- so_UpdateToDoItem(int,string,Nullable[DateTime])_ToDoItem.html
- ui_CreateNewToDoItemClicked(object,System.Windows.RoutedEventArgs)_void.html
- ui_DeleteClicked(object,System.Windows.RoutedEventArgs)_void.html
- ui_InitializeComponent()_void.html
- ui_MarkDoneClicked(object,System.Windows.RoutedEventArgs)_void.html
- ui_RefreshToDoItems()_void.html
- ui_SaveClicked(object,System.Windows.RoutedEventArgs)_void.html
- ui_ToDoItemSelected(object,System.Windows.Controls.SelectionChangedEventArgs)_void.html
- ui_UserSelected(object,System.Windows.Controls.SelectionChangedEventArgs)_void.html
- ui_WindowLoaded(object,System.Windows.RoutedEventArgs)_void.html
- SampleApp
- LocalTestRun.testrunconfig
- ToDoApplication
- ToDoContract
- ToDoSample.vsmdi
- ToDoService
- ToDoUnitTests
- StaticCodeAnalyzer
- Arebis.CodeAnalysis.Static
- Arebis.Common
|
using System;
using System.Text;
namespace System.Collections.Generic.Net2
{
/// <summary>
/// A collection of unique unordered members.
/// </summary>
/// <typeparam name="T">Member type.</typeparam>
[Serializable]
[Obsolete("Since .NET 3.5, prefer System.Collections.Generic.HashSet, from System.Core.dll.", false)]
public class HashSet<T> : ICollection<T>
{
private Dictionary<T, object> internalList;
#region Constructor methods
public HashSet()
: this(new DefaultEqualityComparer<T>())
{ }
public HashSet(IEqualityComparer<T> customComparer)
{
this.internalList = new Dictionary<T, object>(customComparer);
}
public HashSet(IEnumerable<T> range)
: this()
{
this.AddRange(range);
}
public HashSet(IEnumerable<T> range, IEqualityComparer<T> customComparer)
: this(customComparer)
{
this.AddRange(range);
}
#endregion Constructor methods
#region ICollection<T> Members
public void Add(T item)
{
if (!this.internalList.ContainsKey(item))
this.internalList.Add(item, null);
}
public void Clear()
{
this.internalList.Clear();
}
public bool Contains(T item)
{
return this.internalList.ContainsKey(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
this.internalList.Keys.CopyTo(array, arrayIndex);
}
public int Count
{
get { return this.internalList.Count; }
}
public bool IsReadOnly
{
get { return false; }
}
public bool Remove(T item)
{
return this.internalList.Remove(item);
}
#endregion
#region IEnumerable<T> Members
public IEnumerator<T> GetEnumerator()
{
return this.internalList.Keys.GetEnumerator();
}
#endregion
#region Additional Members
public void AddRange(IEnumerable<T> range)
{
foreach (T item in range)
this.Add(item);
}
#endregion
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return ((System.Collections.IEnumerable)this.internalList.Keys).GetEnumerator();
}
#endregion
#region Default Comparer
[Serializable]
private class DefaultEqualityComparer<U> : IEqualityComparer<U>
{
public bool Equals(U x, U y)
{
if (Object.ReferenceEquals(x, y))
return true;
else if (Object.ReferenceEquals(x, null))
return false;
else
return x.Equals(y);
}
public int GetHashCode(U obj)
{
return obj.GetHashCode();
}
}
#endregion
}
}
|
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.