I can get easily see what projects and dlls a single project references from within a Visual Studio .NET project.
Is there any application or use of reflection that can build me a full dependency tree that I can use to plot a graphical chart of dependencies?
...
How do you tell if a function in Javascript is defined?
I want to do something like
function something_cool(text, callback){
alert(text);
if( callback != null ){ callback(); };
}
but that gets me a 'callback is not a function' error when callback is not defined.
...
Most mature C++ projects seem to have an own reflection and attribute system, i.e for defining attributes which can be accessed by string and are automatically serializable. At least many C++ projects I participated in seemed to reinvent the wheel.
Do you know any good open source libraries for C++ which support reflection and attribute...
I remember seeing a while ago that there is some method in maybe the Reflection namespace that would recursively run ToString() on all of an object's properties and format it nicely for display.
Yes, I know everything I could want will be accessible through the debugger, but I'm wondering if anyone knows that command?
...
When constructing an ArgumentException, a couple of the overloads take a string that is the invalid argument's parameter name. I figure it would be nice to not have to remember to update this ctor param whenever I change the method's param name. Is there a simple way to do this using reflection?
Update: thanks to the 2 respondents so fa...
Given this class
class Foo
{
// Want to find _bar with reflection
[SomeAttribute]
private string _bar;
public string BigBar
{
get { return this._bar; }
}
}
I want to find the private item _bar that I will mark with a attribute. Is that possible?
I have done this with properties where I have looked ...
I always believe they did, but seeing some answers here make me doubt...
Can I access private fields/properties/methods from outside a class through reflection?
...
For example, given a type param method i'm looking for something like the part in bold
void MyMethod< T >() {
if ( typeof(T).Implements( IMyInterface ) )
{
//Do something
else
//Do something else
}
Anwers using C# 3.0 are also welcome, but first drop the .NET 2.0 ones please ;)
...
Given an instance of System.Reflection.Assembly.
...
Is there any way via System.Reflection, System.Diagnostics or other to get a reference to the actual instance that is calling a static method without passing it in to the method itself.
For example, something along these lines
class A
{
public void DoSomething()
{
StaticClass.ExecuteMethod();
}
}
class B
{
public...
Using reflection in .Net, what is the differnce between:
if (foo.IsAssignableFrom(IBar))
And
if (foo.GetInterface(typeof(IBar).FullName) != null)
Which is more appropriate, why?
When could one or the other fail?
...
I am creating a generic error handling / logging class for our applications. The goal is to log the exception info, info about the class and function (as well as parameters) and if relevant, the information about the System.Data.SqlClient.SqlCommand object.
I would like to be able to handle passing in SqlCommands, TableAdaptors, and Sql...
I'm curious to know what other Java programmers feel is their favorite part of the language, why they feel that way, and why other programmers should want an intimate knowledge of it as well. I'm looking for reasons like simplicity, performance, etc. Thanks.
...
Is there a way to iterate (through foreach preferably) over a collection using reflection? I'm iterating over the properties in an object using reflection, and when the program gets to a type that is a collection, I'd like it to iterate over the contents of the collection and be able to access the objects in the collection.
At the mome...
I have a ArrayList made up of different elements imported from a db, made up of strings, numbers, doubles and ints. Is there a way to use a reflection type technique to find out what each type of data each element holds?
FYI: The reason that there is so many types of data is that this is a piece of java code being written to be implem...
I have a marker interface defined as
public interface IExtender<T>
{
}
I have a class that implements IExtender
public class UserExtender : IExtender<User>
At runtime I recieve the UserExtender type as a parameter to my evaluating method
public Type Evaluate(Type type) // type == typeof(UserExtender)
How do I make my Evaluate me...
Is there any way to create C# 3.0 anonymous object via Reflection at runtime in .NET 3.5? I'd like to support them in my serialization scheme, so I need a way to manipulate them programmatically.
edited later to clarify the use case
An extra constraint is that I will be running all of it inside a Silverlight app, so extra runtimes are ...
How to get an instance's member's values?
With propertyInfos there is a propertyInfo.GetValue(instance, index), but no such thing exists in memberInfo.
I searched the net, but it seems to stop at getting the member's name and type.
...
I need to determine if a Class object representing an interface extends another interface, ie:
package a.b.c.d;
public Interface IMyInterface extends a.b.d.c.ISomeOtherInterface{
}
according to the spec Class.getSuperClass() will return null for an Interface.
If this Class represents either the
Object class, an interf...
Ok, so I just ran into the following problem that raised an eyebrow.
For various reasons I have a testing setup where Testing classes in a TestingAssembly.dll depend on the TestingBase class in a BaseTestingAssembly.dll.
One of the things the TestBase does in the meantime is look for a certain embedded resource in its own and the callin...