-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds support for nameof expression (issue #95)
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
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,19 @@ | ||
using NUnit.Framework; | ||
|
||
namespace Cecilifier.Core.Tests.Tests.Unit | ||
{ | ||
[TestFixture] | ||
public class NameOfTests : CecilifierUnitTestBase | ||
{ | ||
[TestCase("using System; [Obsolete(nameof(Foo))] public class Foo { }", "new CustomAttributeArgument(assembly.MainModule.TypeSystem.String, \"Foo\")", TestName = "Attribute Parameter")] | ||
[TestCase("public class Foo { string ConstString = nameof(ConstString); }", "Ldstr, \"ConstString\"",TestName = "Field Initialization")] | ||
[TestCase("public class Foo { string Name() => nameof(Name); }", "Ldstr, \"Name\"",TestName = "Method Return")] | ||
[TestCase("public class Foo { string StringInterpolation() => $\"Name={nameof(StringInterpolation)}\"; }", "??",TestName = "String Interpolation", IgnoreReason = "Depends on #107")] | ||
public void Test(string code, string expectedLiteral) | ||
{ | ||
var result = RunCecilifier(code); | ||
var cecilifiedCode = result.GeneratedCode.ReadToEnd(); | ||
Assert.That(cecilifiedCode, Contains.Substring(expectedLiteral)); | ||
} | ||
} | ||
} |
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
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