-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
seize dep volnurability warning; improve the IL debug output for the …
…type names; add test for #449
- Loading branch information
Showing
5 changed files
with
231 additions
and
13 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
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
55 changes: 55 additions & 0 deletions
55
test/FastExpressionCompiler.IssueTests/Issue449_MemberInit_produces_InvalidProgram.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,55 @@ | ||
using System; | ||
using NUnit.Framework; | ||
|
||
#if LIGHT_EXPRESSION | ||
using static FastExpressionCompiler.LightExpression.Expression; | ||
using FastExpressionCompiler.LightExpression; | ||
namespace FastExpressionCompiler.LightExpression.IssueTests; | ||
#else | ||
using static System.Linq.Expressions.Expression; | ||
using System.Linq.Expressions; | ||
namespace FastExpressionCompiler.IssueTests; | ||
#endif | ||
|
||
[TestFixture] | ||
public class Issue449_MemberInit_produces_InvalidProgram : ITest | ||
{ | ||
public int Run() | ||
{ | ||
// Original_case(); | ||
return 1; | ||
} | ||
|
||
public struct SampleType | ||
{ | ||
public int? Value { get; set; } | ||
|
||
public SampleType() { } | ||
} | ||
|
||
[Test] | ||
public void Original_case() | ||
{ | ||
var ctor = typeof(SampleType).GetConstructors()[0]; | ||
var valueProp = typeof(SampleType).GetProperty(nameof(SampleType.Value)); | ||
|
||
var expr = Lambda<Func<SampleType>>( | ||
MemberInit( | ||
New(ctor), | ||
Bind(valueProp, Constant(666, typeof(int?))))); | ||
|
||
expr.PrintCSharp(); | ||
|
||
var fs = expr.CompileSys(); | ||
fs.PrintIL(); | ||
|
||
var sr = fs(); | ||
Assert.AreEqual(666, sr.Value.Value); | ||
|
||
var ff = expr.CompileFast(false); | ||
ff.PrintIL(); | ||
|
||
var fr = ff(); | ||
Assert.AreEqual(666, sr.Value.Value); | ||
} | ||
} |
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