diff options
author | Jon Skeet <jonskeet@google.com> | 2015-07-28 08:16:50 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-07-28 08:16:50 +0100 |
commit | 0802d56fcde72346554240f932ad11a789e16fbe (patch) | |
tree | 5097d607a5b82776267ba19b0a1b4d0b13ea94ad /csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs | |
parent | 0dbd5ec80d33ea2a37f5362a24fd72b2c5f51aaa (diff) | |
download | protobuf-0802d56fcde72346554240f932ad11a789e16fbe.tar.gz protobuf-0802d56fcde72346554240f932ad11a789e16fbe.tar.bz2 protobuf-0802d56fcde72346554240f932ad11a789e16fbe.zip |
Tweaks to Profile259 support
- Fix nupec paths
- Remove an obsolete part of the JSON build
- Add documentation and tests to reflection extension methods, and improve implementations
Diffstat (limited to 'csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs b/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs index 934424f8..8a6fefa7 100644 --- a/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs +++ b/csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs @@ -34,16 +34,31 @@ using System.Reflection; namespace Google.Protobuf.Compatibility { + /// <summary> + /// Extension methods for <see cref="PropertyInfo"/>, effectively providing + /// the familiar members from previous desktop framework versions while + /// targeting the newer releases, .NET Core etc. + /// </summary> internal static class PropertyInfoExtensions { + /// <summary> + /// Returns the public getter of a property, or null if there is no such getter + /// (either because it's read-only, or the getter isn't public). + /// </summary> internal static MethodInfo GetGetMethod(this PropertyInfo target) { - return target.GetMethod; + var method = target.GetMethod; + return method != null && method.IsPublic ? method : null; } + /// <summary> + /// Returns the public setter of a property, or null if there is no such setter + /// (either because it's write-only, or the setter isn't public). + /// </summary> internal static MethodInfo GetSetMethod(this PropertyInfo target) { - return target.SetMethod; + var method = target.SetMethod; + return method != null && method.IsPublic ? method : null; } } } |