Debian Codegraph @

external/corefx/src/System.Reflection.Emit/tests/PropertyBuilder/PropertyBuilderGetIndexParameters.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 PropertyBuilderTest7
10 {
11 [Fact]
12 public void GetIndexParameters_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("TestProperty", 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 myType = type.CreateTypeInfo().AsType();
24 Assert.Throws<NotSupportedException>(() => property.GetIndexParameters());
25 }
26 }
27 }