• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #region Copyright notice and license
2 // Protocol Buffers - Google's data interchange format
3 // Copyright 2015 Google Inc.  All rights reserved.
4 //
5 // Use of this source code is governed by a BSD-style
6 // license that can be found in the LICENSE file or at
7 // https://developers.google.com/open-source/licenses/bsd
8 #endregion
9 
10 using System;
11 using System.Reflection;
12 using Google.Protobuf.TestProtos;
13 using NUnit.Framework;
14 using UnitTest.Issues.TestProtos;
15 
16 #pragma warning disable CS0612 // Type or member is obsolete
17 namespace Google.Protobuf
18 {
19     public class DeprecatedMemberTest
20     {
AssertIsDeprecated(MemberInfo member)21         private static void AssertIsDeprecated(MemberInfo member)
22         {
23             Assert.NotNull(member);
24             Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member);
25         }
26 
27         [Test]
TestDeprecatedPrimitiveValue()28         public void TestDeprecatedPrimitiveValue() =>
29             AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty(nameof(TestDeprecatedFields.DeprecatedInt32)));
30 
31         [Test]
TestDeprecatedMessage()32         public void TestDeprecatedMessage() =>
33             AssertIsDeprecated(typeof(DeprecatedChild));
34 
35         [Test]
TestDeprecatedEnum()36         public void TestDeprecatedEnum() =>
37             AssertIsDeprecated(typeof(DeprecatedEnum));
38 
39         [Test]
TestDeprecatedEnumValue()40         public void TestDeprecatedEnumValue() =>
41             AssertIsDeprecated(typeof(DeprecatedEnum).GetField(nameof(DeprecatedEnum.DeprecatedZero)));
42     }
43 }
44 #pragma warning restore CS0612 // Type or member is obsolete
45