vendredi 15 juillet 2016

Public set accessor missing from function list

I am curious as to why when I reflect using

var functions = t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance).ToList()

to get all of the methods (including property accessors) why some set methods are ignored in the results.

Take the following example inside of System.Drawing.Imaging.EncoderParameter:

public Encoder Encoder {
    get {
        return new Encoder(parameterGuid);
    }
    set {
        parameterGuid = value.Guid;
    }
}

Getting the type for the aforementioned class and using the above var functions code, I do not get a setter method in the results, even though you would expect that considering the set method is public for the above property.

Any particular reason why this might be? Is it a bug in Reflection or am I just missing something?

I changed from .NET framework 4.5 to 4.6, but that made no difference in the results.





Aucun commentaire:

Enregistrer un commentaire