dimanche 23 avril 2017

Why .NET TypeInfo.GetDeclaredField return both public and private fields?

Documentation of TypeInfo.GetDeclaredField method clearly states that it "returns an object that represents the specified public field declared by the current type". So I suppose that it should distinguish by public and non-public fields and return "null" for non-public ones ("the specified field, if found; otherwise, null", according to the docs). However, if I define both public and private fields in the class, a call to GetDeclaredField on the corresponding TypeInfo object returns field object in both cases.

Is this a bug in documentation or a bug in the implementation? I can hardly believe this is an implementation bug since this is the part of core .NET functionality. So why is it documented in such way?





Aucun commentaire:

Enregistrer un commentaire