Debian Codegraph @

external/corefx/src/System.Reflection.Emit/tests/PropertyBuilder/PropertyBuilderGetValue.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 PropertyBuilderTest8
10 {
11 [Fact]
12 public void GetValue_ThrowsNotSupportedException()
13 {
14 TypeBuilder type = Helpers.DynamicType(TypeAttributes.Class | TypeAttributes.Public);
15 PropertyBuilder property = type.DefineProperty("TestProperty", PropertyAttributes.None, typeof(int), null);
16 MethodBuilder method = type.DefineMethod("TestMethod", MethodAttributes.Public, CallingConventions.HasThis, typeof(int), null);
17
18 ILGenerator methodILGenerator = method.GetILGenerator();
19 methodILGenerator.Emit(OpCodes.Ldarg_0);
20 methodILGenerator.Emit(OpCodes.Ret);
21 property.AddOtherMethod(method);
22
23 type.CreateTypeInfo().AsType();
24 Assert.Throws<NotSupportedException>(() => property.GetValue(null, null));
25 }
26 }
27 }