QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using System.Linq.Expressions;
|
|
using Centron.BusinessLogic.Sales.Receipts.Internal;
|
|
using Centron.Data.Entities.Sales.Receipts.DeliveryLists;
|
|
using Centron.Interfaces.Sales.Receipts.DeliveryLists;
|
|
|
|
namespace Centron.Tests.BL.Sales.Receipts.Internal;
|
|
|
|
public class ReceiptExpressionHelperTest
|
|
{
|
|
[Fact]
|
|
public void GetExpression_RewritesArrayContainsForReceiptFilters()
|
|
{
|
|
int[] receiptItemI3Ds = [1, 2];
|
|
|
|
Expression<Func<ReceiptDeliveryList, bool>> filter =
|
|
receipt => receipt.Items.Any(item => receiptItemI3Ds.Contains(item.I3D));
|
|
|
|
var result = ReceiptExpressionHelper.GetExpression<ReceiptDeliveryList, IReceiptDeliveryList>(filter);
|
|
|
|
Assert.NotNull(result);
|
|
Assert.False(ContainsArrayContainsOrImplicitConversion(result));
|
|
}
|
|
|
|
private static bool ContainsArrayContainsOrImplicitConversion(Expression expression)
|
|
{
|
|
var visitor = new ArrayContainsOrImplicitConversionFinder();
|
|
visitor.Visit(expression);
|
|
return visitor.Found;
|
|
}
|
|
|
|
private sealed class ArrayContainsOrImplicitConversionFinder : ExpressionVisitor
|
|
{
|
|
public bool Found { get; private set; }
|
|
|
|
protected override Expression VisitMethodCall(MethodCallExpression node)
|
|
{
|
|
if (node.Method.Name == "op_Implicit")
|
|
{
|
|
Found = true;
|
|
return node;
|
|
}
|
|
|
|
if (node.Method.Name == "Contains" && node.Arguments.Count > 0)
|
|
{
|
|
var source = node.Object ?? node.Arguments[0];
|
|
if (source.Type.IsArray)
|
|
Found = true;
|
|
}
|
|
|
|
return base.VisitMethodCall(node);
|
|
}
|
|
}
|
|
}
|