Click here to Skip to main content
15,885,366 members
Articles / Programming Languages / C#

FindRefs - Find Method, Property and Field References Originating From Your Assembly

Rate me:
Please Sign up or sign in to vote.
4.08/5 (6 votes)
3 Apr 2007CPOL3 min read 27.8K   444   13  
A command line utility that analyzes your assembly and generates an XML file containing the methods, fields and properties referenced, grouped by assembly and type
using System;
using System.Collections.Generic;
using System.Text;

namespace Senthil.Tools
{
    class Reference : IComparable<Reference>
    {
        internal Reference(string assembly, string type, string referenceName)
        {
            this.assembly = assembly;
            this.type = type;
            this.referenceName = referenceName;
        }

        string assembly;

        public string Assembly
        {
            get { return assembly; }
        }
        string type;

        public string Type
        {
            get { return type; }
        }
        string referenceName;

        public string ReferenceName
        {
            get { return referenceName; }
        }

        public override bool Equals(object obj)
        {
            if (Object.ReferenceEquals(this, obj))
                return true;

            Reference reference = obj as Reference;
            if (reference == null)
                return false;

            return reference.assembly == this.assembly && reference.type == this.type && reference.referenceName == this.referenceName;
        }

        public override int GetHashCode()
        {
            return assembly.GetHashCode() ^ type.GetHashCode() ^ referenceName.GetHashCode();
        }


        #region IComparable<Reference> Members

        public int CompareTo(Reference other)
        {
            return string.Compare(this.referenceName, other.referenceName);
        }

        #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.

License

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


Written By
Software Developer Atmel R&D India Pvt. Ltd.
India India
I'm a 27 yrs old developer working with Atmel R&D India Pvt. Ltd., Chennai. I'm currently working in C# and C++, but I've done some Java programming as well. I was a Microsoft MVP in Visual C# from 2007 to 2009.

You can read My Blog here. I've also done some open source software - please visit my website to know more.

Comments and Discussions