Index: third_party/grpc/src/csharp/Grpc.Core/Internal/SafeHandleZeroIsInvalid.cs |
diff --git a/third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs b/third_party/grpc/src/csharp/Grpc.Core/Internal/SafeHandleZeroIsInvalid.cs |
similarity index 68% |
copy from third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs |
copy to third_party/grpc/src/csharp/Grpc.Core/Internal/SafeHandleZeroIsInvalid.cs |
index 8dfad8b331c1622d9325af438a1eaa6e1c5c25fd..702aea2883ad828c6f0b8e6675bb2b0c56522f92 100644 |
--- a/third_party/protobuf/csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs |
+++ b/third_party/grpc/src/csharp/Grpc.Core/Internal/SafeHandleZeroIsInvalid.cs |
@@ -1,7 +1,7 @@ |
-#region Copyright notice and license |
-// Protocol Buffers - Google's data interchange format |
-// Copyright 2015 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
+#region Copyright notice and license |
+ |
+// Copyright 2015, Google Inc. |
+// All rights reserved. |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -28,28 +28,39 @@ |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ |
#endregion |
- |
+ |
using System; |
-using System.Reflection; |
-using Google.Protobuf.TestProtos; |
-using NUnit.Framework; |
+using System.Runtime.InteropServices; |
-namespace Google.Protobuf |
+namespace Grpc.Core.Internal |
{ |
- public class DeprecatedMemberTest |
+ /// <summary> |
+ /// Safe handle to wrap native objects. |
+ /// </summary> |
+ internal abstract class SafeHandleZeroIsInvalid : SafeHandle |
{ |
- private static void AssertIsDeprecated(MemberInfo member) |
+ public SafeHandleZeroIsInvalid() : base(IntPtr.Zero, true) |
+ { |
+ } |
+ |
+ public SafeHandleZeroIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle) |
{ |
- Assert.NotNull(member); |
- Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member); |
} |
- [Test] |
- public void TestDepreatedPrimitiveValue() |
+ public override bool IsInvalid |
{ |
- AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32")); |
+ get |
+ { |
+ return handle == IntPtr.Zero; |
+ } |
} |
+ protected override bool ReleaseHandle() |
+ { |
+ // handle is not owned. |
+ return true; |
+ } |
} |
} |