Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6728731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:12:18+00:00 2026-05-26T10:12:18+00:00

I have a number of test classes in C# ( NUnit Test scripts ,

  • 0

I have a number of test classes in C# (NUnit Test scripts, compiling on Mono).

Instead of compiling all unit tests into one big assembly, as usual, I’d like to compile the individual class files into separate assemblies. To do so, I’d like to do a dependency analysis, so I can generate the separate assemblies automatically.

What I’m looking for is similar to class dependency analyser which exists for Java

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:12:19+00:00Added an answer on May 26, 2026 at 10:12 am

    Have a look at Mono Cecil.

    This library has the capability to ‘reflect’ (not a very good name for it) on the actual assembly image to do analysis. This assumes that you would be willing to compile down to a ‘big’ assembly in order to run the dependency analysis using Mono.Cecil.

    Edit In fact, you might simply use Cecil to copy the ‘big’ assembly while filtering out parts of it. That way, you’ll not have much of the complexity of compiling the separate assemblies; Look at CecilRoundtrip sample for an example of how to roundtrip (read -> manipulate -> save) assemblies in Cecil.

    I have previously published quite extensive examples of how to use Mono Cecil for ‘advanced’ searches (static call tree search, in essence):

    • Get types used inside a C# method body
    • Look if a method is called inside a method using reflection

    The absolute bare minimum that would be most useful to you would probably be:

    var types = assemblies
        .SelectMany(assembly => assembly.MainModule.Types.Cast<TypeDefinition>());
    
    var dependencies = types.ToDictionary(
        key => key,
        typedef => new HashSet<string>(typedef.Methods.Cast<MethodDefinition>()
                    .Where(method => null != method.Body) // ignore abstracts and generics
                    .SelectMany(method => method.Body.Instructions.Cast<Instruction>())
                    .Select(instr => instr.Operand)
                    .OfType<TypeReference>().Distinct()
              //    .Where(type => !type.Namespace.StartsWith("System"))
                    .Select(type => type.Name)));
    
    foreach (var entry in dependencies)
    {
         Console.WriteLine("{0}\t{1}", entry.Key.Name, string.Join(", ", entry.Value.ToArray()));
    }
    

    Note the commented line optionally filters out things from the framework (System.String, System.Char etc.).

    This will list required types per declared type. To list types used, simply tag on the lookup to assembly name:

                    .Select(type => type.Module.Assembly.Name.Name)));
    

    Sample output of the first kind (types required):

    SegmentSoortKenmerk     SegmentSoortKenmerk
    OperatorValue
    Koppelpad       Koppelpad, CodeLeidendVolgend
    RedenWaarschuwing
    RelExceptions
    GecontroleerdDocument   GecontroleerdDocument, GecontroleerdDocument[]
    OwiExtraKenmerk OwiExtraKenmerk, Gegeven, BackofficeRelatie
    Entiteit        Entiteit, SleutelSysteemObject[], EniteitType
    

    Similar query but using the assembly name lookup:

    SegmentSoortKenmerk     Lspo.Business
    OperatorValue
    Koppelpad       Lspo.Business
    RedenWaarschuwing
    RelExceptions
    GecontroleerdDocument   Lspo.Business
    OwiExtraKenmerk Lspo.Business
    Entiteit        Lspo.Business
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a number of tests failing in the following JUnit Task. <target name=test-main
I unit test my classes by giving all my classes an interface. These interfaces
I have a number of test classes and methods that copy a particular directory
I have a number of Eclipse projects that are all using classes from a
I have written an application that unit tests our hardware via a internet browser.
I have a problem with one-to-many relationships. I have the following domain classes: public
I have an application where many unit tests use a real connection to an
I'd like to execute all tests in a /test directory without using annotations such
I have a WPF dll that contains a number of Window classes and exposes
I have developed some classes with similar behavior, they all implement the same interface.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.