-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
249 additions
and
55 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...EntityFramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommands.md
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
2 changes: 1 addition & 1 deletion
2
...ramework.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md
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
2 changes: 1 addition & 1 deletion
2
...iler.EntityFramework.Tests/GeneratedDocumentation/SummaryOfSupportedCommands.md
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
2 changes: 1 addition & 1 deletion
2
...tyFrameworkCore.Tests/GeneratedDocumentation/DetailedListOfSupportedCommands.md
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
2 changes: 1 addition & 1 deletion
2
...workCore.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md
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
2 changes: 1 addition & 1 deletion
2
....EntityFrameworkCore.Tests/GeneratedDocumentation/SummaryOfSupportedCommands.md
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
2 changes: 1 addition & 1 deletion
2
...yFrameworkCore3.Tests/GeneratedDocumentation/DetailedListOfSupportedCommands.md
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
2 changes: 1 addition & 1 deletion
2
...orkCore3.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md
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
2 changes: 1 addition & 1 deletion
2
...EntityFrameworkCore3.Tests/GeneratedDocumentation/SummaryOfSupportedCommands.md
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
2 changes: 1 addition & 1 deletion
2
...yFrameworkCore5.Tests/GeneratedDocumentation/DetailedListOfSupportedCommands.md
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
2 changes: 1 addition & 1 deletion
2
...orkCore5.Tests/GeneratedDocumentation/DetailedListOfSupportedCommandsWithSQL.md
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
2 changes: 1 addition & 1 deletion
2
...EntityFrameworkCore5.Tests/GeneratedDocumentation/SummaryOfSupportedCommands.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace DelegateDecompiler.Tests | ||
{ | ||
[TestFixture] | ||
public class Issue166 : DecompilerTestsBase | ||
{ | ||
[Test] | ||
public void ShouldSupportInstanceClosures() | ||
{ | ||
var comments = new Comment[0]; | ||
var expected = comments.AsQueryable().Select(c => new CommentDto | ||
{ | ||
HasUserPurchasedTheCourse = c.User.Purchases.Any(p => p.Items.Any(i => i.CourseId == c.CourseId)), | ||
}); | ||
var actual = comments.AsQueryable().Select(c => ToCommentDto(c)).Decompile(); | ||
AssertAreEqual(expected.Expression, actual.Expression); | ||
} | ||
|
||
[Decompile] | ||
static CommentDto ToCommentDto(Comment comment) | ||
{ | ||
return new CommentDto | ||
{ | ||
HasUserPurchasedTheCourse = comment.User.Purchases.Any(p => p.Items.Any(i => i.CourseId == comment.CourseId)), | ||
}; | ||
} | ||
|
||
class Comment | ||
{ | ||
public User User { get; set; } | ||
|
||
public int CourseId { get; set; } | ||
} | ||
|
||
class User | ||
{ | ||
public IEnumerable<Purchase> Purchases { get; set; } | ||
} | ||
|
||
class PurchaseItem | ||
{ | ||
public int CourseId { get; set; } | ||
} | ||
|
||
class Purchase | ||
{ | ||
public IEnumerable<PurchaseItem> Items { get; set; } | ||
} | ||
|
||
class CommentDto | ||
{ | ||
public bool HasUserPurchasedTheCourse { get; set; } | ||
} | ||
} | ||
} |
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,49 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace DelegateDecompiler.Tests | ||
{ | ||
[TestFixture] | ||
public class Issue167 : DecompilerTestsBase | ||
{ | ||
[Test] | ||
public void ShouldFlattenTransparentExpressions() | ||
{ | ||
var comments = new Comment[0]; | ||
var expected = comments.AsQueryable().Select(c => new CommentDto | ||
{ | ||
IsUserPurchaser = c.Purchases.Any(p => p.UserId == c.UserId) | ||
}); | ||
var actual = comments.AsQueryable().Select(c => ToCommentDto(c)).Decompile(); | ||
|
||
AssertAreEqual(expected.Expression, actual.Expression); | ||
} | ||
|
||
[Decompile] | ||
static CommentDto ToCommentDto(Comment comment) | ||
{ | ||
return new CommentDto | ||
{ | ||
IsUserPurchaser = comment.Purchases.Any(p => p.UserId == comment.UserId), | ||
}; | ||
} | ||
|
||
public class Comment | ||
{ | ||
public int UserId { get; set; } | ||
|
||
public IEnumerable<Purchase> Purchases { get; } | ||
} | ||
|
||
public class Purchase | ||
{ | ||
public int UserId { get; set; } | ||
} | ||
|
||
public class CommentDto | ||
{ | ||
public object IsUserPurchaser { get; set; } | ||
} | ||
} | ||
} |
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,44 @@ | ||
using NUnit.Framework; | ||
|
||
namespace DelegateDecompiler.Tests | ||
{ | ||
[TestFixture] | ||
public class Issue171 | ||
{ | ||
[Test] | ||
public void ShouldSupportStructsWithoutInitializer() | ||
{ | ||
var method = typeof(Issue171).GetMethod(nameof(X1)); | ||
var expression = method.Decompile(); | ||
|
||
Assert.That(expression.ToString(), Is.EqualTo("this => new DataOnStack() {StatementCount = 1}")); | ||
} | ||
|
||
[Test] | ||
public void ShouldSupportStructsWithInitializer() | ||
{ | ||
var method = typeof(Issue171).GetMethod(nameof(X2)); | ||
var expression = method.Decompile(); | ||
|
||
Assert.That(expression.ToString(), Is.EqualTo("this => new DataOnStack() {StatementCount = 1}")); | ||
} | ||
|
||
public DataOnStack X1() | ||
{ | ||
DataOnStack x; | ||
x.StatementCount = 1; | ||
return x; | ||
} | ||
|
||
|
||
public DataOnStack X2() | ||
{ | ||
return new DataOnStack {StatementCount = 1}; | ||
} | ||
|
||
public struct DataOnStack | ||
{ | ||
public uint StatementCount; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace DelegateDecompiler | ||
{ | ||
internal static class MemberExtensions | ||
{ | ||
public static Type FieldOrPropertyType(this MemberInfo member) | ||
{ | ||
switch (member) | ||
{ | ||
case FieldInfo field: | ||
return field.FieldType; | ||
case PropertyInfo property: | ||
return property.PropertyType; | ||
default: | ||
throw new NotSupportedException($"MemberInfo {member} is not supported"); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.