Inspect Mono .NET Types with monop2

monop2 prints the public outline of a Mono type straight from the assembly, so a failed lookup means either a typo or a missing type.

Allow about ten minutes. The examples were checked with Debian's mono-devel package, version 6.8.0.105+dfsg-3.6ubuntu2, where monop2 reports runtime version 4.0.30319.42000. Other Mono releases can show different members or diagnostic text.

You do not need root for these checks: they read installed assemblies and write their output to the terminal. Do not use sudo merely because a type cannot be found.

1. Confirm the executable and runtime

Check which executable your shell will run and which package supplied it. This catches a missing installation and a surprising alternate copy early:

$ command -v monop2
/usr/bin/monop2
$ dpkg-query -W -f='${Package} ${Version}\n' mono-devel
mono-devel 6.8.0.105+dfsg-3.6ubuntu2
$ monop2 --runtime-version
runtime version: 4.0.30319.42000

Checkpoint: you should have a path, a package version and a runtime version. If command -v prints nothing, install mono-devel through your normal package-management process. That is the only step in this guide that may need elevated privileges, and it changes system state, so review the package transaction before accepting it.

2. Print a type outline by its full name

The positional argument is the type to inspect, using its full name including the namespace. This example prints the signature of System.String:

$ monop2 System.String
[Serializable]
public sealed class String : ICloneable, IComparable, IComparable<string>, IConvertible, System.Collections.IEnumerable, System.Collections.Generic.IEnumerable<char>, IEquatable<string> {
	
	
	public String (char [] value);
	...
}

The exact member list is release-dependent, so treat the abbreviated output above as an orientation point rather than a spec. The useful result is a readable declaration and member signatures: the command does not run the type's methods and does not modify the assembly.

A common trip-up is using a short name such as String. The manual requires the full name, so start with a namespace-qualified name even when the type feels obvious.

3. Use metadata notation for generic classes

For a generic type, pass the backtick followed by its arity, and quote the argument so the shell passes it unchanged:

$ monop2 'System.Collections.Generic.List`1'
[Serializable]
public class List<T> : ICollection, ICollection<T>, IEnumerable, IEnumerable<T>, IList, IList<T>, IReadOnlyCollection<T>, IReadOnlyList<T> {
	
	public List ();
	public List (int capacity);
	public List (IEnumerable<T> collection);
	public void Add (T item);
	...
}

The `1 means one generic parameter; a two-parameter type uses `2. This is the reflection-style name used for lookup, not the same spelling as the source-language declaration List<T>.

4. Narrow the displayed members

When a large outline gets hard to scan, add one of the manpage's filtering switches:

$ monop2 -d System.String
[Serializable]
public sealed class String : ICloneable, IComparable, IComparable<string>, ... {
	
	public String (char [] value);
	...
}

These switches change what is printed, not the assembly being inspected. Start with -d when inherited members are the noise, and add -p only when you are deliberately examining implementation details: private members are often less useful for designing against a public API.

5. Inspect a specific assembly

Use -r:assembly when the type must be looked up in a particular assembly. The option has a colon, so keep the assembly path immediately after -r::

$ monop2 -r:/usr/lib/mono/4.5/mscorlib.dll --refs
$ printf 'exit status: %s\n' "$?"
exit status: 0

--refs prints referenced assemblies and requires -r:assembly. An assembly can have no displayed references, as in this installed mscorlib.dll check, so an empty terminal result is not automatically an error. For the outline itself, add the full type name after the assembly option, for example monop2 -r:/path/to/library.dll Example.Namespace.Widget.

Tip: the -a switch asks for all types in the specified assembly. Treat that as potentially large output: redirect it to a new file if you need to search it, and do not overwrite an existing report with shell redirection.

6. Search when the full name is unknown

The manpage documents --search, with short forms -s and -k, for searching known assemblies. It loads many assemblies, so it can be slower and noisier than a direct lookup:

$ monop2 --search String
Loading mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
...
Could not find String
$ printf 'exit status: %s\n' "$?"
exit status: 1

Example: on this installed build, the literal search term String did not match and returned status 1 after loading assemblies. That is a lookup result, not proof Mono is broken. Try the exact namespace-qualified name directly, or search for the name as it appears in the assembly metadata. If the output is large, capture it in a new file:

$ monop2 --search 'String' > monop2-search.txt 2>&1
$ printf 'exit status: %s\n' "$?"
exit status: 1

Keep the search file if someone else needs to inspect it, and remove it later only when it is no longer useful. The search command does not alter assemblies, but it can generate a substantial report; the non-zero status here is just the installed build's response to an unsuccessful lookup.

7. Diagnose a missing type without escalating privileges

Check the spelling, namespace and assembly selection before changing permissions or installing anything. Confirm a candidate assembly is readable:

$ test -r /usr/lib/mono/4.5/mscorlib.dll && echo readable
readable
$ monop2 'System.Collections.Generic.List`1' >/dev/null
$ printf 'exit status: %s\n' "$?"
exit status: 0

If the direct lookup succeeds, the earlier failure was probably the type name or search term. If the assembly is genuinely absent, find the package that should provide it with your distribution's package tools. Do not download an unrelated DLL into a system directory, and do not replace a system assembly as a troubleshooting shortcut.

For a report you may want to share, avoid blindly redirecting over an existing file. Use a new name such as monop2-report.txt, or copy an existing report first. If a command fails after opening the destination, inspect the file before reusing it: a redirection can leave a truncated report.

Done means