forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of System.Reflection.Emit.ILGeneration.
- Loading branch information
1 parent
7aa7b9d
commit 39252e0
Showing
39 changed files
with
7,078 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/System.Reflection.Emit.ILGeneration/System.Reflection.Emit.ILGeneration.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.22609.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Reflection.Emit.ILGeneration.Tests", "tests\System.Reflection.Emit.ILGeneration.Tests.csproj", "{FB037640-0591-4DF4-A331-0BEFE50A200B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{FB037640-0591-4DF4-A331-0BEFE50A200B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FB037640-0591-4DF4-A331-0BEFE50A200B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FB037640-0591-4DF4-A331-0BEFE50A200B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FB037640-0591-4DF4-A331-0BEFE50A200B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
147 changes: 147 additions & 0 deletions
147
....Reflection.Emit.ILGeneration/tests/CustomAttributeBuilder/CustomAttributeBuilderCtor1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
using System.Reflection.Emit; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace System.Reflection.Emit.ILGeneration.Tests | ||
{ | ||
public class CustomAttributeBuilderCtor1 | ||
{ | ||
[Fact] | ||
public void PosTest1() | ||
{ | ||
string str = "PosTest1"; | ||
Type[] ctorParams = new Type[] { typeof(string) }; | ||
object[] paramValues = new object[] { str }; | ||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
typeof(ObsoleteAttribute).GetConstructor(ctorParams), paramValues); | ||
|
||
Assert.NotNull(cab); | ||
} | ||
|
||
[Fact] | ||
public void PosTest2() | ||
{ | ||
Type[] ctorParams = new Type[] { }; | ||
object[] paramValues = new object[] { }; | ||
|
||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
typeof(ObsoleteAttribute).GetConstructor(ctorParams), paramValues); | ||
|
||
Assert.NotNull(cab); | ||
} | ||
|
||
[Fact] | ||
public void PosTest3() | ||
{ | ||
string str = "PosTest3"; | ||
bool b = TestLibrary.Generator.GetByte(-55) > Byte.MaxValue / 2; | ||
|
||
Type[] ctorParams = new Type[] { typeof(string), typeof(bool) }; | ||
object[] paramValues = new object[] { str, b }; | ||
|
||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
typeof(ObsoleteAttribute).GetConstructor(ctorParams), paramValues); | ||
|
||
Assert.NotNull(cab); | ||
} | ||
|
||
[Fact] | ||
public void NegTest1() | ||
{ | ||
object[] paramValues = new object[] { }; | ||
|
||
Assert.Throws<ArgumentException>(() => | ||
{ | ||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
typeof(TestConstructor).GetConstructors(BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic) | ||
.Where(c => c.IsStatic).First(), paramValues); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void NegTest2() | ||
{ | ||
object[] paramValues = new object[] | ||
{ | ||
false | ||
}; | ||
|
||
Assert.Throws<ArgumentException>(() => | ||
{ | ||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
typeof(TestConstructor).GetConstructors(BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic) | ||
.Where(c => c.IsPrivate).First(), paramValues); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void NegTest3() | ||
{ | ||
string str = "NegTest3"; | ||
bool b = false; | ||
|
||
Type[] ctorParams = new Type[] { typeof(string) }; | ||
object[] paramValues = new object[] { str, b }; | ||
|
||
Assert.Throws<ArgumentException>(() => | ||
{ | ||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
typeof(ObsoleteAttribute).GetConstructor(ctorParams), paramValues); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void NegTest4() | ||
{ | ||
string str = "NegTest4"; | ||
bool b = true; | ||
|
||
Type[] ctorParams = new Type[] { typeof(string), typeof(bool) }; | ||
object[] paramValues = new object[] { b, str }; | ||
|
||
Assert.Throws<ArgumentException>(() => | ||
{ | ||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
typeof(ObsoleteAttribute).GetConstructor(ctorParams), paramValues); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void NegTest5() | ||
{ | ||
string str = "NegTest5"; | ||
bool b = false; | ||
|
||
object[] paramValues = new object[] { str, b }; | ||
|
||
Assert.Throws<ArgumentNullException>(() => | ||
{ | ||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
null, paramValues); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void NegTest6() | ||
{ | ||
Type[] ctorParams = new Type[] { typeof(bool), typeof(string) }; | ||
|
||
Assert.Throws<ArgumentNullException>(() => | ||
{ | ||
CustomAttributeBuilder cab = new CustomAttributeBuilder( | ||
typeof(ObsoleteAttribute).GetConstructor(ctorParams), null); | ||
}); | ||
} | ||
} | ||
|
||
public class TestConstructor | ||
{ | ||
static TestConstructor() { } | ||
internal TestConstructor(bool b) { } | ||
} | ||
} |
Oops, something went wrong.