Debian Codegraph @

external/corefx/src/System.Reflection.Emit/tests/MethodBuilder/MethodBuilderGetGenericMethodDefinition.cs

raw
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 using Xunit;
6
7 namespace System.Reflection.Emit.Tests
8 {
9 public class MethodBuilderGetGenericMethodDefinition
10 {
11 [Fact]
12 public void GetGenericMethodDefinition()
13 {
14 TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
15 MethodBuilder method = type.DefineMethod("TestMethod", MethodAttributes.Public);
16 method.DefineGenericParameters("T", "U");
17 Assert.True(method.GetGenericMethodDefinition().Equals(method));
18 }
19
20 [Fact]
21 public void GetGenericMethodDefinition_NonGenericMethod_ThrowsInvalidOperationException()
22 {
23 TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract);
24 MethodBuilder method = type.DefineMethod("TestMethod", MethodAttributes.Public);
25
26 Assert.Throws<InvalidOperationException>(() => method.GetGenericMethodDefinition());
27 }
28 }
29 }