Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: third_party/protobuf/csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #region Copyright notice and license 1 #region Copyright notice and license
2 // Protocol Buffers - Google's data interchange format 2 // Protocol Buffers - Google's data interchange format
3 // Copyright 2015 Google Inc. All rights reserved. 3 // Copyright 2015 Google Inc. All rights reserved.
4 // https://developers.google.com/protocol-buffers/ 4 // https://developers.google.com/protocol-buffers/
5 // 5 //
6 // Redistribution and use in source and binary forms, with or without 6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are 7 // modification, are permitted provided that the following conditions are
8 // met: 8 // met:
9 // 9 //
10 // * Redistributions of source code must retain the above copyright 10 // * Redistributions of source code must retain the above copyright
(...skipping 15 matching lines...) Expand all
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #endregion 31 #endregion
32 32
33 using System; 33 using System;
34 using System.Reflection; 34 using System.Reflection;
35 35
36 #if !DOTNET35
36 namespace Google.Protobuf.Compatibility 37 namespace Google.Protobuf.Compatibility
37 { 38 {
38 /// <summary> 39 /// <summary>
39 /// Provides extension methods on Type that just proxy to TypeInfo. 40 /// Provides extension methods on Type that just proxy to TypeInfo.
40 /// These are used to support the new type system from .NET 4.5, without 41 /// These are used to support the new type system from .NET 4.5, without
41 /// having calls to GetTypeInfo all over the place. While the methods here a re meant to be 42 /// having calls to GetTypeInfo all over the place. While the methods here a re meant to be
42 /// broadly compatible with the desktop framework, there are some subtle dif ferences in behaviour - but 43 /// broadly compatible with the desktop framework, there are some subtle dif ferences in behaviour - but
43 /// they're not expected to affect our use cases. While the class is interna l, that should be fine: we can 44 /// they're not expected to affect our use cases. While the class is interna l, that should be fine: we can
44 /// evaluate each new use appropriately. 45 /// evaluate each new use appropriately.
45 /// </summary> 46 /// </summary>
46 internal static class TypeExtensions 47 internal static class TypeExtensions
47 { 48 {
48 /// <summary> 49 /// <summary>
49 /// Returns true if the target type is a value type, including a nullabl e value type or an enum, or false
50 /// if it's a reference type (class, delegate, interface - including Sys tem.ValueType and System.Enum).
51 /// </summary>
52 internal static bool IsValueType(this Type target)
53 {
54 return target.GetTypeInfo().IsValueType;
55 }
56
57 /// <summary>
58 /// See https://msdn.microsoft.com/en-us/library/system.type.isassignabl efrom 50 /// See https://msdn.microsoft.com/en-us/library/system.type.isassignabl efrom
59 /// </summary> 51 /// </summary>
60 internal static bool IsAssignableFrom(this Type target, Type c) 52 internal static bool IsAssignableFrom(this Type target, Type c)
61 { 53 {
62 return target.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo()); 54 return target.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo());
63 } 55 }
64 56
65 /// <summary> 57 /// <summary>
66 /// Returns a representation of the public property associated with the given name in the given type, 58 /// Returns a representation of the public property associated with the given name in the given type,
67 /// including inherited properties or null if there is no such public pr operty. 59 /// including inherited properties or null if there is no such public pr operty.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (ret != null && ret.IsPublic) 96 if (ret != null && ret.IsPublic)
105 { 97 {
106 return ret; 98 return ret;
107 } 99 }
108 target = typeInfo.BaseType; 100 target = typeInfo.BaseType;
109 } 101 }
110 return null; 102 return null;
111 } 103 }
112 } 104 }
113 } 105 }
106 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698