| 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 MethodBuilderInitLocals |
| 10 |
{ |
| 11 |
[Fact] |
| 12 |
public void InitLocals_Get_ReturnsTrue() |
| 13 |
{ |
| 14 |
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract); |
| 15 |
MethodBuilder method = type.DefineMethod("TestMethod", MethodAttributes.Public); |
| 16 |
Assert.True(method.InitLocals); |
| 17 |
} |
| 18 |
|
| 19 |
[Theory] |
| 20 |
[InlineData(true)] |
| 21 |
[InlineData(false)] |
| 22 |
public void InitLocals_Set(bool newInitLocals) |
| 23 |
{ |
| 24 |
TypeBuilder type = Helpers.DynamicType(TypeAttributes.Abstract); |
| 25 |
MethodBuilder method = type.DefineMethod("TestMethod", MethodAttributes.Public); |
| 26 |
|
| 27 |
method.InitLocals = newInitLocals; |
| 28 |
Assert.Equal(newInitLocals, method.InitLocals); |
| 29 |
} |
| 30 |
} |
| 31 |
} |